need help for loop issue or something in object detection

 

hello every one.

I am so new so fresh in MQL

I try to learn this language by practicing 


in this case I try to check the chart objects(trend lines) like this:



#property version   "100.002"

#property strict


extern string LongTrendLineDescr  = "LTR";

extern string ShortTrendLineDescr = "STR";


extern color clBuy  = Blue;

extern color clSell = Red;


int OnInit()

  {

   return(INIT_SUCCEEDED);

  }


void OnDeinit(const int reason)

  {

   

  }


void OnTick()

   {

   string obj_name, obj_descr;

   color  obj_color;

   int obj_type;

   int total = ObjectsTotal();  

   for (int i=total-1; i >= 0; i--) 

      {

      obj_name = ObjectName(i);

      obj_type = ObjectType(obj_name);

      if (obj_type != OBJ_TREND) continue;

    

      obj_descr = ObjectDescription(obj_name);

      obj_color = ObjectGet(obj_name,OBJPROP_COLOR);


      if ( (obj_descr == LongTrendLineDescr)  && (obj_color == clBuy)  ) Comment("GO LONG", total);

      if ( (obj_descr == ShortTrendLineDescr) && (obj_color == clSell) ) Comment("GO SHORT", total);

      }

   }

and I expected the (for loop) to check all the objects on the chart and comment "GO LONG" or "GO SHORT" on the each lines that I want. but (for loop) just comment one of the trend lines and nothing more... Please guide me to fix this problem


Files:
Untitled.png  43 kb
 

Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
          General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
          Messages Editor

Reason: