文章 "如何利用 MQL5 处理指示线"

 

新文章 如何利用 MQL5 处理指示线已发布:

在本文中,您将发现利用 MQL5 处理最重要的指示线(如趋势线、支撑线和阻力线)的方法。

我们可以在交易中应用趋势线,并依据趋势线类型下单。 如果是上升趋势线,我们可能会期望价格向下移动,来从上方测试该趋势线,若反弹到向上,然后我们就可在此趋势线附近放置买入订单。 反之亦然,如果是一条下降趋势线,我们可能期望价格从下方向上移动,来测试该趋势线,若反弹向下,然后我们就可以在此下降趋势线附近放置卖出订单。

以下是上升趋势线:

 向上趋势线

我们可以看到,上图中很明显,我们有一个向上的走势,如果我们尝试在最后三个低点之间连接,我们可以发现它们在同一条上升线上。

作者:Mohamed Abdelmaaboud

 
但为什么 ObjectCreate(_Symbol, "supportLine",OBJ_HLINE,0,pArray[candleLow].time,pArray[candleLow].low, pArray[0].time,pArray[0].low); ?
enough ObjectCreate(_Symbol, "supportLine",OBJ_HLINE,0,pArray[candleLow].time,pArray[candleLow].low);
 
MetaQuotes:

文章"如何使用 MQL5 工具处理线条"已发布:

作者:Mohamed Abdelmaaboud

对于初学者来说,这是一篇有趣的文章,但要正确使用智能交易系统,需要对代码稍作修改。

致 Vladimir。

//+------------------------------------------------------------------+
//|上升趋势线系统。mq5
//+------------------------------------------------------------------+
void OnTick()
  {
   int candles = (int)ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0);
   double pLow[];
   ArraySetAsSeries(pLow,true);
   int copy_low = CopyLow(_Symbol,_Period,0,candles,pLow);
   if(copy_low>0)
     {
      int candleLow = ArrayMinimum(pLow,0,candles);
      MqlRates pArray[];
      ArraySetAsSeries(pArray,true);
      int Data = CopyRates(_Symbol,_Period,0,candles,pArray);
      ObjectDelete(0,"UpwardTrendline");
      ObjectCreate(0,"UpwardTrendline",OBJ_TREND,0,pArray[candleLow].time,pArray[candleLow].low,
                   pArray[0].time,pArray[0].low);
      ObjectSetInteger(0,"UpwardTrendline",OBJPROP_COLOR,Blue);
      ObjectSetInteger(0,"UpwardTrendline",OBJPROP_STYLE,STYLE_SOLID);
      ObjectSetInteger(0,"UpwardTrendline",OBJPROP_WIDTH,3);
      ObjectSetInteger(0,"UpwardTrendline",OBJPROP_RAY_RIGHT,true);
     }
  }
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//|向下趋势线系统。mq5
//+------------------------------------------------------------------+
void OnTick()
  {
   int candles = (int)ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0);
   double pHigh[];
   ArraySetAsSeries(pHigh,true);
   int copy_high = CopyHigh(_Symbol,_Period,0,candles,pHigh);
   if(copy_high>0)
     {
      int candleHigh = ArrayMaximum(pHigh,0,candles);
      MqlRates pArray[];
      ArraySetAsSeries(pArray,true);
      int Data = CopyRates(_Symbol,_Period,0,candles,pArray);
      ObjectDelete(0,"DnwardTrendline");
      ObjectCreate(0,"DnwardTrendline",OBJ_TREND,0,pArray[candleHigh].time,pArray[candleHigh].high,
                   pArray[0].time,pArray[0].high);
      ObjectSetInteger(0,"DnwardTrendline",OBJPROP_COLOR,Blue);
      ObjectSetInteger(0,"DnwardTrendline",OBJPROP_STYLE,STYLE_SOLID);
      ObjectSetInteger(0,"DnwardTrendline",OBJPROP_WIDTH,3);
      ObjectSetInteger(0,"DnwardTrendline",OBJPROP_RAY_RIGHT,true);
     }
  }
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//|支持线路系统。mq5
//+------------------------------------------------------------------+
void OnTick()
  {
   int candles = (int)ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0);
   double pLow[];
   ArraySetAsSeries(pLow,true);
   int copy_low = CopyLow(_Symbol,_Period,0,candles,pLow);
   if(copy_low>0)
     {
      int candleLow = ArrayMinimum(pLow,0,candles);
      MqlRates pArray[];
      ArraySetAsSeries(pArray,true);
      int Data = CopyRates(_Symbol,_Period,0,candles,pArray);
      ObjectDelete(0,"supportLine");
      ObjectCreate(0,"supportLine",OBJ_HLINE,0,pArray[candleLow].time,pArray[candleLow].low,
                   pArray[0].time,pArray[0].low);
      ObjectSetInteger(0,"supportLine",OBJPROP_COLOR,Green);
      ObjectSetInteger(0,"supportLine",OBJPROP_STYLE,STYLE_SOLID);
      ObjectSetInteger(0,"supportLine",OBJPROP_WIDTH,3);
      ObjectSetInteger(0,"supportLine",OBJPROP_RAY,true);
     }
  }
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//|阻力线系统。mq5 ||
//+------------------------------------------------------------------+
void OnTick()
  {
   int candles=(int)ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0);
   double pHigh[];
   ArraySetAsSeries(pHigh,true);
   int copy_high = CopyHigh(_Symbol,_Period,0,candles,pHigh);
   if(copy_high>0)
     {
      int candleHigh = ArrayMaximum(pHigh,0,candles);
      MqlRates pArray[];
      ArraySetAsSeries(pArray,true);
      int Data = CopyRates(_Symbol,_Period,0,candles,pArray);
      ObjectDelete(0,"resistanceLine");
      ObjectCreate(0,"resistanceLine",OBJ_HLINE,0,pArray[candleHigh].time,pArray[candleHigh].high,
                   pArray[0].time,pArray[0].high);
      ObjectSetInteger(0,"resistanceLine",OBJPROP_COLOR,Red);
      ObjectSetInteger(0,"resistanceLine",OBJPROP_STYLE,STYLE_SOLID);
      ObjectSetInteger(0,"resistanceLine",OBJPROP_WIDTH,3);
      ObjectSetInteger(0,"DnwardTrendline",OBJPROP_RAY_RIGHT,true);
     }
  }
//+------------------------------------------------------------------+
 
MrBrooklin #:

对于初学者来说,这篇文章很有意思,但要使 EA 正常工作,需要对代码稍作调整。

弗拉基米尔




感谢您的友好评论,我会进行审核的。
 
你画趋势线的方法非常好。关于趋势线,我有一个看法:如果第二个锚点总是 0 指数条形图,那就没什么用了,因为每出现一个新的条形图,趋势线就会更新一次,这样趋势线就没有用了。理想的做法是根据特定标准定义第二个锚点。例如,价格最高的第二个柱形图,与第一个柱形图的最小距离为 30 个柱形图,或者取第二天价格最高的柱形图,以此类推。

祝贺您的文章。
 
Andrei Pereira 趋势线,我有一个看法:如果第二个锚点总是 0 指数条形图,那就没什么用了,因为每出现一个新的条形图,趋势线就会更新一次,这样趋势线就没有用了。理想的做法是根据特定标准定义第二个锚点。例如,价格最高的第二个柱形,距离第一个柱形至少 30 个柱形,或者取第二天价格最高的柱形,以此类推。 祝贺您的文章。

感谢您的评论,这是一个很好的意见。

 
Mohamed Abdelmaaboud #:
谢谢您的评论,我会修改的。

已经过去快 10 个月了,文章作者没有对他的代码进行任何修改。))

再见,弗拉基米尔。

 
MrBrooklin #:

将近 10 个月过去了,文章作者的代码没有任何变化。))

问候,弗拉基米尔。

感谢您的提醒和贡献。我们将把它送交编辑。