Download MetaTrader 5

Urgent help needed

To add comments, please log in or register
Deposit to your account via WebMoney
Tonny Obare
29204
Tonny Obare 2011.07.03 12:16 
High i have a mql4 EA that uses the iMA() function to trade using moving averages. In mql5 ive noticed the function misses a key parameter the bar shift which is the last parameter in the mql4 version and i cant figure a way to do this alternatively. Can someone please tell me how to read moving average values for previous bars in mql5? This is very urgent!
Andrei Moraru
1160
Andrei Moraru 2011.07.03 13:39  
tonny:
High i have a mql4 EA that uses the iMA() function to trade using moving averages. In mql5 ive noticed the function misses a key parameter the bar shift which is the last parameter in the mql4 version and i cant figure a way to do this alternatively. Can someone please tell me how to read moving average values for previous bars in mql5? This is very urgent!
In MQL5 you only get an indicator handle using iMA() function. Then you have to copy the actual indicator values from the handle to a buffer using CopyBuffer() function. As a result you'll have an array of indicator values for all the bars you specify in CopyBuffer() function.
Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
  • www.mql5.com
Timeseries and Indicators Access / CopyBuffer - Documentation on MQL5
Robert Simon
44
Robert Simon 2011.07.03 17:38  

Migrating from MQL4 to MQL5 - 17.technical indicators

double iMAMQL4(string symbol,
               int tf,
               int period,
               int ma_shift,
               int method,
               int price,
               int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   ENUM_MA_METHOD ma_method=MethodMigrate(method);
   ENUM_APPLIED_PRICE applied_price=PriceMigrate(price);
   int handle=iMA(symbol,timeframe,period,ma_shift,
                  ma_method,applied_price);
   if(handle<0)
     {
      Print("The iMA object is not created: Error",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,0,shift));
  }


Tonny Obare
29204
Tonny Obare 2011.07.03 20:37  
Lol "high" instead of hi. Thanks guys im gona build it and see, you both gave me a lead.

To add comments, please log in or register