**NO** Delay in trace function

I run same afl on 4 different systems, and I use trace function to display in log window whenever a signal is generated. There are two trace functions that get triggered on every signal, on 3 of my systems both the trace functions execute in same second but on one system there is a delay of more than 1 second for the second trace function. Is there some system setting or amibroker setting that might be causing the delay?

You can refer to the below code

SetChartOptions(0,chartShowArrows | chartShowDates);

_N( Title = (Name()+" - " +Interval(2)+" "+Date()+"  Open " + open + ", High " + high + ",\n Low " + low + ", Close " + close ));
_N( Title = (Title + "  {{VALUES}}"));

Plot( C, "Close", IIf( C < Ref( C, -1 ), colortan, colorseaGreen ), styleCandle | styleNoTitle );

Short = Cover = 0;

sflag = 0;

time  = TimeNum()/100>=0918 AND TimeNum()/100<0919;
time1 = TimeNum()/100>=1529;

se = sx = 0;

stk = 0;

_N(optname1 = "");
_N(optname2 = "");

for(i=1;i<BarCount;i++)
{
	if(time[i] AND !sflag)
	{
		stk   = (floor(o[i]/100)*100);
		optname1 = Name()+NumToStr(stk[i],0.0,False)+"C1";
		optname2 = Name()+NumToStr(stk[i],0.0,False)+"P1";
		se[i] = 1;
		Short[i] = 1;
		sflag = 1;
	}
	
	if(sflag AND time1[i])
	{
		Cover[i] = 1;
		sx[i] = 1;
		sflag = 0;
	}
}

_N(csym = optname1);
_N(psym = optname2);

Checkdt11 = Nz( StaticVarGet( "lastdt11" ) );
dt11 = LastValue( DateTime() );

Checkdt12 = Nz( StaticVarGet( "lastdt12" ) );
dt12 = LastValue( DateTime() );

RTe = LastValue( se ) AND Checkdt11 != dt11;
	
if( RTe )
{
	StaticVarSet( "lastdt11", dt11 );
	
	//CE
	StaticVarSet( "counter", Nz( StaticVarGet( "counter" ) ) + 1 );
	_TRACE( "#" + Nz( StaticVarGet( "counter" ) ) + ",SE," + csym + "," + Date() );
		
	//PE
	StaticVarSet( "counter", Nz( StaticVarGet( "counter" ) ) + 1 );
	_TRACE( "#" + Nz( StaticVarGet( "counter" ) ) + ",SE," + psym + "," + Date() );
}

RTex = LastValue( sx ) AND Checkdt12 != dt12;

if( RTex )
{
	StaticVarSet( "lastdt12", dt12 );
	
	//CE
	StaticVarSet( "counter", Nz( StaticVarGet( "counter" ) ) + 1 );
	_TRACE( "#" + Nz( StaticVarGet( "counter" ) ) + ",SX," + csym + "," + Date() );
	
	//PE
	StaticVarSet( "counter", Nz( StaticVarGet( "counter" ) ) + 1 );
	_TRACE( "#" + Nz( StaticVarGet( "counter" ) ) + ",SX," + psym + "," + Date() );
}

Trace for put option gets delayed by 1-2 seconds on one system.

Thanks in advance.

There is NO DELAY in _TRACE.

_TRACE is immediate - it occurs immediately when code is run.

If you see any "delay" it means that your code was executed "later" than you think.
This can be because you are using 3rd party data source that does not send proper update messages. This can also be because your formula is written wrong and executes too slow.
This can also be because you don't have 0 entered in Tools->Preferences, "Intraday" tab "Real time chart refresh interval" and/or you are not using Professional Edition.

I have shared the code for that very purpose, so that someone can guide if it is wrong.
Two trace functions are executing on same bar, so it can't be because of improper data source, otherwise first trace function would also have incurred delays but that is not the case.
I am using professional edition and have 0 set in the preferences.
And exact same formula with same internet, same data source, same amibroker version and same hardware configuration is working perfectly on all other systems, so there must be some system or amibroker setting that I am missing.

I wrote you: there is NO DELAY in _TRACE function. And no "setting" for any "delay". If you observe "delay" it means that the _TRACE is called later than you think.

It is your responsibility to "know your own code" and debug your own code.

If the problem is limited to ONE machine only, it is a problem with machine, not with formula or AmiBroker.
People usually dismiss idea of hardware problems, but hardware problems are common more common than one would admit. It is not uncommon to have driver issues, SSD stuttering, interrupt latency. The first thing to do is to RESTART your machine and perform rigorous "torture test" on hardware. Google if you don't know what I mean.

Thinking of formatting that machine if nothing else works. But before that could you help me in understanding that can the reason be me using Static variables just before calling the trace function?

Highly unlikely. By the way why don't you use StaticVarAdd ? StaticVarGet/Set pair is not atomic. You should be using StaticVarAdd.

Will give it a try, also formatting the machine helped in removing the delay that was occurring.
Thanks

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