初学者的问题 MQL5 MT5 MetaTrader 5 - 页 1023

 

如何获得iMA指标在 "零条 "上的数据,即获得当前条上的指标值?

如果我这样做

int OnInit()
{handle.MA_CHART=iMA(_Symbol,_Period,period_MA_CHART,0,Signal_MA_Method,Signal_MA_Applied);}

void OnTick()
{CopyBuffer(handle.MA_CHART, 0, 0, 3, ind_date.MA_CHART);}


呼叫时

ind_date.MA_CHART[0]

我得到的是前一栏的数据,而不是当前的数据。

 
Yury Smagin:

如何获得iMA指标在 "零条 "上的数据,即获得当前条上的指标值?

如果我这样做


呼叫时

我得到的是前一栏的数据,而不是当前的数据。

该阵列需要

ArraySetAsSeries(ind_date.MA_CHART,true);

然后数组中索引为 "0 "的元素将对应于图表中的右栏。

 
Vladimir Karputov:

该阵列必须是

然后数组中索引为 "0 "的元素将对应于图表中最右边的柱子。

谢谢你!
 
Yury Smagin:

如何获得iMA指标在 "零条 "上的数据,即获得当前条上的指标值?

如果我这样做


呼叫时

我得到的是前一栏的数据,而不是当前的数据。

就像那部电影中的 "我有一些疑虑......"。你不是用我的专家顾问来学习吗?

你不需要翻转阵列。取数组中第二个索引的值就足够了。

ind_date.MA_CHART[2]
 

OBJPROP_BACK

两种方式都试过了。它不起作用。我完全不明白它是如何运作的。

不管价值如何,这些对象只是按照它们形成的顺序显示--最后一个更高。

还有,如果有两个以上的对象,我如何调整它们的水平(层)?也许有一些其他的设置?如果你知道的话,请告诉我。

 
Alexey Viktorov:

就像那部电影中的 "我有疑虑......"。你用的不是我的顾问吗,你在研究。

你不需要翻转阵列。只要取数组的第二个索引的值就可以了。

谢谢你!

 

祝大家一天好心情))


能否请您告诉我为什么会有不同的结果?

//+------------------------------------------------------------------+
//|  exponential moving average multytimeframes   ДЛЯ БУФЕРА         |
//+------------------------------------------------------------------+
void CalculateExponentialMA(int rates_total,int prev_calculated,int begin,const double &price[])
  {
   int    i,limit;
   double SmoothFactor=2.0/(1.0+period_ma);
//--- first calculation or number of bars was changed
   if(prev_calculated==0)
     {
      limit=period_ma+begin;
      ExtLineBuffer[begin]=price[begin];
   for(i=begin+1;i<limit;i++)
         ExtLineBuffer[i]=price[i]*SmoothFactor+ExtLineBuffer[i-1]*(1.0-SmoothFactor);
     }
   else limit=prev_calculated-1;
//--- main loop
   for(i=limit;i<rates_total && !IsStopped();i++)
      ExtLineBuffer[i]=price[i]*SmoothFactor+ExtLineBuffer[i-1]*(1.0-SmoothFactor);
//---
  }
//+------------------------------------------------------------------+
//|  exponential moving average       ДЛЯ ТОЧКИ                      |
//+------------------------------------------------------------------+
void CalculateEMA(int periodMA,int bgn)
  {
 int i,lmt=periodMA+bgn+1;
 double SmoothFactor=2.0/(1.0+periodMA);
   for(i=0;i<lmt;i++)
              BufferPrice[i]=0.0;
   switch(AppliedPrice)
     {
      case 1: BufferPrice[lmt]=iClose(NULL,Timeframes,lmt); break;
      case 2: BufferPrice[lmt]=iOpen(NULL,Timeframes,lmt);  break;
      case 3: BufferPrice[lmt]=iHigh(NULL,Timeframes,lmt);  break;
      case 4: BufferPrice[lmt]=iLow(NULL,Timeframes,lmt);   break;
   default :  BufferPrice[lmt]=iClose(NULL,Timeframes,lmt); break;
     }
   for(i=lmt-1;i>=0;i--)
   switch(AppliedPrice)
     {
      case 1: BufferPrice[i]=iClose(NULL,Timeframes,i)*SmoothFactor+BufferPrice[i+1]*(1.0-SmoothFactor); break;
      case 2: BufferPrice[i]=iOpen(NULL,Timeframes,i)*SmoothFactor+BufferPrice[i+1]*(1.0-SmoothFactor);  break;
      case 3: BufferPrice[i]=iHigh(NULL,Timeframes,i)*SmoothFactor+BufferPrice[i+1]*(1.0-SmoothFactor);  break;
      case 4: BufferPrice[i]=iLow(NULL,Timeframes,i)*SmoothFactor+BufferPrice[i+1]*(1.0-SmoothFactor);   break;
   default :  BufferPrice[i]=iClose(NULL,Timeframes,i)*SmoothFactor+BufferPrice[i+1]*(1.0-SmoothFactor); break;
     }
      MA=NormalizeDouble(BufferPrice[bgn],_Digits);
  }
//+------------------------------------------------------------------+

问题:我在第二个版本的MA计算中写错了什么?

谢谢你))))。

 
在优化时,图形对象的构造是否可以从图形中读取?
 
Aleksey Vyazmikin:
在优化时,图形对象的构造是否可以从图形中读取?

没有

 
Artyom Trishkin:

没有

糟糕的是...