Enum for Applied_Price

 
i have encountered this error :  "improper enumerator cannot be used "


my code below , can anyone please help.
enum Applied_Price
{
   Close_Price = 0,
   Price_Open = 1,      
   Price_High=2,         
   Price_Low=3,          
   Price_Median=4,        
   Price_Typical=5,      
   Price_Weight=6 
};

input Applied_Price Appliyer = Price_Open;

void OnTick()
{
RSI      = iRSI(Symbol(),PERIOD_H4,14,Appliyer,0);
}
 
Lim Boon Keng:
enum Applied_Price {    Close_Price = 0,    Price_Open = 1,          Price_High=2,            Price_Low=3,              Price_Median=4,            Price_Typical=5,          Price_Weight=6 }; input Applied_Price Appliyer = Price_Open;

no need for the custom enum. just change the input line to

input ENUM_APPLIED_PRICE Appliyer = PRICE_OPEN;
 
Michael Charles Schefe #:

no need for the custom enum. just change the input line to

Thank you Michael !!

 
Lim Boon Keng #:

Thank you Michael !!

Hi Lim

You may find this useful to work with different types of applied price(s).

enum CENUM_APPLIED_PRICE {
        // MQL ENUM_APPLIED_PRICE values
  price_CLOSE,
  price_OPEN,
  price_HIGH,
  price_LOW,
  price_MEDIAN,
  price_TYPICAL,
  price_WEIGHTED,
  price_AVERAGE,
        // ADDED CUSTOM HEIKEN ASHI PRICE values
  priceHA_CLOSE,
  priceHA_OPEN,
  priceHA_HIGH,
  priceHA_LOW,
  priceHA_MEDIAN,
  priceHA_TYPICAL,
  priceHA_WEIGHTED,
  priceHA_AVERAGE
};
//+-----------------------------------------------------------------------------------------------------------------------------+
//| CLASS:                              CAppliedPrice.mqh
//| APPLICATION:        Library to calculate various types of 'AppliedPrice' including Heiken Ashi candle based prices
//+-----------------------------------------------------------------------------------------------------------------------------+
class CAppliedPrice {

public:

                CAppliedPrice() { }
         ~CAppliedPrice() { }

                double getPrice(CENUM_APPLIED_PRICE pAppliedPrice,const double &open[],const double &close[],const double &high[],
                                                                                const double &low[],int pIDx,int pRatesTotal);
private:
                double aPriceHA[][4];


}; // END Of Class Definition
//+-----------------------------------------------------------------------------------------------------------------------------+
//| METHOD:             getPrice()
//+-----------------------------------------------------------------------------------------------------------------------------+
double CAppliedPrice::getPrice(CENUM_APPLIED_PRICE pAppliedPrice,const double &open[],const double &close[],const double &high[],
                                                                                                                         const double &low[],int pIDx,int pRatesTotal) {

                int      k = pIDx;
        //+---------------------------------------------------------------------------------------------------------------------------+
        //| Calculation of Heiken Ashi candle applied price
        //+---------------------------------------------------------------------------------------------------------------------------+
                if(pAppliedPrice >= priceHA_CLOSE && pAppliedPrice <= priceHA_AVERAGE) {

                        // RESET, IF NEEDED aPriceHA (Two Dimensional Array) ARRAY SIZE
            if(ArrayRange(aPriceHA,0) != pRatesTotal)
                ArrayResize(aPriceHA,pRatesTotal);
        
                        // CALCULATE HAOpen PRICE
                        double HAOpen;
            if(k > 0)                                                                   HAOpen = (aPriceHA[k-1][2] + aPriceHA[k-1][3]) / 2.0;
            else                                                                                                HAOpen = open[k] + close[k];
        
                        // CALCULATE HAClose, HAHigh AND HALow PRICE
            double HAClose = (open[k] + high[k] + low[k] + close[k]) / 4.0;
            double HAHigh  = MathMax(high[k],MathMax(HAOpen,HAClose));
            double HALow   = MathMin(low[k],MathMin(HAOpen,HAClose));
        
                        // SET FINAL HA CANDLE PRICES
            if(HAOpen < HAClose) {
              aPriceHA[k][0] = HALow;
              aPriceHA[k][1] = HAHigh;
            } 
            else {
              aPriceHA[k][0] = HAHigh;
              aPriceHA[k][1] = HALow;
            } 
            aPriceHA[k][2] = HAOpen;
            aPriceHA[k][3] = HAClose;
        
                        switch(pAppliedPrice) {
                          case priceHA_CLOSE:           return(HAClose);
                          case priceHA_OPEN:            return(HAOpen);
                          case priceHA_HIGH:            return(HAHigh);
                          case priceHA_LOW:             return(HALow);
                          case priceHA_MEDIAN:                  return((HAHigh + HALow) / 2.0);
                          case priceHA_TYPICAL:         return((HAHigh + HALow + HAClose) / 3.0);
                          case priceHA_WEIGHTED:        return((HAHigh + HALow + HAClose + HAClose) / 4.0);
                          case priceHA_AVERAGE:         return((HAHigh + HALow + HAClose + HAOpen)  / 4.0);
                        }
                }
        //+---------------------------------------------------------------------------------------------------------------------------+
        //| Calculation of standard candle applied price
        //+---------------------------------------------------------------------------------------------------------------------------+
                else {
                        switch(pAppliedPrice) {
                                case price_CLOSE:                                       return(close[k]);
                                case price_OPEN:                                        return(open[k]);
                                case price_HIGH:                                        return(high[k]);
                                case price_LOW:                                         return(low[k]);
                          case price_MEDIAN:                    return((open[k] + close[k]) / 2.0);
                                case price_TYPICAL:                             return((high[k] + low[k] + close[k]) / 3.0);
                                case price_WEIGHTED:                    return((high[k] + low[k] + close[k] + close[k]) / 4.0);
                        }
                }

                return(0.00);                                           // if none of the Price Type above (warning signal!!! to be provided)

} // End of method getPrice()
//+-----------------------------------------------------------------------------------------------------------------------------+
 
Anil Varma #:

Hi Lim

You may find this useful to work with different types of applied price(s).

sweet!