对象获取和对象获取的移位问题 - 页 3

 
Rajakumar1:

非常感谢您的帮助。有什么地方可以先看看吗?Meta编辑器只显示警告。没有错误。


好吧,如果指标在工作/如你所期望的那样画出趋势线,就把注意力放在EA上。

如果没有显示打印语句,那么这些对象就不存在。你是否在运行EA的同时将指标添加到图表中?

如果你看不到图表上的线条,那么EA就不会工作。

 
honest_knave:


好吧,如果指标在工作/如你所期望的那样画出趋势线,就把注意力放在EA上。

如果打印语句没有显示,那么这些对象就不存在。你是否在运行EA的同时将指标添加到图表中?

如果你看不到图表上的线条,那么EA就不会工作。

谢谢你。该指标工作正常。我想知道为什么对象对EA不可见。图表对象 列表中显示了所有的趋势线。
 
Rajakumar1:
谢谢你。该指标工作正常。我想知道为什么对象对EA不可见。图表对象 列表中显示了所有的趋势线。


试着替换掉所有这些。

   int obj_total = ObjectsTotal();
   string name;
   for(int j = 0; j<obj_total; j++)
   {
   name = ObjectName(j);
   Print(j, "Object - ", name);
   
      if(ObjectType(name) == OBJ_TREND && name == "Trendline1-m30")
      {
       price1 = ObjectGetValueByShift(name, 0);
       Print("price1:  ", price1);
      }

      if(ObjectType(name) == OBJ_TREND && name == "Trendline2-m30")
      {
       price2 = ObjectGetValueByShift(name, 0);
       Print("price2:  ", price2);
      }

      if(ObjectType(name) == OBJ_TREND && name == "Trendline3-m30")
      {
       price3 = ObjectGetValueByShift(name, 0);
       Print("price3:  ", price3);
      }

      if(ObjectType(name) == OBJ_TREND && name == "Trendline4-m30")
      {
       price4 = ObjectGetValueByShift(name, 0);
       Print("price4:  ", price4);
      }

      if(ObjectType(name) == OBJ_TREND && name == "Trendline5-m30")
      {
       price5 = ObjectGetValueByShift(name, 0);
       Print("price5:  ", price5);
      }

      if(ObjectType(name) == OBJ_TREND && name == "Trendline6-m30")
      {
      price6 = ObjectGetValueByShift(name, 0);
      Print("price6:  ", price6);
      }

      if(ObjectType(name) == OBJ_TREND && name == "Trendline7-m30")
      {
       price7 = ObjectGetValueByShift(name, 0);
       Print("price7:  ", price7);
      }

      if(ObjectType(name) == OBJ_TREND && name == "Trendline8-m30")
      {
       price8 = ObjectGetValueByShift(name, 0);
       Print("price8:  ", price8);
      }
     }

有了这个。

   string name = "Trendline1-m30";
   if(ObjectFind(0,name)<0) Print("Error: cannot find ", name);
   else price1 = ObjectGetValueByShift(name, 0);

   name = "Trendline2-m30";
   if(ObjectFind(0,name)<0) Print("Error: cannot find ", name);
   else price2 = ObjectGetValueByShift(name, 0);

   name = "Trendline3-m30";
   if(ObjectFind(0,name)<0) Print("Error: cannot find ", name);
   else price3 = ObjectGetValueByShift(name, 0);

   name = "Trendline4-m30";
   if(ObjectFind(0,name)<0) Print("Error: cannot find ", name);
   else price4 = ObjectGetValueByShift(name, 0);
   
   name = "Trendline5-m30";
   if(ObjectFind(0,name)<0) Print("Error: cannot find ", name);
   else price5 = ObjectGetValueByShift(name, 0);
   
   name = "Trendline6-m30";
   if(ObjectFind(0,name)<0) Print("Error: cannot find ", name);
   else price6 = ObjectGetValueByShift(name, 0);   

   name = "Trendline7-m30";
   if(ObjectFind(0,name)<0) Print("Error: cannot find ", name);
   else price7 = ObjectGetValueByShift(name, 0);
   
   name = "Trendline8-m30";
   if(ObjectFind(0,name)<0) Print("Error: cannot find ", name);
   else price8 = ObjectGetValueByShift(name, 0);
 
honest_knave:


试着把这些都替换掉。

用这个。

谢谢。打印功能 没有打印出价格。图表对象列表中显示了所有的趋势线,并且也在图表中。我在第一条趋势线后添加了 "Print("price1: ", price1);"。
 
Rajakumar1:
谢谢。打印功能 没有打印价格。图表对象列表中显示了所有的趋势线,并且也在图表中。我在第一条趋势线后添加了 "Print("price1: ", price1);"。


是的,我提供的代码只在有问题时打印。

你在专家日志中看到任何信息吗?

例如,"错误:找不到趋势线1-m30"?

 
Rajakumar1:
谢谢。打印功能 不能打印价格。图表对象列表中显示了所有的趋势线,并且也在图表中。我在第一条趋势线后添加了 "Print("price1: ", price1);"。

非常感谢。它现在工作了。问题是禁用自动交易。

 
Rajakumar1:

非常感谢。它现在工作了。问题出在禁用的自动交易上。


 
honest_knave:


是的,我提供的代码只在有问题时才打印出来。

你在专家日志中看到任何信息吗?

例如,"错误:找不到趋势线1-m30"?

非常感谢。它现在工作了。问题出在禁用的自动交易上。
 
Rajakumar1: 它现在可以工作了。问题是禁用自动交易。
  1. 你问的问题与禁用自动交易无关。
  2. 检查你的返回代码(OrderSend)并找出原因。什么是函数返回值?我如何使用它们?-MQL4论坛MQL4程序中的常见错误以及如何避免这些错误 - MQL4文章
 
大家好,我想通过double iCustom(Symbol(), 0, jebatfx-breakout-trendline, Price_close, 0, 1)调用指标。

为了在我的EA上获得高位趋势线和下降趋势线。

当价格突破它时,它会进行交易。

我已经得到了我的EA,但我不能得到高点和低点。

自定义指标 中。

你认为我应该用ObjectGetValueByShift()来定义它吗?谢谢你。