User Input

 

I used the predefined list, but it gave 1 error that says: cannot convert enum

enum MY_TIMEFRAME {
    D1 = PERIOD_D1,
    H4 = PERIOD_H4,
    H1 = PERIOD_H1,
    M15 = PERIOD_M15,
    M5 = PERIOD_M5
};

input MY_TIMEFRAME Timeframe = H4;

int OnInit() {
   datetime time = iTime(_Symbol, Timeframe, 0);
   return(INIT_SUCCEEDED);
   }  

void OnDeinit(const int reason) {}
 
codemq:

I used the predefined list, but it gave 1 error that says: cannot convert enum


    datetime time = iTime(_Symbol, (ENUM_TIMEFRAMES)Timeframe, 0); 
 
Michael Charles Schefe #:


thanks,

 (ENUM_TIMEFRAMES)Timeframe  is written anytime Timeframe is used, can it be defined once instead of writing it multiple times:

   Candle1Open = NormalizeDouble(iOpen(_Symbol, (ENUM_TIMEFRAMES)Timeframe, 1), _Digits);
   Candle1Close = NormalizeDouble(iClose(_Symbol, (ENUM_TIMEFRAMES)Timeframe, 1), _Digits);
   Candle1High = NormalizeDouble(iHigh(_Symbol, (ENUM_TIMEFRAMES)Timeframe, 1), _Digits);
   Candle1Low = NormalizeDouble(iLow(_Symbol, (ENUM_TIMEFRAMES)Timeframe, 1), _Digits);
 
codemq #:

thanks,

 (ENUM_TIMEFRAMES)Timeframe  is written anytime Timeframe is used, can it be defined once instead of writing it multiple times:

below the input line, then, add a new line below that...

input MY_TIMEFRAME Timeframe = H4;
ENUM_TIMEFRAMES tf = (ENUM_TIMEFRAMES)Timeframe;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
    datetime time = iTime(_Symbol, tf, 0); 
 
codemq #:

thanks,

 (ENUM_TIMEFRAMES)Timeframe  is written anytime Timeframe is used, can it be defined once instead of writing it multiple times:

no need to normalise the OHCL as those are already normalised.

 
Michael Charles Schefe #:

no need to normalise the OHCL as those are already normalised.

Thanks