Is it necessary that charts need to be open always to fire the order from Amibroker to Nest Trader… How to fire orders from generated scan results of AFL??
Hi AShetty...
Applying a Strategy to multiple Symbols at a time in Amibroker to fire orders To Nest Trader through plus Trading Plug-in...
Suppose U have 50 Symbols/Tickers in Ur Database and Ur Strategy is saved in Test.afl (For Example) and
U wants to apply Ur Strategy to all 50 Symbols and fire orders to nest trader if any symbol generates signal...
For That there are Two options..
Option-I:
Open Chart for Each ticker and drag and drop ur Test.afl on each chart and Lock symbol for each Chart and Tile/Float Windows..
This options takes more resources and performance of Amibroker will lower..
Option-II:
Open a single Chart and Select any symbol..
Send Ur Test.afl to Automatic Analysis..
In the settings Drop down menu..Tick Auto Repeat (AR) Scan/Explore and enter AR Interval as 1s (For One second Repeat)
Press Scan Button
It’ll scan all symbols in Database with Ur Test.afl every second...And if any symbol generates signal, order will be fired to Nest Trader...
Important Points To Use Plus Trading Plug-in..
- Ensure that U subscribed to Plus Trading Plug-in (Rs300/month) if not Mail to [email protected] to subscribe
- Ensure that Nest Trader is updated with Latest version of Nest Plus..If not download it from http://zerodha.com/downloads
- Ensure that U have logged into Nest Plus..
- “MARKET” Order Type is not supported by Plus Trading Plug-in
- MCX Exchange is not Supported..
Important Points To Charting in Amibroker..
1. If U have opened multiple charts and each chart with separate symbol and all charts having same chart Id..
Then If U Change/Assign any value in the parameter window of one Chart will be applied to all chart with same chart Id..
2. Any Changes made in the Parameter window will not be applied while scanning the same AFL through automatic analysis window..
Important Points To Use The Below AFL..
- This AFL is to fire Orders From Amibroker to Nest Trader
- Pay Attention to Line Number 30 – 35
- Enter Ur strategy in the Trading System Section..Not anywhere else..
- Ensure that U changed/Confirmed the Following values in the AFL
NClientId
NExch
NTrdSymbol
NLotNo
NProdType
_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 ="AB1234";//Change To Ur Zerodha Client Id-Line No 30 NExch = "NFO";//Change as per Ur Trading segment-Line No 31 NTrdSymbol = Name()+"FUT";//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[i] ) PlotText( "Buy @ " + C[ i ], i-3, L[ i ]-dist[i], colorGreen ); if( Sell[i] ) PlotText( "Sell @ " + C[ i ], i-3, H[ i ]+dist[i], colorOrange); if( Short[i] ) PlotText( "Short @ " + C[ i ], i-3, H[ i ]+dist[i], colorRed ); if( Cover[i] ) PlotText( "Cover @ " + C[ i ], i-3, L[ i ]-dist[i], colorPaleGreen ); } _SECTION_END();
Say I get access to NestPlus API and would like to fire MARKET order via PlaceOrder funtion in NestPlus API.
- What I heard is that market order are not allowed in NEstPlusAPI, how to fire market orders?
- My algo generate signal which I want to execute with PlaceOrder function in NestPLus API, but NestPlus API allowes only Limit orders so my order may or may not execute. But as orders are generate by my algo so I want to execute that orders with 100% certainty even with some slippage. How to get rid of this problem?? How to trade my order with 100% certainty?
Thanks,
Param
Hi,
It is not necessary to keep open chart to fire orders from ami to nest.
U can send ur afl to auto analysis and do a auto repeat scan provided that u have included plus api code in ur afl and hav subscribed to plus trading plugin.
Thanks for ur reply sir… Could u please help me with plus api code that is to be attached to afl…
Hi ashetty,
Here power cut.I’ll post the code when power comes tonight.U just need to insert ur strategy in the code.That’s it.I’ll post detailed instruction on multiple symbol scan.
What is ur ticker format in ami and which segment u want to trade?
NFO and MCX Sir… Ticker format…SBIN15MAR
Sir… Is there any chance to invoke a bracket order???
Hi AShetty…
BO Not Supported by Nest Plugin…
But Similar thing can be manipulated through AFL…
U can place a Target and STloss order after U taking Long/Short…and Cancel one order if Others gets Executed…
The Only Diff…BO handles the cancel itself…But through AFL It’ll fire order to Nest and U Have to Submit It…
(1) What lines of code will make this afl starts and stops by itself everyday at specific time…
(2) Please add position sizing and max number of position held…
(3) How to make this AFL remember to sell/cover open positions, if position size exceed due to extreme price increase/decrease…
(4) Make this AFL to generate first buy then sell and short before cover…