Hi,
can someone give me a hint, why I get in visual testing the data that I can see in the indicator graph but in non-visual I get different data (or worse none data).
It is related to the indicator, because some indicators work in both modes and some not. Example: SSL_Channel_Chart works, but Rex not (https://www.mql5.com/en/forum/265346).
Can I somehow workaround that problem for Rex? Or do I call it in a wrong way?
Edit: Just made an observation: When I'm on H1 and I get the data 5 min before end of the candle then everything is fine. I just want to understand that.
Regards
Daniel
EA:
The problem seems to me:
You check the result of CopyBuffer(), and return when the data is not ready yet - so far so good.
But once returned, you never check again if the data is already available, but wait for the next bar.
[EDIT]: So this is not a problem of the indicator. The indicator just hasn't already calculated it's results at the point of time when you've got the tick.
Yes, thats right. After waiting one Tick the indicator seems up-to-date.
Here is how I work-arounded it: (if someone has a better idea, please comment it here)
void OnTick() { //--- datetime newTime = waitForNewBar(); if(newTime != NULL) { // we wait some ticks/mins after new candle open waitTicks = 1; return; // exit } else if(waitTicks > 0) { waitTicks--; // new candle opened if(waitTicks == 0) { if(m_symbol.RefreshRates() && m_symbol.Refresh()) { crossover(); } else { waitTicks++; } } } }
If you wait for the next candle open, you most probably would want to receive the values of candle '1' instead of '0' in the CopyRates(). (No need to wait for next tick)
if(CopyRates(Symbol(), PERIOD_CURRENT, 1, 2, mrate) < 2)
Most probably your indicator needs to be updated every tick to work properly (I didn't check).
Use
#property tester_everytick_calculate
Look at the documentation to understand.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
can someone give me a hint, why I get in visual testing the data that I can see in the indicator graph but in non-visual I get different data (or worse none data).
It is related to the indicator, because some indicators work in both modes and some not. Example: SSL_Channel_Chart works, but Rex not (https://www.mql5.com/en/forum/265346).
Can I somehow workaround that problem for Rex? Or do I call it in a wrong way?
Edit: Just made an observation: When I'm on H1 and I get the data 5 min before end of the candle then everything is fine. I just want to understand that.
Regards
Daniel
EA: