forxtradr1: I print the 8:00 Macd value at 8:00, I get a different value than if I print the 8:00 Macd value at 9:00.
The candle was forming when you printed the value. The close and everything derived from it (MACD) will change every tick. Why does this surprise you?
whroeder1:
Hi whroeder1, I am printing the MACD values as soon as the "NewBar" is formed (the "IsNewBar()" function in my sample code is used for that purpose). In my mind, that means that the old bar is now "complete" and a new bar is starting to form, and the old bar cannot change anymore. You say that "The candle was forming when you printed the value", does it mean my IsNewBar function is not working as described above and I am printing the values "too soon"?
The candle was forming when you printed the value. The close and everything derived from it (MACD) will change every tick. Why does this surprise you?
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
I am struggling to match the MACD H1 values from Strategy Tester Logs from one hour to the next. It seems that when I print the MACD H1 value in the Tester logs for the current hour eg: I print the 8:00 Macd value at 8:00, I get a different value than if I print the 8:00 Macd value at 9:00.
These are the results from the Strategy Tester Logs:
2018.01.03 08:00:00 MacdBuffer[0]:23.851 [1]:24.629 [2]:25.292 [3]:26.252
2018.01.03 09:00:00 MacdBuffer[0]:24.128 [1]:24.485 [2]:24.629 [3]:25.292
2018.01.03 10:00:00 MacdBuffer[0]:21.953 [1]:23.19 [2]:24.485 [3]:24.629
2018.01.03 11:00:00 MacdBuffer[0]:20.588 [1]:21.864 [2]:23.19 [3]:24.485
2018.01.03 12:00:00 MacdBuffer[0]:19.23 [1]:20.508 [2]:21.864 [3]:23.19
As you can see:
At 08:00 MacdVal[0] = 23.851
At 09:00 MacdVal[1] = 24.485 (This should be the same value as 8:00-MacdVal[0], but its not!)
At 10:00 MacdVal[2] = 24.485 (This is the same value as 9:00-MacdVal[1] and it is the same...)
At 11:00 MacdVal[3] = 24.485 (This is the same as 10:00-MacdVal[2] and it is the same...)
So my question is, why does the current MACD values in the current hour seem to differ from the MACD value for the same hour pulled in the subsequent hour.
The code is below: