Bar 0 is current open bar, on a live chart you get current prices (when EA is started).
With the Strategy Tester, you always start with the first tick of first (current) bar, so all prices are equals.
Alain Verleyen:
Bar 0 is current open bar, on a live chart you get current prices (when EA is started).
With the Strategy Tester, you always start with the first tick of first (current) bar, so all prices are equals.
Thanks for your reply, it does make sense.
However, this leaves me with the question: Ho can I get the actual OHLC values for the first bar I want the EA to start on?
You shouldn't be looking at the chart at all in OnInit. The chart may not be set up; history and market info not updated yet. Look in OnTick/OnCalculate only.

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
It seems as if the values of High[0], Low[0], and Close[0] gets overwritten with the value of Open[0] when running this simple code from within Strategy Tester.
For Instance, take this Init code:
When I run it on the current chart, I get the correct values for all the bars, including the first:
2017.08.29 08:47:52.956 jjj EURUSD,Daily: Bar[1]=1.194270|1.198290|1.191620|1.197800
2017.08.29 08:47:52.956 jjj EURUSD,Daily: Bar[0]=1.197790|1.199330|1.195470|1.199270
On the contrary, when the same expert is run from within Strategy Tester, here's a sample of what I get:
2017.08.29 08:33:04.199 2016.08.01 00:01:00 jjj EURUSD,Daily: Bar[1]=1.107630|1.119720|1.107200|1.117430
2017.08.29 08:33:04.199 2016.08.01 00:01:00 jjj EURUSD,Daily: Bar[0]=1.117150|1.117150|1.117150|1.117150
In this case, the value 1.117150 is the actual Open value of Bar[0], while Bar[1] values are correct.
I just don't understand this behavior. Is there any way around this?
Thanks in advance