too many calculations. I need MT4 to "give me"more time to calculate

 

hi there,

I am not 100% sure, but I think when inside of an EA or Indicator there are too many calculations i.e. too many FOR cycles with double multiplication and division inside them - and it looks like the EA is runing out of time - calculations are not finished and OS or MT$ framework or whatever it is regains controll before EA executes return.

I had this issue first with an EA who was intended to draw a 10x15 table on the screen and I notised that at first it was OK, but when table grew up it stopped working correctly. the work-around was to make calculations one by one i.e. calculate first row, then return, then calculate for next row... till the end. EA has become slower in updating table, but is working now. But now I have the problem with EA who calls an Custom indicator. the CI itself is working fine, but when called with iCustom returns correct results only during the first bar of symulation, then only one of the buffers is correct with the other two become equal to 2147483647. And now the old work-around is helpless because these too many calcualtions are in the custom indicator and I can't divide them...

Did someone had similar problems? or is it possible to "tell" MT4 environment to "give me" more time ?

regards

adinchi

 
Maybe you simply got your iCustom call wrong . . .
 
RaptorUK:
Maybe you simply got your iCustom call wrong . . .


hi Raptor, thank you for reply.

no, the call is fine. I print the return values. they are fine during first bar after EA is tested. an when second bar comes only one of the buffers is OK.

I noticed something else - in more details i have costom ind. with one hystogram and two signal lines. it is fine if it is used as indicator - works in every period and so. the hystogram is calculated first, and two signal lines are kind of the smoothed average of last n points of this hystogram. I wanted to test it with EA and I want to initiate trade in certain conditions depending on these three bufers - hystogram and two signals. I am starting the test in visual mode and in slow speed. after start I add to the Visual window of the instrument this exact custom indicator I call from EA. and I noticed that when I add the indicator it is OK in the history - with hystogram an two signals displayed, but during the test only the hystogram is being displayed. obviousli the two signal lines are not calculated correctly - hence not diplayed and hence not return correct values for the EA. after the test ends the mt4 displays additional window with the indicator and again the hystogram is fine, but two signal lines are prezent only to the point in time where the test starts and then they are missing.

that is all.

regards

adinchi

 

Indicators work in the mql4 GUI thread. They MUST finish quickly.

EA's do not - they can run as long as you want. New ticks are ignored while EA is running.

Whatever you're doing you're doing something wrong. The COG indicator does a non-linear least squares - that's a lot of calculations - no problems. Post your code.

 
WHRoeder:

Indicators work in the mql4 GUI thread. They MUST finish quickly.

EA's do not - they can run as long as you want. New ticks are ignored while EA is running.

Whatever you're doing you're doing something wrong. The COG indicator does a non-linear least squares - that's a lot of calculations - no problems. Post your code.


You are right obviously. I have found the problem in my indicator. funny it did not disturb the indicator, but only when used in an EA. and it looks now to me that it is not a problem with too many calculations. I should also check my previous EA - the one with big table.

so far - so good. It was helpfull to discuss here.

thanks a lot.

adinchi

Reason: