Count objects - page 3

 
Yango #: Yes still. only HLines.. It goes through them in this loop.

No, it does not. It goes through all objects in that loop.

I repeat #15: "And where in your new code do you filter to get only HLines? It is almost always your code."
 

then how about it right? and why does it only return the number of lines via ObjectsTotal(ChartID(),-1,OBJ_HLINE)? You've got me stumped.

 
Yango #: and why does it only return the number of lines via ObjectsTotal(ChartID(),-1,OBJ_HLINE)? You've got me stumped.

That returns the number of HLines, but you select all objects.

 
William Roeder #:

Dadurch wird die Anzahl der HLines zurückgegeben, aber Sie wählen alle Objekte aus.

how do you think the solution is?

 
I checked again.. it was a topic a few times in the forum. but I didn't come to any solution
 
Yango #: how do you think the solution is?
  1. If you get the count of HLines, only select HLines. #4 #9
  2. If you get the count of all objects, select all objects and filter out non-HLines. #15
 
William Roeder #:
  1. If you get the count of HLines, only select HLines. #4 #9
  2. If you get the count of all objects, select all objects and filter out non-HLines. #15

thank you it works

 
Yango #: thank you it works

Don't do that. Someone searching might find this thread and still be clueless. What was the problem? What solved what? Show your fix.

How To Ask Questions The Smart Way. (2004)
     When You Ask.
          Follow up with a brief note on the solution.

 

The problem was that he went BUY but not SELL. This was because he was overwhelmed with the prizes.. I told him go through all the lines and get the prizes (from yellow, brown etc.). Because the for loop iterates through each object one at a time, over and over again, it cannot provide 6 prices at the same time without pausing. So I created 2 for loops, one for BUY and one for SELL orders. Now he has the prices and reacts accordingly in the areas! I also globally initialized the double variables that were previously in the for loop and put in a filter that filters out "non-HLines".

for (int i = ObjectsTotal(0,-1)-1; i>=0; i--){
  
   string objects_lines = ObjectName(ChartID(), i);
    
   color LineColor = color(ObjectGetInteger(0,objects_lines,OBJPROP_COLOR));
   
         if (ObjectGetInteger(ChartID(), objects_lines, OBJPROP_TYPE) != OBJ_HLINE) continue; 

      if(LineColor==clrWhite)     price_red_middle_position   = ObjectGetDouble(ChartID(),objects_lines,OBJPROP_PRICE);
      if(LineColor==clrBrown)     price_red_down_position     = ObjectGetDouble(ChartID(),objects_lines,OBJPROP_PRICE);
      if(LineColor==clrAqua)      price_red_up_position       = ObjectGetDouble(ChartID(),objects_lines,OBJPROP_PRICE);   
      
      if(Loss == Percent){
      if(bid <= price_red_up_position   && bid >= price_red_down_position && bid <= price_red_middle_position) SELLPercent();
      }    

}

for (int x = ObjectsTotal(0,-1)-1; x>=0; x--){
  
   string objects_lines = ObjectName(ChartID(), x);
   
   color LineColor = color(ObjectGetInteger(0,objects_lines,OBJPROP_COLOR));
   
         if (ObjectGetInteger(ChartID(), objects_lines, OBJPROP_TYPE) != OBJ_HLINE) continue; 

      if(LineColor==clrBlack)     price_green_middle_position = ObjectGetDouble(ChartID(),objects_lines,OBJPROP_PRICE);
      if(LineColor==clrOrangeRed) price_green_up_position     = ObjectGetDouble(ChartID(),objects_lines,OBJPROP_PRICE);
      if(LineColor==clrYellow)    price_green_down_position   = ObjectGetDouble(ChartID(),objects_lines,OBJPROP_PRICE);
      
      if(Loss == Percent){
      if(ask <= price_green_up_position   && ask >= price_green_down_position && ask >= price_green_middle_position) BUYPercent();
      }    

}
 

do you know how i can get the price of a specific item that is closest to the current bid/acs rate?

Reason: