Objectget and objectgetvaluebyshift question - page 3

 
Rajakumar1:

Many thanks for your help. Any area where to look first?. The Meta editor shows only warnings. No errors.


Well, if the indicator is working / drawing the trendlines as you expect, focus on the EA.

If the print statements aren't showing, the objects don't exist. Do you have the indicator added to the chart at the same time you run the EA?

If you can't see the lines on the chart, the EA isn't going to work.

 
honest_knave:


Well, if the indicator is working / drawing the trendlines as you expect, focus on the EA.

If the print statements aren't showing, the objects don't exist. Do you have the indicator added to the chart at the same time you run the EA?

If you can't see the lines on the chart, the EA isn't going to work.

Thank you. The indicator is working fine. I am wondering why objects are not visible to EA. The chart object list shows all the trend lines.
 
Rajakumar1:
Thank you. The indicator is working fine. I am wondering why objects are not visible to EA. The chart object list shows all the trend lines.


Try replacing all of this:

   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);
      }
     }

With this: 

   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:


Try replacing all of this:

With this: 

Thanks. The print function is not printing the price. The chart object list shows all the trend lines and are also in the chart. I added  "Print("price1:  ", price1);" after the first trend line.
 
Rajakumar1:
Thanks. The print function is not printing the price. The chart object list shows all the trend lines and are also in the chart. I added  "Print("price1:  ", price1);" after the first trend line.


Yes, the code I provided only prints if there is a problem.

Do you see any messages in the Experts log?

e.g. "Error: cannot find Trendline1-m30"?

 
Rajakumar1:
Thanks. The print function is not printing the price. The chart object list shows all the trend lines and are also in the chart. I added  "Print("price1:  ", price1);" after the first trend line.

Many thanks. It works now. The problem is with disabled auto trading.

 
Rajakumar1:

Many thanks. It works now. The problem is with disabled auto trading.


 
honest_knave:


Yes, the code I provided only prints if there is a problem.

Do you see any messages in the Experts log?

e.g. "Error: cannot find Trendline1-m30"?

Many thanks. It works now. The problem is with disabled auto trading.
 
Rajakumar1: It works now. The problem is with disabled auto trading.
  1. The problem you asked about has nothing to do with disabled auto trading.
  2. Check your return codes (OrderSend) and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
 
Hello guys, I would like to call the indicator by double iCustom(Symbol(), 0, jebatfx-breakout-trendline, Price_close, 0, 1);

To get the high trendline and the down trendline on my ea.

When the price  break it , it take a trade.

I have ever gotten  my ea but I can't get the high and the low .


Do you think i would use ObjectGetValueByShift() to define it? Thank you 
Reason: