[Plz help] New bar detection function in an indicator doesn't work in backtest visual mode
Indicators go through the bars and display things. You shouldn't ever, need isNewBar in an indicator.
Thank you for your reply.
Any replacement for isNewBar? I want to detect the bar of higher level...
2 => REMEMBERS ONLY ONE time value for the last checked time frame
<in the static variable last_time_up>
I wrote other codes to detect current time frame then use it in the function.
The code I posted is just for convenience.
Thanks anyway.
//Current time frame = PERIOD_M5 if(isNewBar_up(PERIOD_M15))
- www.mql5.com
Yes, your brain. Stop thinking about a new bar, and code your loop. No detection is necessary.
The XY Problem
Yes, your brain. Stop thinking about a new bar, and code your loop. No detection is necessary.
The XY Problem
I solved it by directly take value from past bars. Thank you for the sharing.
Hi everyone,
I have a problem as follows.
When I use the function isNewBar_up() to detect a new bar in higher-level chart in a self-made indicator in real time it works well. The functions comes from here: https://www.mql5.com/en/articles/159
However, when I run some backtest in visual mode(model: every tick), the same isNewBar_up() function in the same indicator doesn't work properly. Every time when it's called, the return is always "false" no matter a new higher-level bar comes or not.
Is it any feature in backtest mode that disturbs this function to work in backtest mode?
Thanks very much