[MQL5] How to get previous candle data from Heiken Ashi with iCustom

 

I need to get data of candles 0 and candles 1.

I get candle 0:

double HAOpen = iCustom(NULL,0,"Examples\\Heiken_Ashi", 0, 0);

double HAHigh = iCustom(NULL,0,"Examples\\Heiken_Ashi", 1, 0);

double HALow = iCustom(NULL,0,"Examples\\Heiken_Ashi", 2, 0);

double HAClose = iCustom(NULL,0,"Examples\\Heiken_Ashi", 3, 0);

Comment("High: " + (string)HAHigh, " Open: " + (string)HAOpen, " Close: " + (string)HAClose, " Low: " + (string)HALow);

but, my output:

High: 418.0  Open: 420.0  Close: 421.0 Low: 419

Question:

1. How to get previous candle data?

2. Why open prices are always smaller than close prices despite the downtrend?

I need some help

(My picture: Blue is uptrend, Yellow is downtrend in Heiken Ashi indicator )


Thanks,

Kha

Files:
HA_Candles.png  25 kb
 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. double HAOpen = iCustom(NULL,0,"Examples\\Heiken_Ashi", 0, 0);
    double HAHigh = iCustom(NULL,0,"Examples\\Heiken_Ashi", 1, 0);
    double HALow = iCustom(NULL,0,"Examples\\Heiken_Ashi", 2, 0);
    double HAClose = iCustom(NULL,0,"Examples\\Heiken_Ashi", 3, 0); 
    Your title says MT5 and you posted in the Root /MT5 Indicators section. Perhaps you should read the manual. iCustom does not return a double.
 
double HAOpen = iCustom(NULL,0,"Examples\\Heiken_Ashi", 0, 1);

double HAHigh = iCustom(NULL,0,"Examples\\Heiken_Ashi", 1, 1);

double HALow = iCustom(NULL,0,"Examples\\Heiken_Ashi", 2, 1);

double HAClose = iCustom(NULL,0,"Examples\\Heiken_Ashi", 3, 1);


If you need informations from candle 1 (If this code is mt4)

 
William Roeder:
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. Your title says MT5 and you posted in the Root /MT5 Indicators section. Perhaps you should read the manual. iCustom does not return a double.
thanks
 
Shin Joo Young:


If you need informations from candle 1 (If this code is mt4)

thanks, i need mql5 code