Buy & Sell Signal generation timing mismatch with the broker API


Is there a way to find out in Amibroker, the actual time of Buy & Sell signal generation (in real-time) as I find that there is a delay of almost 1 minute before the buy & sell signal generation symbol appears on the 1-minute chart and the order being placed on the broker API. Currently, the buy and sell orders are appearing on the next candle in the broker API (Dashboard) whereas the buy and sell signal appears on the previous candle in Amibroker Chart.

Any help/suggestion is highly appreciated.

Unfortunately your question isn't clear enough and does not provide all necessary details to give you an answer. Your post is missing: screenshot, formula and other info. Please follow this advice: How to ask a good question

Thank you, Tomasz.

Appreciate your reply.

Sorry for not being clear in my previous question.

I'll try and explain with an example. Hope this makes my question a bit more clear and more precise.

I have attached two Amibroker charts (screenshots) with a tooltip showing the precise time when the LE and LX signals fired.



API Dashboard

The first longEntry was generated at 14:57:00 and the longExit signal was generated at 14:59:00.

However, in the last attachment (API Dashboard screenshot), the longEntry signal received shows a timestamp of 2:58:01 PM (14:58:01) and the longExit signal received shows a timestamp of 3:00:00 PM (15:00:00).

My buy and sell codes are as given below:

_SECTION_BEGIN("DMI Spread Index Trading");

_N(Title = StrFormat("{{NAME}} – {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

StartTime = ParamTime("Start Time", "09:20");
EndTime = ParamTime("End Time", "15:00");
sqOffTime = ParamTime("Square Off Time", "15:10");

Percent=3;RefreshPeriod = Param("Timed Refresh Period", 5, 1, 100, 1);
RequestTimedRefresh(RefreshPeriod, False);

//Initial Parameters

RiskPerShare = 2*ATR(14);          // How much (in percent equity) of entire equity to be risked in a single position.

PositionRisk = 5;

PctSize = PositionRisk * BuyPrice/RiskPerShare;    // Position size calculation

SetTradeDelays( 0,0,0, 0 );
SetOption( "InitialEquity", 100000);
SetOption( "AllowPositionShrinking", True );
SetOption("MaxOpenPositions", 1);
SetPositionSize(PctSize, spsPercentOfEquity);

Pd = Optimize("Period", 4, 1, 20, 1);

HaClose = (O + H + L + C)/4; 
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 ); 
HaHigh = Max( H, Max( HaClose, HaOpen ) ); 
HaLow = Min( L, Min( HaClose, HaOpen ) ); 

barcolor = IIf(HaClose >= HaOpen,colorGreen,colorRed);

PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle );

printf("\nHaOpen : " + HaOpen );  
printf("\nHaHigh : " + HaHigh );  
printf("\nHaLow : " + HaLow );  
printf("\nHaClose : " + HaClose );  

Buy=  PDI(Pd) - MDI(Pd) >= 20 AND ADX(Pd) >= 35   AND TimeNum() > StartTime AND TimeNum() < EndTime;   
Sell= PDI(Pd) - MDI(Pd) < 10                                               OR TimeNum() >= sqOffTime;                                                                                                   
Short= MDI(Pd) - PDI(Pd) >= 15  AND ADX(Pd) >= 25   AND TimeNum() > StartTime AND TimeNum() < EndTime;              
Cover=MDI(Pd) - PDI(Pd) <10                                       OR TimeNum() >= sqOffTime;	

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

printf("\nBuy : " + Buy );  
printf("\nSell : " + Sell );  
printf("\nShort : " + Short );  
printf("\nCover : " + Cover );  


ApplyStop(stopTypeTrailing, stopModePoint, RiskPerShare, True, True);	




As you would see, the longEntry signal received at the API Bridge shows few seconds of delay in receiving this signal when compared with the longEntry signal generation time in the Amibroker chart.

Hence wanted to know if somehow I could figure out if there was an issue with my programming or with the setting of the API Bridge.

Hope I was able to explain the issue.

It depends if you are using scan, or exploration. Exploration is much more versatile.
In the system I am developing, when I generate buy/sell signals I run an exploration which specifically includes a column for now()

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.