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

 
sandex:

声明该数组为静态,大小为1。

编译后出现一行,这与本版和上版相同。以下是整个代码。

#property copyright ""
#property link      ""
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2
#property  indicator_type1   DRAW_LINE
#property  indicator_color1  clrMediumVioletRed
#property  indicator_style1  STYLE_SOLID
#property  indicator_label1  ""
#property  indicator_type2   DRAW_LINE
#property  indicator_color2  clrRed
#property  indicator_style2  STYLE_SOLID
#property  indicator_label2  "Sell TP"
input int Period_ = 34;         //Период
int ma1Handle;
double ma1Val[1];
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {   
SetIndexBuffer(0,ExtMapBuffer1,INDICATOR_DATA);
SetIndexBuffer(1,ExtMapBuffer2,INDICATOR_DATA);
ma1Handle=iMA(_Symbol,_Period,Period_,0,MODE_EMA,PRICE_CLOSE); 
   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[])
  {
ArraySetAsSeries(ma1Val,true);
int bars=Bars(_Symbol,_Period);
for(int i=0;i<bars;i++)
    {
    CopyBuffer(ma1Handle,0,i,1,ma1Val);
    ExtMapBuffer2[i]=ma1Val[0] - ((ma1Val[0]/100)*0.3);//ЗДЕСЬ НЕ ПОЛУЧАЕТСЯ ПОЛУЧИТЬ ЛИНИЮ
    }
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
工作代码。
附加的文件:
Ind.mq5  3 kb
 

你好。

我决定学习MQL5,我读了关于如何在MetaEditor中生成EA的文章,一切都很清楚,但如何使作为EA一部分的指标按照你的规则进行交易,例如CCI指标做出了我不需要的东西,如何使买单在穿越100时打开,在穿越100时从下到上关闭,卖单也是如此。我也一直在研究这个问题,但我不知道如何去做。

 
vitan06:

你好。

我决定学习MQL5,我读了关于如何在MetaEditor中生成EA的文章,一切都很清楚,但如何使作为EA一部分的指标按照你的规则进行交易,例如CCI指标并不符合我的要求;如何使买单在穿越100点时打开,并在穿越100点时从头开始关闭;卖单也是如此。我也一直在研究这个问题,但我不知道如何去做。

我有一个分心的问题,你如何使用MQL4?
 
没办法
 
sandex:
工作代码。
谢谢你!它的作用!!!。
 
vitan06:
没办法

然后安全地忘记代码生成器。

从MA或MACD的交付中打开一个标准的例子

将指标改为CCI

而去

 

你好!

对不起,在我看来,这个问题很愚蠢。

在mql5上写了一个EA,正确加载了它,测试了它,在我家里的笔记本上试了一下演示,现在演示在VPS上运行。

我从我的笔记本上卸载了它。在VPS的源代码上做了一些调整。

试图从VPS加载到笔记本电脑 - 没有看到MQL5!!W7资源管理器有它应该有的位置,但MQL5却没有。

通过打开文件的元编辑器找到、编辑并保存它。

当我试图编译它时,在第一行 出现了不能创建MQL编译器接口的 错误。这个错误是什么?

我应该怎么做

 

能否请教如何在指标代码中获得当前价格,并与另一个指标进行比较来画线?

我在专家顾问中得到了当前的价格。

MqlTick latest_price;       
double iclose=latest_price.bid;
但我如何在指标中得到它呢?
 
forexman77:

能否请教如何在指标代码中获得当前价格,并与另一个指标进行比较来画线?

在EA中,我得到当前的价格,如下所示。

但我如何在指标中得到它呢?
请看指标代码中的OnCalculate()函数。