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

 
Tango_X:

谢谢你!我一直认为指代类是指代一个类。但在这里,它只是一个声明......这有什么关系呢?

这些是OOP的基础知识,请看一下帮助。例如,新建/删除操作符 等等。

 
Tango_X:

谢谢你!我一直认为指代类是指代一个类。但在这里,它只是一个声明......这有什么关系呢?

我会研究的,谢谢!!!。

 
Seric29:

你在MT5上用哪种货币交易系统创建符号?

是的,在MT5上

 
fxsaber:

你不能。

这是一种耻辱。

我是在上传到excel后这样做的,但它在那里也有自己的缺点。遗憾的是,没有内置这样的功能。

但我有一种预感,它可以通过某种方式以编程方式实现)

 
ISL:

是的,在MT5上。

很遗憾,MT4不允许你创建符号,你可以改变数值,但不能创建。

 

教我如何摆脱ArraySetAsSeries()!!?

在这里,我重写了MT4已知指标的一部分(完美趋势线),一切都像在MT4中一样工作,但...但我不能强行去掉我写的ArraySetAsSeries()--否则指标就不能正确计算,我知道ArraySetAsSeries()会改变数组中的索引方向,但我自己两天来都没能做到!"。

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_plots   1
//--- plot BufBars
#property indicator_label1  "BufBars"
#property indicator_type1   DRAW_COLOR_BARS
#property indicator_color1  clrRed,clrAqua,clrNONE
#property indicator_style1  STYLE_SOLID
#property indicator_width1  3

//--- input parameters
input int SlowLength         = 7; //Slow length
input int SlowPipDisplace    = 0; //Slow pip displace
input int FastLength         = 3; //Fast length
input int FastPipDisplace    = 0; //Fast pip displace
//--- indicator buffers
double         BufBarsBuffer1[];
double         BufBarsBuffer2[];
double         BufBarsBuffer3[];
double         BufBarsBuffer4[];
double         BufBarsColors[];
double         BufLSELLBuffer[];
double         BufLBUYBuffer[];
static int trend=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,BufBarsBuffer1,INDICATOR_DATA);
   SetIndexBuffer(1,BufBarsBuffer2,INDICATOR_DATA);
   SetIndexBuffer(2,BufBarsBuffer3,INDICATOR_DATA);
   SetIndexBuffer(3,BufBarsBuffer4,INDICATOR_DATA);
   SetIndexBuffer(4,BufBarsColors,INDICATOR_COLOR_INDEX);
   SetIndexBuffer(5,BufLSELLBuffer,INDICATOR_DATA);
   SetIndexBuffer(6,BufLBUYBuffer,INDICATOR_DATA);
   for(int i=0;i<7;i++)
     {
      PlotIndexSetInteger(i,PLOT_DRAW_BEGIN,FastLength+1);
      PlotIndexSetDouble(i,PLOT_EMPTY_VALUE,0.0);
     }
   ArraySetAsSeries(BufBarsBuffer1,true);
   ArraySetAsSeries(BufBarsBuffer2,true);
   ArraySetAsSeries(BufBarsBuffer3,true);
   ArraySetAsSeries(BufBarsBuffer4,true);
   ArraySetAsSeries(BufBarsColors,true);
   ArraySetAsSeries(BufLBUYBuffer,true);
   ArraySetAsSeries(BufLSELLBuffer,true);
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
   trend=0;
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int i,limit;
   double thigh1,tlow1,thigh2,tlow2,trendUp,trendDn;
   ArraySetAsSeries(open,true);
   ArraySetAsSeries(high,true);
   ArraySetAsSeries(low,true);
   ArraySetAsSeries(close,true);
   if(prev_calculated==0)
     {
      limit=rates_total-1;
      BufLSELLBuffer[limit]=high[limit];
      BufLBUYBuffer[limit]=low[limit];
      limit--;
     }
   else limit=rates_total-prev_calculated+1;
   for(i=limit;i>=0;i--)
     {
      thigh1= high[iHighest(NULL,0,MODE_HIGH,SlowLength,i)]+SlowPipDisplace * _Point;
      tlow1 = low[iLowest(NULL,0,MODE_LOW,SlowLength,i)]-SlowPipDisplace * _Point;
      thigh2= high[iHighest(NULL,0,MODE_HIGH,FastLength,i)]+FastPipDisplace * _Point;
      tlow2 = low[iLowest(NULL,0,MODE_LOW,FastLength,i)]-FastPipDisplace * _Point;
      if(close[i]>BufLBUYBuffer[i+1])  trendUp=tlow1;  else trendUp=thigh1;
      if(close[i]>BufLSELLBuffer[i+1]) trendDn=tlow2;  else trendDn=thigh2;
      BufLSELLBuffer[i]= trendDn;
      BufLBUYBuffer[i] = trendUp;
      BufBarsBuffer1[i] = 0.0;
      BufBarsBuffer2[i] = 0.0;
      BufBarsBuffer3[i] = 0.0;
      BufBarsBuffer4[i] = 0.0;
      BufBarsColors[i]  = 2;
      if(close[i]<trendUp && close[i]<trendDn)
        {
         BufBarsBuffer1[i] = open[i];
         BufBarsBuffer2[i] = high[i];
         BufBarsBuffer3[i] = low[i];
         BufBarsBuffer4[i] = close[i];
         BufBarsColors[i]  = 0;
        }
      if(close[i]>trendUp && close[i]>trendDn)
        {
         BufBarsBuffer1[i] = open[i];
         BufBarsBuffer2[i] = high[i];
         BufBarsBuffer3[i] = low[i];
         BufBarsBuffer4[i] = close[i];
         BufBarsColors[i]  = 1;
        }
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Igor Makanu:

教我如何摆脱ArraySetAsSeries()!!?

在这里,我重写了MT4已知指标的一部分(完美趋势线),一切都像在MT4中一样工作,但...我知道ArraySetAsSeries()会改变数组中的索引方向,但两天来我自己都没有处理好这个问题!

我可以做到以下几点

#ifdef __MQL5__
   ArraySetAsSeries(BufBarsBuffer1,true);
   ArraySetAsSeries(BufBarsBuffer2,true);
   ArraySetAsSeries(BufBarsBuffer3,true);
   ArraySetAsSeries(BufBarsBuffer4,true);
   ArraySetAsSeries(BufBarsColors,true);
   ArraySetAsSeries(BufLBUYBuffer,true);
   ArraySetAsSeries(BufLSELLBuffer,true);
#endif
 
Vitaly Muzichenko:

我可以这样做

我知道你可以不用ArraySetAsSeries() 来计算指标值,但我不知道我做错了什么。 我试图在kodobase中找到一个简单的例子,但可惜的是,所有的指标都以不同的方式编写,我无法弄清楚(()

SZY: 我不需要跨平台指标,我想处理默认的数组索引,我已经通过ArrayGetAsSeries()准备了数组 - 我不明白

 
Igor Makanu:

我知道你可以不用ArraySetAsSeries() 来计算指标值,但我不知道我做错了什么。 我试图在kodobase中找到一个简单的例子,唉,所有的指标都是用不同的方式写的,我无法理解(()

你的指标计算 从头到尾(从最近的历史数据到最近的--到当前的)。而这表明如时间序列中的索引。所以数组应该有相应的索引,这就是你的情况。

那么,是什么出了问题?

 
Igor Makanu:

我知道我可以不用ArraySetAsSeries() 来计算指标值,但我不知道我做错了什么。 我试图在kodobase中找到一个简单的例子,但可惜的是,所有的指标都以不同的方式编写,我无法弄清楚((()

SZZ:我不需要跨平台的指标,我想处理默认的数组索引,我已经用过ArrayGetAsSeries()了--我不明白

你可以不用ArraySetAsSeries 来做,只需用PrintComment 来表明,0的数组索引,例如open[0],将被打印出来。从这里你可以做出自己的决定。它将帮助你弄清什么是什么。