How to AUTO Place from Nest Plus API? Apart from Manual Place Button

#1


I dont want to click Place or Ignore.. it should auto execute..

My Working Code is :

_SECTION_BEGIN("Chart Options");
GfxSetBkMode(0);
SetChartOptions (0,chartShowDates|chartShowArrows,chartGridMiddle,0,0,10);
SetChartBkColor( colorBlack ) ;
SetChartBkGradientFill( colorBlack,colorBlack);
SetBarFillColor( IIf( C > O, colorLime, IIf(C <= O,colorRed,colorBlack ) ));
Plot(Close,"Close",IIf( C > O, colorLime, IIf(C <= O,colorRed,colorBlack ) ),styleCandle|styleNoTitle);
pxw = Status("pxwidth");
pxh = Status("pxheight");
GfxSelectFont( "Lucida Fax", 16, 700, False );
GfxSetTextColor( colorYellow );
GfxGradientRect( 1, 1, pxw, 30, colorGrey50, colorDarkGrey);
GfxTextOut( "AMIBROKER - NESTPLUGIN ", (pxw/2)-120, 4 );
GfxSetTextColor( colorGold );
GfxTextOut( Name(), 5, 4 );
GfxTextOut( Date(), PXW-250, 4 );
GfxSelectFont( "Lucida Fax", 24, 700, False );
GfxSetTextColor( colorOrange );
GfxTextOut( "LTP:"+" "+WriteVal(LastValue(C,1),1.2), (PXW/2)-80, 60 );
GfxSelectFont( "Lucida Fax", 11, 700, False );GfxSetTextColor( colorWhite );
GfxTextOut( "Op :"+WriteVal(Open,1.2)+" Hi :"+WriteVal(High,1.2)+" Lo :"+WriteVal(Low,1.2)+" Cl :"+WriteVal(Close,1.2), 3, 35);
_SECTION_END();

_SECTION_BEGIN("Inputs For Nest Plugin");
Buy=Sell=Short=Cover=0;
BarN = ValueWhen(DateNum()!= Ref(DateNum(),-1),BarIndex());
BarNo = IIf(IsEmpty(BarN),BarIndex()+1,BarIndex()-BarN+1);
Bvalue = LastValue(ValueWhen(BarNo==1,C),1);
PrvC = IIf(IsEmpty(TimeFrameGetPrice("C",inDaily,-1)),ValueWhen(BarNo==1,O),TimeFrameGetPrice("C",inDaily,-1));
NClientId ="****";//Change To Ur Zerodha Client Id-Line No 30
NExch = "NFO";//Change as per Ur Trading segment-Line No 31
NTrdSymbol = Name();//Since Ur Ticker Format is SBIN15MAR...adding FUT to last 'll make Trade Symbol
NProdType = "MIS";//Line No 33
NOrdType = "LIMIT";//Line No 34
NLotNo = 1;//Enter Ur No of lots to Trade .. DoNot Enter Lot size here-Line No 35
NOrder="Null";
_SECTION_END();

_SECTION_BEGIN("Trading System");
//Sample Trading System..Replace It with your own
Buy = Cross(C,Ref(HHV(H,30),-1));
Short =Cross(Ref(LLV(L,30),-1),C);
Sell = Cross(C,Ref(HHV(L,60),-1));
Cover =Cross(Ref(LLV(L,60),-1),C);

Buy=ExRem(Buy,Short);
Short=ExRem(Short,Buy);
Sell= ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);
_SECTION_END();

_SECTION_BEGIN("NestPluginAPI");
ORder = IIf(Buy,1,IIf(Sell,2,IIf(Short,3,IIf(Cover,4,0))));
BSCond = LastValue(ORder,1);
NLmtPrice = LastValue(ValueWhen(BSCond >0,C),1);
Checkone=StaticVarGetText("Check"+StrFormat(Name()));
Checktwo = StrFormat(Name())+"-"+NumToStr(LastValue((Cum(Buy)+Cum(Sell)+Cum(Short)+Cum(Cover)),1),1.0)+"-"+NumToStr(GetChartID(),1.0);
if (LastValue(Buy)){NOrder="BUY";NRefNo = Name()+"-"+"Buy"+"-"+NumToStr(Cum(Buy),1.0)+"-"+Now(0); }
if (LastValue(Short)){NOrder="SELL";NRefNo = Name()+"-"+"Short"+"-"+NumToStr(Cum(Short),1.0)+"-"+Now(0); }
if (LastValue(Sell)){NOrder="SELL";NRefNo = Name()+"-"+"Sell"+"-"+NumToStr(Cum(Sell),1.0)+"-"+Now(0); }
if (LastValue(Cover)){NOrder="BUY";NRefNo = Name()+"-"+"Cover"+"-"+NumToStr(Cum(Cover),1.0)+"-"+Now(0); }
if (BSCond >0 AND CheckOne != CheckTwo){
{plus = CreateStaticObject("Nest.PlusApi");
plus.SetObjectName(NClientId); // result = Null;
plus.PlaceOrder(NOrder,NRefNo,NExch,NTrdSymbol,"DAY",NOrdType,NLotNo,NLmtPrice,0,0,NProdType,NClientId);}
StaticVarSetText("Check"+StrFormat(Name()),CheckTwo );}
_SECTION_END();

_SECTION_BEGIN("Trades Plot");
PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow + Short * shapeDownArrow + Cover * shapeUpArrow , IIf( Buy, colorGreen,IIf(Short,colorRed,IIf(Sell,colorOrange, IIf(Cover,colorPaleGreen,colorBlack))) ),0,IIf(Buy OR Cover ,L,IIf(Sell OR Short ,H,C)), Offset=-30 );
dist = 1.5*ATR(60);
for( i = 0; i < BarCount; i++ )
{if( Buy ) PlotText( "Buy @ " + C[ i ], i-3, L[ i ]-dist, colorGreen );
if( Sell ) PlotText( "Sell @ " + C[ i ], i-3, H[ i ]+dist, colorOrange);
if( Short ) PlotText( "Short @ " + C[ i ], i-3, H[ i ]+dist, colorRed );
if( Cover ) PlotText( "Cover @ " + C[ i ], i-3, L[ i ]-dist, colorPaleGreen ); }
_SECTION_END();
 

NJ23

Well-Known Member
#2
You'd need a dealer terminal for that.
 

josh1

Well-Known Member
#5
It seems auto trading should be enabled by your broker. You are using PlusAPI.
I use NestRTD to capture live prices from terminal. However, I have to request my broker to enable it. Same way .........