Getting different values of Heiken Ashi candles in Data Window & in my code - page 2

 
kumaillakhani:


Changed the code but still not solved my problem. Review snapshot.


Would you mind explaining what have you changed?

In your log it still shows i==0. Which means CURRENT bar, not yet closed.

 
Andrey Barinov:

Would you mind explaining what have you changed?

In your log it still shows i==0. Which means CURRENT bar, not yet closed.

basically logic is when ever a white candle appear and it close white after some red bars I have to get last highest high value from current white candle till before last white bar appeared in previous and then want to place a pending order. When ever second white candle appear I truncate my loop so no chance of getting 2 white candles in my loop. According to my logic White bar will always be at 0 position.

 

Free to Download for Metatrader 5

There are many Heiken Ashi indicators (and EA) on MT5 CodeBase, for example :

  1. Trading signals module based on Heiken_Ashi_Smoothed indicator
  2. Heiken_Ashi_Smoothed_HTF_Signal
  3. Heiken Ashi Smoothed
  4. Heiken-Ashi

========

========

How To Trade - Heiken Ashi indicator and How Does It Work (adapted from the article)

Heikin-Ashi chart looks like the candlestick chart, but the method of calculation and plotting of the candles on the Heikin-Ashi chart is different from the candlestick chart. In candlestick charts, each candlestick shows four different prices: Open, Close, High and Low price.


But Heikin-Ashi candles are different and each candle is calculated and plotted using some information from the previous candle:

1- Open price: the open price in a Heikin-Ashi candle is the average of the open and close of the previous candle.
2- Close price: the close price in a Heikin-Ashi candle is the average of open, close, high and low prices.
3- High price: the high price in a Heikin-Ashi candle is chosen from one of the high, open and close price of which has the highest value.
4- Low price: the low price in a Heikin-Ashi candle is chosen from one of the low, open and close price of which has the lowest value.

So candles of a Heikin-Ashi chart are related to each other because the open price of each candle should be calculated using the previous candle close and open prices, and also the high and low price of each candle is affected by the previous candle. So a Heikin-Ashi chart is slower than a candlestick chart and its signals are delayed.


The Heikin-Ashi chart is delayed and the candlestick chart is much faster and helps us to make more profit. Why should we use a Heikin-Ashi chart then? As it was already explained, because of the delay that the Heikin-Ashi chart has, it has less number of false signals and prevent us from trading against the market. On the other hand, Heikin-Ashi candles are easier to read because unlike the candlesticks they don’t have too many different patterns.

What Is Heikin-Ashi and How to Trade with It? [With Pictures]
What Is Heikin-Ashi and How to Trade with It? [With Pictures]
  • LuckScout Team
  • www.luckscout.com
On forex or stock market, we can make or lose money when the price goes up and down. We have to become able to understand what party, bulls or bears, have taken the market’s control. Then we can make money by following the dominant party. Different traders do this using different methods. But for most traders, technical analysis of the price...
Reason: