-
for(int i=0; i<10; i++) {
Yes. You are applying future bars to generate earlier ones.
-
Why are you not just reading the indicator?
take candle color hekin ashi - MQL4 and MetaTrader 4 #8-10 or #1 (2018)
-
Yes. You are applying future bars to generate earlier ones.
-
Why are you not just reading the indicator?
take candle color hekin ashi - MQL4 and MetaTrader 4 #8-10 or #1 (2018)
Thank you very much William for your help!
for(int i=10; i>=0; i--) { datetime time = iTime(Symbol(), Period(), i); double HA_Open = (iOpen(Symbol(), Period(), i-1) + iClose(Symbol(), Period(), i-1))/2; double HA_Close = (iOpen(Symbol(), Period(), i) + iHigh(Symbol(), Period(), i) + iLow(Symbol(), Period(), i) + iClose(Symbol(), Period(), i))/4; double HA_High = MathMax(iHigh(Symbol(), Period(), i), MathMax(HA_Open, HA_Close)); double HA_Low = MathMin(iLow(Symbol(), Period(), i), MathMin(HA_Open, HA_Close)); Print("Candle No:", i, ", Time: ", time, ", HA_Open: ", HA_Open, ", HA_Close: ", HA_Close, ", HA_High: ", HA_High, ", HA_Low: ", HA_Low); }
If I make a mistake again, could you please explain it to me. Because the calculation seems easy but somehow I stuck on the logic.
What about check the documentation and see the description of the parameters?
shift
[in] The index of the received value from the timeseries (backward shift by specified number of bars relative to the current bar).

- www.mql5.com

- www.mql5.com
What about check the documentation and see the description of the parameters?
shift
[in] The index of the received value from the timeseries (backward shift by specified number of bars relative to the current bar).
Thank you very much Samuel!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I was trying to find out open, high, close, low prices of a candle with the Heiken Ashi formula. Using a daily chart, heiken ashi close and low prices calculation gives correct results but from open and high prices calculation getting incorrect results. Have I applied the wrong formula? Could someone please help me with what I have missed? Thanks in advance.
Using this formula:
Open of candle: (open of previous bar + close of previous bar) / 2
Close of candle: (open + high + low + close) / 4
High of candle: the maximum value from the high, open, or even close of the current period
Low of candle: the lowest value from the low, open, or close of the current period
Please see the attached files for comparing log and chart prices.