Problem translating timeframes from mql5 to mql4

 

Hi,


I have a problem to translate MQL indicators from MQL5 to MQL4. (https://docs.mql4.com/constants/chartconstants/enum_timeframes)

For the example, I will use iMFI (https://docs.mql4.com/indicators/imfi)


With a simple print, I can see that MQL5 timeframes are not loaded (M2, M20, H2) but MQL4 timeframes are loading correctly (M1, H1).

   Print("m1: "+  DoubleToString( iMFI(_Symbol, PERIOD_M1, 12, 0),2)   + ", " + DoubleToString( iMFI(_Symbol, PERIOD_M1, 12, 1),2) + ", " + DoubleToString( iMFI(_Symbol, PERIOD_M1, 12, 2),2) );

   Print("m2: "+  DoubleToString( iMFI(_Symbol, PERIOD_M2, 12, 0),2)   + ", " + DoubleToString( iMFI(_Symbol, PERIOD_M2, 12, 1),2) + ", " + DoubleToString( iMFI(_Symbol, PERIOD_M2, 12, 2),2) );

   Print("m20: "+ DoubleToString( iMFI(_Symbol, PERIOD_M20, 12, 0),2)  + ", " + DoubleToString( iMFI(_Symbol, PERIOD_M20, 12, 1),2) + ", " +DoubleToString( iMFI(_Symbol, PERIOD_M20, 12, 2),2) );

   Print("h1: "+  DoubleToString( iMFI(_Symbol, PERIOD_H1, 12, 0),2)   + ", " + DoubleToString( iMFI(_Symbol, PERIOD_H1, 12, 1),2) + ", " + DoubleToString( iMFI(_Symbol, PERIOD_H1, 12, 2),2) );

   Print("h2: "+  DoubleToString( iMFI(_Symbol, PERIOD_H2, 12, 0),2)   + ", " + DoubleToString( iMFI(_Symbol, PERIOD_H2, 12, 1),2) + ", " + DoubleToString( iMFI(_Symbol, PERIOD_H2, 12, 2),2) );

  

As you can see below, M2, M20 & H2 stay at 0.



Can somebody explain me why this is not working for the MQL5 timeframes and how to make it work?


Thank you, 

Arthur

iMFI - Technical Indicators - MQL4 Reference
iMFI - Technical Indicators - MQL4 Reference
  • docs.mql4.com
iMFI - Technical Indicators - MQL4 Reference
 
There are no  M2, M20 & H2 timeframes in MT4, so obviously you won't get a value.
 
Keith Watford:
There are no  M2, M20 & H2 timeframes in MT4, so obviously you won't get a value.

Thanks for that answer @Keith Watford. I know that, but in the mql4 doc for enum_timeframes it says: 

Note

The constants of non-standard timeframes are included in the MQL4 language to enable translation and compilation of MQL5 programs, where these timeframes are standard and are included in the ENUM_TIMEFRAMES enumeration.

So it's here to translate from mql5 to mql4 but it can't work?

Chart Timeframes - Chart Constants - Constants, Enumerations and Structures - MQL4 Reference
Chart Timeframes - Chart Constants - Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
All predefined timeframes of charts have unique identifiers. The PERIOD_CURRENT identifier means the current period of a chart, at which a mql4-program is running. The ENUM_TIMEFRAMES enumeration contains the values of standard timeframes, online charts of financial instruments can be...
 

If you know that those timeframes don't exist in MT4 why would you expect them to work in an iMFI() call or anything for that matter?

There is no timeframe data for those timeframes.

 
Keith Watford:

If you know that those timeframes don't exist in MT4 why would you expect them to work in an iMFI() call or anything for that matter?

There is no timeframe data for those timeframes.

I thought it was simple calculations. 

Thanks for the answer

Reason: