take candle color hekin ashi

To add comments, please log in or register
Alessandro Iovine
118
Alessandro Iovine  
Good evening to everyone, I'm desperate. I need to take the color of the candle (heikin ashi), how can I do?
Thank you in advance
William Roeder
20228
William Roeder  
You should encapsulate your iCustom calls to make your code self-documenting.
          Detailed explanation of iCustom - MQL4 and MetaTrader 4 - MQL4 programming forum

#define  PRICE double            // A PRICE
//+------------------------------------------------------------------+
//| Heiken Ashi iCustom function                                     |
//+------------------------------------------------------------------+
enum HAbuffer{ HA_LOW_HIGH, HA_HIGH_LOW, HA_OPEN, HA_CLOSE, HA_BOTTOM, HA_TOP };
PRICE    Heiken_Ashi(HAbuffer buf, INDEX iBar){
   return Heiken_Ashi(_Symbol, ENUM_TIMEFRAMES(_Period), buf, iBar);
}
PRICE    Heiken_Ashi(ENUM_TIMEFRAMES tf, HAbuffer buf, INDEX iBar){
   return Heiken_Ashi(_Symbol, tf, buf, iBar);
}
PRICE    Heiken_Ashi(SYMBOL sym, ENUM_TIMEFRAMES tf, HAbuffer buf, INDEX iBar){
   #define  HA    "Heiken Ashi"
   if(buf < HA_BOTTOM)  return iCustom(sym, tf, HA,
                                       // All four parameters are just colors
                                       buf, iBar);
   PRICE    lh = iCustom(sym, tf, HA, HA_LOW_HIGH, iBar);
   PRICE    hl = iCustom(sym, tf, HA, HA_HIGH_LOW, iBar);
   return HA_BOTTOM == buf ? MathMin(lh, hl) : MathMax(lh, hl);
}

PRICE haOpen  = Heiken_Ashi(HA_OPEN, 1);
PRICE haClose = Heiken_Ashi(HA_CLOSE, 1);
bool  upCandle  = haClose > haOpen;
Alessandro Iovine
118
Alessandro Iovine  

whroeder1:
You should encapsulate your iCustom calls to make your code self-documenting.
          Detailed explanation of iCustom - MQL4 and MetaTrader 4 - MQL4 programming forum


with this code the color of the candle where it is stored?

William Roeder
20228
William Roeder  
There is no color. Only up and down candles.
Alain Verleyen
38701
Alain Verleyen  
Alessandro Iovine:
Please don't answer inside the quote.
Alessandro Iovine
118
Alessandro Iovine  
okok thank you very much. so if I want to open an order when after a red candle there is a green candle, I can not do it?
William Roeder
20228
William Roeder  
There is no red candle or green candle. The colors can be changed to whatever you want. Stop thinking color. Think up or down. You've been answered three times.
Mladen Rakic
160313
Mladen Rakic  
Alessandro Iovine:
okok thank you very much. so if I want to open an order when after a red candle there is a green candle, I can not do it?

HA close > HA open -> "green"

HA close < HA open -> "red"

To add comments, please log in or register