ONCE Add x Seconds delay at Start of Strategy

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
faraz
Posts: 144
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 57 times

ONCE Add x Seconds delay at Start of Strategy

Postby faraz » 10 Jul 2019

Hi,

Only ONCE Add x Seconds delay at Start of Strategy, You need this if you are collecting data from Chart 1 to Chart2 through EL Collection.Dll as if Chart2 is loaded first then Error will be issued by Dll. By adding delay you can keep Chart2 Strategy buzzy for 3 seconds in initial calculation so Chart1 can load properly.

Solution: Only One time X Seconds delay for Strategy calculation in the start of First Bar strategy calculation. To do this, just add below code in the Start of your strategy.

Code: Select all

Input:xSecondsDelay(3); vars: xSecondsDelay1(0),xSecondsDelay2(0),xSecondsDelay3(0); Once ClearPrintLog; Once xSecondsDelay1=CurrentTime_s+xSecondsDelay; Once Print("Started=",CurrentTime_s," ","StopTarget=",xSecondsDelay1); if xSecondsDelay3=0 then begin For xSecondsDelay2=1 to 10000000000000000000 Begin //Print(BarNumber," ",xSecondsDelay2); If CurrentTime_s>xSecondsDelay1 then break; End; xSecondsDelay3=1; Print("Started=",xSecondsDelay1-xSecondsDelay," ","Stopped=",CurrentTime_s); End;

Successful Trading!!!

Thanks

faraz
Posts: 144
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 57 times

Re: ONCE Add x Seconds delay at Start of Strategy

Postby faraz » 21 Aug 2021

Hi,

Improved code to handle delay when time reach close to 60 seconds.

Code: Select all

// Once Add x Seconds Delay //////////////////////////////////////////////////// Vars:xSecondsDelay(3); vars: xSecondsDelay1(0),xSecondsDelay2(0),xSecondsDelay3(0); if xSecondsDelay3=0 then begin Once ClearPrintLog; If CurrentTime_s-(CurrentTime*100)<(60-xSecondsDelay) then begin xSecondsDelay1=CurrentTime_s+xSecondsDelay; end Else begin xSecondsDelay1=CurrentTime_s+(xSecondsDelay+40); Print("xSecondsDelay1 Option2 used"); end; Print("Run Started...... Started=",CurrentTime_s," ","StopTarget=",xSecondsDelay1); For xSecondsDelay2=1 to 10000000000000000000 Begin //Print(BarNumber," ",xSecondsDelay2); If CurrentTime_s>xSecondsDelay1 then break; End; xSecondsDelay3=1; Print("Run Ended...... Stopped=",CurrentTime_s); End; // End Once Add x Seconds Delay ////////////////////////////////////////////////
Successful Trading!!!

Thanks


Return to “User Contributed Studies and Indicator Library”