AFL to place order from Amibroker to Pi using the Pi BRIDGE

Choks, the code you posted on Zconnect to fire orders, I am facing multiple orders problem again, The AFL(your codes for placing order) is working fine, but now i have noticed that the AFL is sending multiple orders “when a signal is generated for more than one chart at a time”. For examble i have two charts open and buy signal is generated in both same time, then the afl is sending multiple orders for this two symbols one by one until the signal bar is closed. As its not happening always, i can still manage, but do u think u can find a solution for this too.
 

////——————————-\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

ClientId = “DP0012″;//Change As per Your client ID
TrdSymbol = “ICICIBANK15JANFUT”;//Change As per Your Symbol
Symbol = “ICICIBANK”;//Change As per Your Symbol
QYT = Param(“Lot Size?”,1,1,25,1);
Exch =ParamList(“Select Exch?”, “NFO|BFO|NSE|BSE|CDS|MCX” );
PType = ParamList(“Product Type?”, “MIS|NRML|CNC” );
OType = ParamList(“Order Type?”, “L|MKT|SL|SL-M” );

BuyP = LastValue(ValueWhen(Buy,C),1);
ShortP = LastValue(ValueWhen(Short,C),1);
SellP = LastValue(ValueWhen(Sell,C),1);
CoverP = LastValue(ValueWhen(Cover,C),1);

Checkone=Nz(StaticVarGet(“Check”),0);
Checktwo = LastValue(BarIndex(),1);
OrdCond=LastValue(Buy) OR LastValue(Short) OR LastValue(Sell) OR LastValue(Cover);

Brd = Null;

if(OrdCond AND CheckOne != CheckTwo)
{
brd = CreateStaticObject(“pibridge.Bridge”);

if(LastValue(Buy))
{
brd.PlaceOrder (Exch, TrdSymbol ,Symbol,”MyAFL”, 1,Qty,0, BuyP, 0, OType, PType, ClientId,”DAY”);
}

if(LastValue(Sell))
{
brd.PlaceOrder (Exch, TrdSymbol,Symbol,”MyAFL”, 2,Qty,0, SellP, 0, OType,PType, ClientId,”DAY”);
}

if(LastValue(Cover))
{
brd.PlaceOrder (Exch, TrdSymbol,Symbol,”MyAFL”, 1,Qty,0, CoverP, 0, OType, PType, ClientId,”DAY”);
}

if(LastValue(Short))
{
brd.PlaceOrder (Exch, TrdSymbol,Symbol,”MyAFL”, 2,Qty,0, ShortP, 0, OType,PType, ClientId,”DAY”);
}
StaticVarSet(“Check”,CheckTwo );
}

Alert = Buy OR Short OR Cover OR Sell;
AlertIf(Alert,”SOUND C:\\Windows\\Media\\Notify.wav”, “Audio alert”, 0 );

///————————————–\\\\\\\
1 Like

Below is the Complete AFL..For Placing Orders From Amibroker to Pi..

https://drive.google.com/uc?export=download&id=0B-AWKNHhYByLLW05TXlJcEVZd0U
 

SetChartOptions (0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

_SECTION_BEGIN
("Zerodha Pi");
/*
Before GoTo Live...Configure All Inputs in the Parameter Window
1.Zerodha ClientId - Enter Ur client ID
2.Choose Ur Stock Exchange..
3.Select Ur Symbol Source for Pi Bridge
How To Use Symbolmapper..
Symbols.txt file is Located in C:\Program Files\Amibroker\Formulas Folder
One Line Per Symbol
Ex:
ACC,ACC-EQ
AXISBANK-I,AXISBANK15FEBFUT
SILVERM-I,SILVERM5FEBFUT
First word 'll be Symbol Format in AmiBroker and Comma and Followed by TrdSymbol Format in Pi
Write in the Same way for all Symbols in Database
4.Trading Segment - Select Equity if want to trade in NSE,BSE
Select Futures -if want to trade in NFO,BFO,MCX
5.Trade Value for Equity - Enter Ur investment Amount Qty'll automatically Calculated for Equity
6.All Trades Generated On AMI 'll be Written in Log file Located at C:\Program Files\Amibroker\Formulas\OrderLog.txt
7.LotSize.txt file located in C:\Program Files\Amibroker\Formulas\
Format is
One Line Per Symbol
SILVERM,10
BHEL-I,1000
First word 'll be Symbol Format in AmiBroker AND Comma AND Lot Size of Future
Write in the Same way for all Future Symbols Only in Database
It is Used only for Calculating P/L and Display it Chart..

Inside This AFL...Insert Your Buy/Short/Sell/Cover at the Place Specified...

Initially Try with Only One Segment..Ex NSE OR NFO etc
For Mutiple Segment U need to open Blank Chart for Each Segment...
and Drag & Drop this AFL into Each chart...
And Change Parameters with respect to each segment...
The Following Parameters 'll differ for each Segmemt 
1.Select Stock Exchange
2.Select Trading Segment
3.Trade Value for Equity
4.Choose Lot Size for Futures

Always check order Log File in formulas folder for Analysis..
U Can check the Trd Symbol which is displayed in Chart..
*/

GfxSetBkMode(0);
Fnt1 = "Arial";
GfxSelectFont( Fnt1, 12, 700, False );
GfxSetTextColor( colorWhite );
EnableScript("VBScript");
SL1 = ValueWhen(DateNum()!= Ref(DateNum(),-1) AND DateNum()==LastValue(DateNum(),1),BarIndex());
SLNo = IIf(IsEmpty(SL1),BarIndex()+1,BarIndex()-SL1+1);
//Getting Height & Width of Charts
pxw = Status("pxwidth");
pxh = Status("pxheight");
//Initializing Variables Needed For Functions
//---------Variables for Trading System ------------\\
Buy=Cover=Short=Sell=0;
NString ="TEXT";
ORder = 0;
BSCond = 0;
RefNo = StrFormat(Name()) + "_" + StrFormat(Now(0));
ChartSymbol = StrFormat(Name());
SymolMapper = "Use Symbol Mapper";
NTrdes = "EQUITY";//OR "FUTURES"
NTrdValue = 10000;//FOR EQUITY
NLot = 1;//Lot Size For Futures
Bvalue = LastValue(ValueWhen(SLNO==1,C),1);
QtyPL = 123456789;//For Calculating Profit Or Loss
NTrdTime = StrFormat(Now(0));
NOrderT ="Buy";
BTgtPrice = 100;
BSLprice = 150;
STgtPrice =100;
SSLPrice = 150;

//---------Variables for Pi Bridge ------------\\
NExch = "NSE";
NTrdSymbol = "ACC-EQ";
NSymbol = "ACC";
NLogic = "MYLOGIC";
NOrder = "BUY";
NQty = 1000;
NlmtPrice = 100;
NTrgPrice= 120;
NOrdType = "LIMIT";
NProdType = "MIS";
NClient = "DC0314";
NVal = "DAY";
//FIRST BOX
//GfxGradientRect( pxw/2, 1, (pxw/2)+5, pxh, colorGrey50, colorDarkGrey);

GfxGradientRect( 1, 1, pxw, 40, colorGrey50, colorDarkGrey);
GfxSelectFont( "Georgia", 18, 800, False );
GfxSetTextColor( colorYellow );
GfxTextOut( "ZERODHA PI ", (pxw/2)-80, 8 );
GfxSelectFont( "Tahoma", 16, 800, False );
GfxSetTextColor( colorGold );
GfxTextOut( Name(), pxw/60, 8 );
GfxSelectFont( "Century Gothic", 15, 100, False );
GfxSetTextColor( colorWhite );
GfxTextOut( Date(), pxw-220, 8 );
GfxSelectFont( "Comic Sans MS", 15, 500, False );
GfxSetTextColor( colorYellow );
GfxTextOut( Interval(2), pxw/5, 8);
///-----------------------------------------------------
//SECOND BOX
GfxGradientRect( 1, 40, pxw, 55, colorGrey50, colorDarkGrey );
GfxSelectFont( Fnt1, 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "High:"+WriteVal(H,1.2), pxw/60, 41 );
GfxTextOut( "Low:"+WriteVal(L,1.2), pxw/10, 41 );
GfxTextOut( "Open:"+WriteVal(O,1.2), pxw/5.5, 41 );
GfxTextOut( "Close:"+WriteVal(C,1.2), pxw/3.7, 41 );
GfxSelectFont( "Brush Script MT", 18, 800, False );
GfxSetTextColor( colorSkyblue );
GfxTextOut( "Welcome to 2020 Trading!!", (pxw/2)-120, 35  );
GfxSelectFont("Tahoma", 15, 600, False, False, 0);
GfxSetTextColor(colorOrange); 
GfxTextOut( "LTP:"+WriteVal(C,1.2), (pxw/2)-60, 60);
GfxSelectFont( Fnt1, 12, 700, False );
GfxSetTextColor( colorWhite );

DayH=HHV(H,SLNO);  
DayL=LLV(L,SLNO);  
DayHL = ParamToggle("Draw Day High/Low ?","Show|Hide",1);
if(DayHL==1)
{
GfxGradientRect( pxw-187, 58, pxw-61, 83, colorGreen, colorDarkGreen );
GfxTextOut( "DayH:"+" "+WriteVal(DayH,1.2), pxw-186, 60 );
GfxGradientRect( pxw-187, pxh-45, pxw-61, pxh-20, colorRed, colorDarkRed );
GfxTextOut( "DayL:"+" "+WriteVal(DayL,1.2), pxw-186, pxh-42 );
}
NClient = ParamStr("ZeroDha ClientId","DC0314");
NLogic = ParamStr("Enter Ur Logic Name","MYLOGIC");
NExch = ParamList("Select Stock Exchange","NSE,NFO,MCX,BSE,BFO,CDS",0);
NTrdSymbol1 = ParamList("Select TrdSymbol Source","Use Symbol Mapper,Use Chart Symbol,I Type Symbol",0);
NTrdSymbol2 = ParamStr("Enter Trd Symbol Here","ACC-EQ");
NProdType = ParamList("Select Product Type","MIS,NRML,CNC",0);
NOrdType = ParamList("Select Order Type","L,MKT,SL,SL-M",0);
NTrades = ParamList("Select Trading Segment","EQUITY,FUTURES",0);
NTrdValue = Param("TradeValue For Equity?",10000,1000,2500000,500);
NLot = Param("Choose Lot Size Futures?",1,1,25,1);
logOrd = ParamToggle("Write Trade Details to LogFile?","Yes|No",1);
TgtPer = Param("Target Percentage?",1,0.25,10,0.25);
SLPer = Param("Stop Loss Percentage?",1,0.25,10,0.25);

if(Ntrades == "EQUITY")
NQty = ceil(NTrdValue/BValue);
else
if(Ntrades == "FUTURES")
NQty = NLot;

if(Ntrades == "EQUITY")
QtyPL = NQty;
else
if(Ntrades == "FUTURES")
QtyPL1 = "FUTURES";

if(NTrdSymbol1 == "Use Symbol Mapper")
SymolMapper = "Use Symbol Mapper";
else
if(NTrdSymbol1 == "Use Chart Symbol")
NTrdSymbol = StrFormat(Name());
else
if(NTrdSymbol1 == "I Type Symbol")
NTrdSymbol = NTrdSymbol2;

<%
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")

if objFSO.FileExists("C:\Program Files\Amibroker\Formulas\Symbols.txt") then
else
objFSO.CreateTextFile("C:\Program Files\Amibroker\Formulas\Symbols.txt")
end if
if objFSO.FileExists("C:\Program Files\Amibroker\Formulas\LotSize.txt") then
else
objFSO.CreateTextFile("C:\Program Files\Amibroker\Formulas\LotSize.txt")
end if
if objFSO.FileExists("C:\Program Files\Amibroker\Formats\Orders.txt") then
else
objFSO.CreateTextFile("C:\Program Files\Amibroker\Formats\Orders.txt")
Set objFile = objFSO.OpenTextFile("C:\Program Files\Amibroker\Formats\Orders.txt", 2)
objFile.Writeline "StartPoint"&VbCrLf
objFile.Close
end if
if objFSO.FileExists("C:\Program Files\Amibroker\Formulas\OrderLog.txt") then 
else 
objFSO.CreateTextFile("C:\Program Files\Amibroker\Formulas\OrderLog.txt") 
end if

NTrdSymbol = AFL("NTrdSymbol")
ChartSymbol = AFL("ChartSymbol")
SymolMapper = AFL("SymolMapper")

if SymolMapper = "Use Symbol Mapper" then
Set objFile = objFSO.OpenTextFile("C:\Program Files\Amibroker\Formulas\Symbols.txt", 1)
do Until objFile.AtEndOfStream
    strsearch = objFile.ReadLine
 	  if instr(strSearch,ChartSymbol&",") = 1 Then
	  NTrdSymbol = Mid(strsearch, InStr(1, strsearch, ",") + 1, Len(strsearch) - InStr(1, strsearch, ","))
     else
		end if
Loop
objFile.Close
else
end if
AFL("NTrdSymbol") = NTrdSymbol
%>

if (NTrdSymbol == NTrdSymbol2 AND NTrdSymbol1 == "Use Symbol Mapper")
{NTrdSymbol = ChartSymbol;
GfxTextOut( "Symbol Not Found In Symbol Mapper" ,(pxw/2)-150, pxh/2);}

<%
QtyPL1 = AFL("QtyPL1")
ChartSymbol = AFL("ChartSymbol")
QtyPL = AFL("QtyPL")

if QtyPL1 = "FUTURES" then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Program Files\Amibroker\Formulas\LotSize.txt", 1)
do Until objFile.AtEndOfStream
    strsearch = objFile.ReadLine
   if instr(strSearch,ChartSymbol&",") = 1 Then
    QtyPLI = Mid(strsearch, InStr(1, strsearch, ",") + 1, Len(strsearch) - InStr(1, strsearch, ","))
    QtyPL=CInt(QtyPLI)
    else
    End if
Loop
objFile.Close
else
end if
AFL("QtyPL") = QtyPL
%>
if (QtyPL == 123456789 AND NTrades == "FUTURES")
{QtyPL = NQty;
GfxTextOut( "Lot Size Not Found In Lot Size File" ,(pxw/2)-138, (pxh/2)+25);}
//-------Your Buy/Short/Sell/Cover Conditions Starts Here------\\\

//-------Your Buy/Short/Sell/Cover Conditions Ends Here------\\\
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);
String1 = StrFormat(Name())+"_" +StrFormat(Now(1));
if(BSCond==1)
{NOrder = 1;
NOrderT = "Buy";
NString = String1+"_Buy_"+NumToStr(Cum(Buy),1.0);}
else
if(BSCond==2)
{NOrder = 2;
NOrderT = "Sell";
NString = String1+"_Sell_"+NumToStr(Cum(Sell),1.0);}
else
if(BSCond==3)
{NOrder = 2;
NOrderT = "Short";
NString = String1+"_Short_"+NumToStr(Cum(Short),1.0);}
else
if(BSCond==4)
{NOrder = 1;
NOrderT = "Cover";
NString = String1+"_Cover_"+NumToStr(Cum(Cover),1.0);}
else
{NOrder = "NO_Order";
NString = String1;}

<%
InputSym = AFL("NString")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Program Files\Amibroker\Formats\Orders.txt", 1)
do Until objFile.AtEndOfStream
    strsearchstring = objFile.ReadLine
    if strsearchstring = InputSym  Then
	 InputSym = "NO"
    else
     End if
Loop
objFile.Close
AFL("NString") = InputSym
%>

if ( NString !="NO" AND BSCond > 0)
{brd = CreateStaticObject("pibridge.Bridge");
brd.PlaceOrder (NExch, NTrdSymbol ,StrLeft(ChartSymbol,9),NLogic, NOrder,NQty,0, NLmtPrice, 0, NOrdType, NProdType, NClient,NVal);}

<%
InputSym = AFL("NString")
BSCond = AFL("BSCond")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Program Files\Amibroker\Formats\Orders.txt", 8)
if InputSym <> "NO" AND BSCond > 0  Then
objFile.WriteLine(InputSym)
else
end if
objFile.Close
%>

<%
InputSym = AFL("NString")
BSCond = AFL("BSCond")
NTrdSymbol = AFL("NTrdSymbol")
NExch = AFL("NExch")
NorderT= AFL("NOrderT")
NOrdType= AFL("NOrdType")
NProdtype= AFL("NProdType")
NlmtPrice= AFL("NLmtPrice")
NTrdTime = AFL("NTrdTime")
logOrd = AFL("LogOrd")
NEnd = "******************************************"

Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objFile = objFSO.OpenTextFile("C:\Program Files\Amibroker\Formulas\OrderLog.txt", 8) 
if InputSym <> "NO" AND BSCond > 0 AND logOrd = 1 Then 
objFile.WriteLine "Symbol:" & NTrdSymbol & VbCrLf _
& "Exch:" & NExch & VbCrLf _
& "Order:" & NOrderT & VbCrLf _
& "Order Type:" & NOrdType & VbCrLf _
& "Prod Type:" & NProdType & VbCrLf _
& "Price:" & NLmtPrice & VbCrLf _
& "Trd Time:" & NTrdTime & VbCrLf _
& NEnd & VbCrLf
else 
end if 
objFile.Close 
%>

TrdBox = ParamToggle("Display Trade Box with P/L","Show|Hide",1);
if(TrdBox==1) 
{
PriceBuy = IIf(Buy,ValueWhen(Buy,C),0);
QtyBuy = Sum(IIf(Buy,QtyPL,0),SLNO);
ValBuy = IIf(Buy,PriceBuy*QtyPL,0);
TValBuy = Sum(ValBuy,SLNO);
NumBuy = Sum(Buy,SLNO);
BuyPL = IIf(NumBuy>0,(C*QtyBuy)-TvalBuy,0);
AvgBuy = Sum(PriceBuy,SLNO)/NumBuy;
PriceSell = IIf(Sell,ValueWhen(Sell,C),0);
QtySell = Sum(IIf(Sell,QtyPL,0),SLNO);
ValSell = IIf(Sell,PriceSell*QtyPL,0);
TValSell = Sum(ValSell,SLNO);
NumSell = Sum(Sell,SLNO);
SellPL = IIf(NumSell >0,TvalSell - (C*QtySell),0);
LongPL = BuyPL;//BuyPL+SellPL;
PriceShort = IIf(Short,ValueWhen(Short,C),0);
QtyShort = Sum(IIf(Short,QtyPL,0),SLNO);
ValShort = IIf(Short,PriceShort*QtyPL,0);
TValShort = Sum(ValShort,SLNO);
NumShort = Sum(Short,SLNO);
ShortPL = IIf(NumShort>0,TvalShort-(C*QtyShort),0);
AvgShort = Sum(PriceShort,SLNO)/NumShort;
PriceCover = IIf(Cover,ValueWhen(Cover,C),0);
QtyCover = Sum(IIf(Cover,QtyPL,0),SLNO);
ValCover = IIf(Cover,PriceCover*QtyPL,0);
TValCover = Sum(ValCover,SLNO);
NumCover = Sum(Cover,SLNO);
CoverPL = IIf(NumCover >0,(C*QtyCover)-TvalCover,0) ;
ShrtPL = ShortPL+CoverPL;
BTGTPrice = AvgBuy + (AvgBuy * (TgtPer/100));
BSLPrice = AvgBuy - (AvgBuy * (SLPer/100));
STGTPrice = AvgShort - (AvgShort * (TgtPer/100));
SSLPrice = AvgShort + (AvgShort * (TgtPer/100));
GfxSelectSolidBrush( colorOrange );
GfxSelectPen( colorLime, 1); 
GfxRoundRect( 2, pxh-195, 371, pxh-155 , 7, 7 ) ;
GfxTextOut( "TrdSymbol" ,90, pxh-193);
GfxTextOut( ":"+NTrdSymbol ,185, pxh-193);
GfxTextOut( "Qty/LotSize" ,90, pxh-173);
GfxTextOut( ":"+QtyPL ,185, pxh-173);
GfxSelectSolidBrush( colorBlue );
GfxSelectPen( colorRed, 1);
GfxRoundRect( 2, pxh-150, 185, pxh-20 , 7, 7 ) ;
GfxTextOut( "Buy Order Details" ,25, pxh-145);
GfxTextOut( "BuyPrice" ,5, pxh-120);
GfxTextOut( "Qty/Lot" ,5, pxh-100);
GfxTextOut( "Tgt Price" ,5, pxh-80);
GfxTextOut( "SL Price" ,5, pxh-60);
GfxTextOut( "Current P/L" ,5, pxh-40);
GfxTextOut( ":"+WriteVal(Nz(AvgBuy,0),1.2) ,100, pxh-120);
GfxTextOut( ":"+WriteVal(NumBuy,1.0) ,100, pxh-100);
GfxTextOut( ":"+WriteVal(Nz(BTGTPrice,0),1.2) ,100, pxh-80);
GfxTextOut( ":"+WriteVal(Nz(BSLPrice,0),1.2) ,100, pxh-60);
GfxTextOut( ":"+WriteVal(LongPL,1.0) ,100, pxh-40);
GfxSelectSolidBrush( colorRed );
GfxSelectPen( colorGreen, 1);
GfxRoundRect( 188, pxh-150, 371, pxh-20 , 7, 7 ) ;
GfxTextOut( "Short Order Details" ,210, pxh-145);
GfxTextOut( "ShortPrice" ,190, pxh-120);
GfxTextOut( "Qty/Lot" ,190, pxh-100);
GfxTextOut( "Tgt Price" ,190, pxh-80);
GfxTextOut( "SL Price" ,190, pxh-60);
GfxTextOut( "Current P/L" ,190, pxh-40);
GfxTextOut( ":"+WriteVal(Nz(AvgShort,0),1.2) ,285, pxh-120);
GfxTextOut( ":"+WriteVal(NumShort,1.0) ,285, pxh-100);
GfxTextOut( ":"+WriteVal(Nz(STGTPrice,0),1.2) ,285, pxh-80);
GfxTextOut( ":"+WriteVal(Nz(SSLPrice,0),1.2) ,285, pxh-60);
GfxTextOut( ":"+WriteVal(ShrtPL,1.0) ,285, pxh-40);
}
BSArrow = ParamToggle("Plot Shapes For Buy/Sell ?","Show|Hide",1);
if(BSArrow==1)
{
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-20);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-30);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-25);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30);                      
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorDarkBlue, 0, H, Offset=55);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorBlue, 0,H, Offset=65);                      
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-60);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorDarkBlue, 0, L, Offset=-55);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorBlue, 0,L, Offset=-65);                      
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-60);
}
Alert=Buy OR Short OR Sell OR Cover ;
AlertIf(ALERT,"SOUND C:\\Windows\\Media\\Notify.wav", "Audio alert", 0 );
_SECTION_END();

3 Likes

Hallo Nithin Can We Use Any other Data Feeds With Amibroker For PI Bridge or only Use GFDL For Amibroker Data Feed ?

Hi Choks
I am facing multiple orders problem again, The AFL(your codes for placing order) is working fine, but now i have noticed that the AFL is sending multiple orders “when a signal is generated for more than one chart at a time”. For examble i have two charts open and buy signal is generated in both same time, then the afl is sending multiple orders for this two symbols one by one until the signal bar is closed. As its not happening always, i can still manage, but do u think u can find a solution for this too. Thanks Choks

Thanks Choks. Hats-off to you for your great work.

Hi Sh
Hav U tried the this AFL.?
Do orders fired properly…?
Anything reqd to add to this AFL?

Hi Choks,
I couldnt check it until now, because my Pi bridge is disabled due to some technical reason from zerodha side. I am following up with them, once its activated again, i will check it and update you. Thanks Choks

Hi Choks,
My Pi bridge is enabled again. I was checking the AFL using amibroker barplay, i found the orders are not going to Pi. The ami generated orders are logged into Order file in format folder, that part is ok. In Format folder, Orderlog file is not showing the orders generated in ami. Then i check Pi bridge log file in Pi folder, that also not showing the trades generated. Generated alerts in Pi is not showing any alerts. I checked with the previous afl to see if there is anything wrong with Pi bridge, but found ok, its firing orders to Pi.
Would u please check it Choks

Hi SH,
Orders.txt file in Format Folder is internally used by AFL to prevent Multiple order firing for the Single Signal.whenever u want to check AFL by Bar Replay…then delete the Orders.txt file in format folder and Orderlog.txt file in Formula Folder.
Then Play BarReplay…Once Finished Check the order Log File in Formula Folders, which’ll hav all order details for all signals…Don’t delete Symbols.txt and lotSize.txt. I’m online …If u face any problem Let me Know

Thanks Choks, its working fine. but i couldnt check the multiple order problem, that i will check it tomorrow during the market hours.
Thanks again.

Hi Choks,
I checked the AFL with barplay and found the multiple order problem is resolved. Now even if an order is generated for multiple symbols, it is sending only one order for a symbol to Pi. So the problem is resolved. Its a great work Choks. If i come across any issues, i will let you know. Thanks.

Hi Choks
I have been checking the AFL made by you for Order placing last two days in live market. It is working perfectly, the multiple order problem is completely resolved. The function of the AFL with Pi bridge is very stable, no errors, nothing. Thanks Choks for ur great work.
I am eagerly waiting for the next release of Pi bridge with popup alert to trade with it, until then i have to wait. Hope Nitin will do something about it soon.

hi rajesh… you can use any…

Did you buy amibroker ??