You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
@deysmacro: I know where the line is which causes the division by zero. It is because I need the daily average range of the last five days. Later in the indicator I divide something by that ATR and as long as the data is not updated ATR is zero and that is the problem. I need to be sure that the daily data of at least the last 5 days is available. Only then the ATR will be >0 and the indicator works.
Put available data into GV and retrieve it. That way, when there is data coming or there is differences in data, just update GV.
Maybe ATR works that way.
People always said "Make it work first, then optimize the code."
Sometimes to make it work, the line of codes are very long but once it is working, you can start to trim the code. :)
Maybe it sounds stupid, but what is GV?
Of course... :-)
Something else I can't explain: The following code is a small modification of my first code I posted. It is also a Moneymanagement indicator but I removed the ATR. It only prints stop loss levels from 5 - 100 pips in 5-pip-steps. So, there is no ATR-calculation at all. When you drag this indicator to your chart it works fine. Every pair, every timeframe. No problems. But when you OPEN the MetaTrader it causes a division by zero error and again only "Label" is printed instead of the stop loss levels.
The error is caused in this line:
I printed ALL variables of this line and I came to the conclusion that AccountBalance() is zero and MarketInfo(Symbol(), MODE_TICKVALUE) is zero. So obviously when you open the MetaTrader, no data at all is available. This never happened in the old MetaTrader. So I have no idea what to do...
Here is the code:
Could you be a little more precise? What exactly is the problem with them (because it always worked..)?
I think there is still the problem that AccountBalance() and other data I need from MetaTrader are not available right after starting the Platform.
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?I printed ALL variables of this line and I came to the conclusion that AccountBalance() is zero and MarketInfo(Symbol(), MODE_TICKVALUE) is zero. So obviously when you open the MetaTrader, no data at all is available. This never happened in the old MetaTrader. So I have no idea what to do...
Here is the code:
If you are sure that this is the cause of the problem, add this just after Start()
Hey GumRai,
I tested it with the indicator above. The AccountBalance stays zero even if I let the MetaTrader run for some minutes. Only until I changed something manually (pair, timeframe) the correct AccountBalance is displayed. And if I use your solution I have no problems with the division by zero error but the indicator will never do its work because AccountBalance stays zero.
I am wondering if I am the only person who has this problem? I think it is a general data-import issue of the new MetaTrader...