I am using PiBridge as a interface between PI and Amibroker. I had written a simple EMA crossover script in AFL and backtested it using AMI, it worked fine. But when I tried to take it ‘Live’ using PI, PiBridge is generating multiple continuous signal every second and sending it to PI. I have placed the AFL script below for your reference. Can you please provide me resolution for the same?
EMA CROSSOVER SCRIPT
FastMALength = 5;
SlowMALength = 13;
FastMA = MA( C, FastMALength );
SlowMA = MA( C, SlowMALength );
Buy = Cross( FastMA, SlowMA );
Sell = Cross( SlowMA, FastMA );
Cover = Buy;
Short = Sell;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Cover = ExRem(Cover,Short);
Short = ExRem(Short,Cover);
RequestTimedRefresh(15, False);
brd=Null;
if(IsNull(brd)) brd = CreateStaticObject(“pibridge.Bridge”);
if(!brd.GetConnectionStatus()) brd.Reconnect();
if (LastValue(Buy)) brd.PlaceOrder(“NFO”, “NIFTY15MAYFUT”, “NIFTY”,“STRATEGY-B”, 1, 1, 1, 0, 0, “MKT”, “NRML”, “RB0799”,“Day”);
if (LastValue(Sell)) brd.PlaceOrder(“NFO”, “NIFTY15MAYFUT”, “NIFTY”,“STRATEGY-S”, 2, 1, 1, 0, 0, “MKT”, “NRML”, “RB0799”,“Day”);