Commit d1e4cf54 authored by FXcoder's avatar FXcoder

ma wrapper

parent ffee5ceb
......@@ -72,7 +72,7 @@ int OnCalculate(const int rates_total, const int prev_calculated, const datetime
while (i >= 0)
{
dAmount = 0.0;
dMovingAverage = iMA(NULL, 0, ExtStdDevPeriod, 0, ExtStdDevMAMethod, ExtStdDevAppliedPrice, i);
dMovingAverage = MA(NULL, 0, ExtStdDevPeriod, 0, (ENUM_MA_METHOD)ExtStdDevMAMethod, ExtStdDevAppliedPrice, i);
for (j = 0; j < ExtStdDevPeriod; j++)
{
......@@ -159,5 +159,30 @@ void SetIndexDrawBegin(int index, int begin)
#endif
double MA(string symbol, ENUM_TIMEFRAMES timeframe, int ma_period, int ma_shift, ENUM_MA_METHOD ma_method, int applied_price, int shift)
{
#ifdef __MQL4__
return(iMA(symbol, timeframe, ma_period, ma_shift, ma_method, applied_price, shift));
#else
static int ma_handle = INVALID_HANDLE;
if (ma_handle == INVALID_HANDLE)
ma_handle = iMA(symbol, timeframe, ma_period, ma_shift, ma_method, applied_price);
if (ma_handle == INVALID_HANDLE)
return(0);
double values[];
return(CopyBuffer(ma_handle, 0, shift, 1, values) == 1 ? values[0] : 0);
#endif
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment