Flush the plotting queue

Posted By: NorbertSz

Flush the plotting queue - 04/28/22 13:00

Dear all,

I have a script that analyzes an asset. It makes the lookback period, then

Code
if (!is(LOOKBACK)){
	draw some lines on chart
	save the drawing with plotChart()
	quit();
}


(It reads the candles from MT4 connector.)

Picture 1:
I selected an asset, run Trade, and this is the result.

Picture 2:
I did exactly the same again, other result.

Picture 3:
MT4 terminal, the realtime data itself, what I should see on the plotted png (except the last ongoing bar of course)

(For simplicity, I commented my drawing commands, so you not see my lines on the attached pictures.)

So as it looks like for me, Zorro did not finish drawing the candles in the first time, and also did not draw my lines. But in the second run it works flawlessly. However I can also be sure on the correct first run if I put some calculations on the main run() script, or just for example:

Code
int run_counter = 0;
function run(){
	run_counter++;
	printf("run %d", run_counter);
	..............
}


So in this way it writes all the running cycles correctly, and the plotted chart looks perfect.

I guess the main run() function is not waiting for the plotting mechanism, so the script ends sooner than Zorro prints the candles and the other drawings. Do you have any idea how can I enforce flushing the ongoing drawing queue with a command?

Thank you!

Attached picture 1.png
Attached picture 2.png
Attached picture 3.png
Posted By: Petra

Re: Flush the plotting queue - 04/28/22 14:45

That's no 'flush' but a known issue with MT4 servers. If they have insufficient history stored, they sometimes need a long time or a second start for delivering all the data. You will normally get a warning message in such a case when the lookback period is incomplete.

https://zorro-project.com/manual/en/mt4plugin.htm
© 2024 lite-C Forums