AFL to fire order from Amibroker to Pi on 15 min TF

_SECTION_BEGIN(“315”);
SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ColorRGB(0,0, 0));
GfxSetBkMode(0);
GfxSetOverlayMode(1);
Plot(C,"",colorPink,styleCandle);
SetPositionSize(100,spsShares);
SetTradeDelays(1,1,1,1);

_SECTION_BEGIN(“Triple EMA Crossover Rules”);

Periods1 = Param(“Periods1”, 3, 2, 300, 1, 10 );
Periods2 = Param(“Periods2”, 5, 2, 300, 1, 10 );
Periods3 = Param(“Periods3”, 8, 2, 300, 1, 10 );

Plot( EMA( C, Periods1 ),"", colorOrange,styleLine|styleNoLabel);
Plot( EMA( C, Periods2 ),"", colorBlue,styleLine|styleNoLabel);
Plot( EMA( C, Periods3 ),"", colorGreen,styleLine|styleNoLabel);

Buy =Cover = EMA(C, Periods1) > EMA(C, Periods2) AND EMA(C, Periods2) > EMA(C, Periods3);
Sell =Short= EMA(C, Periods1) < EMA(C, Periods2) AND EMA(C, Periods2) < EMA(C, Periods3);

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

BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);
ShortPrice=ValueWhen(Short,C);
CoverPrice=ValueWhen(Cover,C);

Title = EncodeColor(colorWhite)+ Name() + " - " + EncodeColor(colorWhite)+ Interval(2) + EncodeColor(colorWhite) +

" - " + Date() +" - “+”\n" +EncodeColor(colorWhite) +“Op-”+O+" “+“Hi-”+H+” “+“Lo-”+L+” "+

“Cl-”+C+" “+ “Vol= “+ WriteVal(V)+”\n”+
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at “+C+” “,””)+
WriteIf (Sell , " EXIT LONG / Reverse Signal at “+C+” “,”")+"\n"+EncodeColor(colorYellow)+
WriteIf(Sell , “Profit/Loss Trade Rs.”+(C-BuyPrice)*RoundLotSize+"","")+
WriteIf(Buy , " Profit/Loss Trade Rs."+(SellPrice-C)*RoundLotSize+"","");

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

for(i=BarCount-1;i>1;i–)
{
if(Buy[i] == 1)
{
entry = C[i];
sig = “BUY”;
bars = i;
i = 0;
}
if(Sell[i] == 1)
{
sig = “SELL”;
entry = C[i];
bars = i;
i = 0;
}
}
Offset = 100;
Clr = IIf(sig == “BUY”, colorLime, colorRed);

Plot(LineArray(bars-Offset, entry, BarCount, entry,1), “”, colorYellow, styleLine, Null, Null, Offset);

messageboard = ParamToggle(“Message Board”,“Show|Hide”,1);
if (messageboard == 1 )
{
GfxSelectFont( “Tahoma”, 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( sig ==“BUY”)
{
GfxSelectSolidBrush( colorBlue ); // this is the box background color
Datetim = “” + ValueWhen( Buy, Day(), 1 ) + “/” + ValueWhen( Buy, Month(), 1 ) + “/” + ValueWhen( Buy, Year(), 1 ) + " " + ValueWhen( Buy, Hour(), 1 ) + “:” + ValueWhen( Buy, Minute(), 1 )+ “:” + ValueWhen( Buy, Second(), 1 );
;
}
else
{
GfxSelectSolidBrush( colorRed ); // this is the box background color
Datetim = “” + ValueWhen( Short, Day(), 1 ) + “/” + ValueWhen( Short, Month(), 1 ) + “/” + ValueWhen( Short, Year(), 1 ) + " " + ValueWhen( Short, Hour(), 1 ) + “:” + ValueWhen( Short, Minute(), 1 ) + “:” + ValueWhen( Short, Second(), 1 );
}
pxHeight = Status( “pxchartheight” ) ;
xx = Status( “pxchartwidth”);
Left = 1100;
width = 310;
x = 5;
x2 = 290;

y = pxHeight;

GfxSelectPen( colorGreen, 1); // broader color
GfxRoundRect( x, y -98, x2, y , 17, 7 ) ;
GfxTextOut( Name(),13,y-100);
GfxTextOut( " LTP = “+ C , 135,y- 100 );
GfxTextOut( (” “),27,y-100);
GfxTextOut( ( “Last Signal” ), 13, y - 75 ) ;
GfxTextOut( ( “: " + Datetim ), 113, y - 75 ) ;
GfxTextOut( (”” + WriteIf(sig ==“BUY”,sig + " @ “,sig + " @”) + " : " + entry), 13, y-50);
GfxTextOut( ("Points : " + WriteVal(IIf(sig == “BUY”,(C-entry),(entry-C)),2.2)), 155, y-50);;
GfxTextOut( ("Current P/L : Rs. " + WriteVal(IIf(sig == “BUY”,(C-entry)*RoundLotSize,(entry-C)*RoundLotSize),2.2)), 13, y-25);;

_SECTION_END();
}

YH=TimeFrameGetPrice(“H”,inDaily,-1);
YL=TimeFrameGetPrice(“L”,inDaily,-1);
TO=TimeFrameGetPrice(“O”,inDaily,0);
TH=TimeFrameGetPrice(“H”,inDaily,0);
TL=TimeFrameGetPrice(“L”,inDaily,0);
TC=TimeFrameGetPrice(“C”,inDaily,0);
PC=TimeFrameGetPrice(“C”,inDaily,-1);
RG=(TH-TL); YRG=(YH-YL);
GfxSetTextColor (colorWhite);
GfxSelectFont(“Times New Roman”, 11, 700, True );
GfxTextOut("OPEN : " + Prec(TO,2), 5 , 55);
GfxTextOut("Prv. Cls : " + Prec(PC,2), 115 , 55);
GfxTextOut("PREV. H/L : "+ Prec(YH,2)+ " / "+ Prec(YL,2), 5 , 70);
GfxTextOut("HIGH/LOW : "+ Prec(TH,2)+ " / "+ Prec(TL,2), 5 , 85);
GfxTextOut("RANGE : "+ Prec(RG,2), 215 , 85);
GfxTextOut("RANGE : "+ Prec(YRG,2), 215 , 70);

_SECTION_BEGIN(“Magfied Market Price”);
GfxSelectFont(“Times New Roman”, 18, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(colorBrightGreen);
GfxTextOut(""+C, 1150 , 15 );
YC=TimeFrameGetPrice(“C”,inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont(“Times New Roman”, 11, 700, True );
GfxSetBkMode( colorBlack );

GfxTextOut(""+DD+" ("+xx+"%)", 1150 ,15+25 );

_SECTION_END();

_SECTION_BEGIN(“Time Left”);

function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}

RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;

GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );

if ( NewPeriod )
{GfxSelectSolidBrush( colorYellow );
GfxSelectPen( colorYellow, 2 );
}

//GfxRoundRect( x+45, y+40, x-3, y-2, 0, 0 );
//GfxSetBkMode(1);

GfxSelectFont( “Arial”, 14, 700, False );
GfxSetTextColor( colorBrightGreen );
GfxTextOut( “”+SecsToGo+ " Sec" , 1150, 0 );
_SECTION_END();

Hi Rana…

U can Refer the below link for Order Placement from Amibroker to Pi Bridge…

http://tradingqna.com/12703/amibroker-bridge