Small Moneymanagement-Indicator ruined by new MQL4 - page 3

 
mar:

angevoyageur, I think you did not see this posting from me:

mar 2014.04.02 08:16 #

You are right.. I can't avoid it. :-)

"What I meant is, can I wait until the update is completed before going on with the SL-calculation? The problem is that I can't give SL a random value because then the whole indicator is useless. So I would like to check for error 4066 and if it occurs, I would like to wait somehow and check again before going on."

There you can see that described that I can't follow the advice and because I came to that solution you can also see that I definitely checked what qjol advised me.

No you don't, qjol wrote :

so you have to check if one of the variables equals to 0.... in case avoid zero divide

And you report a zero divide error after that. But it's as you wish.

 
mar:

Another example:

If you open the MetaTrader, the result will be zero! And it stays zero until you change the timeframe or pair. I think this is exactly the problem of the division by zero error. Don't you also think?

Did you try this at the weekend, when there were no incoming ticks? That is the only reason that I can think of that the comment wouldn't update.
 
GumRai:

Did you try this at the weekend, when there were no incoming ticks? That is the only reason that I can think of that the comment wouldn't update.

Same here. No tick no update.
 

No, I tried it today. Many ticks come in, no update of AccountBalance. I waited almost one minute but AccountBalance was still zero.


The thing is, that this problem never occurred in the last years. Since the new MetaTrader was rolled-out this problem exists. So I don't think it has anything to do with the code. There must be internal changes within the Platform itself which causes this code to fail. And this indicator is only one Comment-line and it fails. So it must be a Platform/Data-issue.

 
mar:

No, I tried it today. Many ticks come in, no update of AccountBalance. I waited almost one minute but AccountBalance was still zero.


The thing is, that this problem never occurred in the last years. Since the new MetaTrader was rolled-out this problem exists. So I don't think it has anything to do with the code. There must be internal changes within the Platform itself which causes this code to fail. And this indicator is only one Comment-line and it fails. So it must be a Platform/Data-issue.


Are you sure that the indicator is exactly the same as the code that you posted?

Seems like you are checking an indicator that has the one line code in init and not in start

 

i already answered all your question (included the future question regarding this issue) but maybe you didn't read them carefully then let me do it again


qjol:

obviously you can't avoid the update ;-) but you have to avoid a situation of "zero divide"

so you have to check if one of the variables equals to 0.... in case avoid zero divide

and because you can not stop an indicator you have to figure out something


mar:


can I wait until the update is completed before going on with the SL-calculation?

no you cant (already written above)

qjol:
and because you can not stop an indicator you have to figure out something


mar:


The problem is that I can't give SL a random value because then the whole indicator is useless.


i already gave you a solution

SL = MathFloor((iATR(NULL, PERIOD_D1, 7, 0)*MathPow(10,Digits-exp)+1)*0.1);
if (SL == 0) // because error 4066 (for example)
   {
   SL = Someting;
   }
lots=MoneyRisk/SL/(MarketInfo(Symbol(), MODE_TICKVALUE)*multi);


it's random only until update is finished (not more than 2-3 seconds give or take) (IMHO it's better than getting an error message and than indicator will not work at all)

if you have another solution feel free to use it, no need for my permission ;-)


mar:


Switch to whatever timeframe you like, except D1. Then you drag the indicator to your chart. The result will be an error like above. It seems to me that the ATR(5) of the daily chart is not correct because of missing DAILY DATA. Opening a "fresh" chart in the D1 timeframe causes no problems at all. And when you switch to another timeframe then it is also fine because the ATR(5) is correct. I noticed that I can switch to any pair as long as I stay in the D1 chart. But switching to other pairs in other timeframes than D1 causes trouble as long as MetaTrader has not received the daily data. So, my question is now, how can I get the daily data that my ATR-calculation is correct when I open a new chart in a timeframe which is not D1?


because you using iATR .. PERIOD_D1 and again ... you have to wait for the Daily pair to finish the update (2-3 sec. unless you using a dial up connection)

 

qjol, I am sorry for so many misunderstandings! Now I understand that you told me to feed the indicator with some random data only because that the division by zero disappears. I also didn't think about the fact that after a data update the indicator uses the correct value. I am sorry for being stupid... :D

But nevertheless the question is still open: why the hell did it work before? What is wrong with the new MetaTrader?

 
mar:


But nevertheless the question is still open: why the hell did it work before? What is wrong with the new MetaTrader?


not related to old or new MT4 it's related how indicators work and executed
since indicators "can not wait" and has been executed immediately
but, at this time you dont have data for iATR ... PERIOD_D1 so. it's equal to 0
that's why you get zero divide
 
That is absolutely clear to me. But I use this indicator for a pretty long time and I had never data-issues with missing data or things like that. So I wonder why this happened the first time I use the build-625 version of MT4.
 
mar:

No, I tried it today. Many ticks come in, no update of AccountBalance. I waited almost one minute but AccountBalance was still zero.


The thing is, that this problem never occurred in the last years. Since the new MetaTrader was rolled-out this problem exists. So I don't think it has anything to do with the code. There must be internal changes within the Platform itself which causes this code to fail. And this indicator is only one Comment-line and it fails. So it must be a Platform/Data-issue.

Are you sure that the indicator is exactly the same as the code that you posted?

Seems like you are checking an indicator that has the one line code in init and not in start

Reason: