Count objects - page 2

 

I'm aware that I'm making the mistake, but I still can't find it.

 
Yango #: I'm aware that I'm making the mistake, but I still can't find it.

Then post your latest code with the corrections that you tried.

 
Fernando Carreiro #:

Posten Sie dann Ihren neuesten Code mit den Korrekturen, die Sie ausprobiert haben.

for (int i = ObjectsTotal(ChartID(),0,-1)-1; i>=0; i--)
{
string objects_lines = ObjectName(ChartID(), i);
doppelter price_green_down_position = 0;
doppelter price_green_up_position = 0;
doppelter price_green_middle_position = 0;
doppelter price_red_down_position = 0;
doppelter price_red_up_position = 0;
doppelter price_red_middle_position = 0;
      if(ObjectGetInteger(0,objects_lines,OBJPROP_COLOR)==clrYellow)    price_green_down_position   = ObjectGetDouble(ChartID(),objects_lines,OBJPROP_PRICE);
      if(ObjectGetInteger(0,objects_lines,OBJPROP_COLOR)==clrBlack)     price_green_middle_position = ObjectGetDouble(ChartID(),objects_lines,OBJPROP_PRICE);
      if(ObjectGetInteger(0,objects_lines,OBJPROP_COLOR)==clrOrangeRed) price_green_up_position     = ObjectGetDouble(ChartID(),objects_lines,OBJPROP_PRICE);
      if(ObjectGetInteger(0,objects_lines,OBJPROP_COLOR)==clrBrown)     price_red_down_position     = ObjectGetDouble(ChartID(),objects_lines,OBJPROP_PRICE);
      if(ObjectGetInteger(0,objects_lines,OBJPROP_COLOR)==clrWhite)     price_red_middle_position   = ObjectGetDouble(ChartID(),objects_lines,OBJPROP_PRICE);
      if(ObjectGetInteger(0,objects_lines,OBJPROP_COLOR)==clrAqua)      price_red_up_position       = ObjectGetDouble(ChartID(),objects_lines,OBJPROP_PRICE);     
if(PositionsTotal()==0 && Verlust == Prozent)
{
         if(ask <= price_green_up_position && ask >= price_green_middle_position && ask >= price_green_down_position) BUYPercent();
         if(bid >= price_red_down_position   && bid <= price_red_middle_position   && bid <= price_red_up_position  ) SELLPercent();
         }

}
 
Yango #: okay, i saw it. I had already tried what you meant with all object types, and that doesn't work either.

And where in your new code do you filter to get only HLines? It is almost always your code.

 
William Roeder #:

Und wo in Ihrem neuen Code filtern Sie, um nur HLines zu erhalten? Es ist fast immer Ihr Code.

I don't really understand what you mean.

 
Yango #:I don't really understand what you mean.
What object type are you processing here? You previously only wanted HLines.
string objects_lines = ObjectName(ChartID(), i);
 
William Roeder #:
What object type are you processing here? You previously only wanted HLines.


that's just the name for the objects in the for loop I just checked again, I think I have a rounding problem if i get the bottom price Subtract (lower HLINE) from the upper price (upper HLINE), divide by 2 and add to the lower (lower HLINE), I get the mean value. the buy positions are opened. and he does it because he gets the right price. he doesn't do it for sell positions because he doesn't round the price. Eur usd





I really don't understand why he's doing this. the lines are set on the chart and each one has its price. he recognizes all prices of the lines, except for the middle one for the short positions here is my code again that sets the lines, i think here is my mistake somewhere

         if(ObjectGetInteger(ChartID(), object_name,OBJPROP_COLOR)==clrRed){
           
            if(!ObjectCreate(_Symbol,low_name_red,OBJ_HLINE,0,0,roundDn(ObjectGetDouble(ChartID(), object_name,OBJPROP_PRICE,1))))PrintFormat("Error object %s not created!",low_name_red);          
            else PrintFormat("object %s created successfully", low_name_red);
            ObjectSetInteger(0,low_name_red,OBJPROP_COLOR,clrBrown);
            
            if(!ObjectCreate(_Symbol,high_name_red ,OBJ_HLINE,0,0,roundDn(ObjectGetDouble(ChartID(), object_name,OBJPROP_PRICE,0))))PrintFormat("Error object %s not created!",high_name_red);
            else PrintFormat("object %s created successfully", high_name_red);
            ObjectSetInteger(0,high_name_red,OBJPROP_COLOR,clrAqua);
            
            double MiddlePriceResistenzOne = roundDn(((ObjectGetDouble(ChartID(), object_name,OBJPROP_PRICE,0) - ObjectGetDouble(ChartID(), object_name,OBJPROP_PRICE,1))/2));
            double MiddlePriceResistenzTwo = roundDn(ObjectGetDouble(ChartID(), object_name,OBJPROP_PRICE,1) + MiddlePriceResistenzOne);
                 
          
                  Print(MiddlePriceResistenzTwo);
                  
            if(!ObjectCreate(_Symbol,middle_of_red ,OBJ_HLINE,0,0,MiddlePriceResistenzTwo))PrintFormat("Error object %s not created!",middle_of_red);
            else PrintFormat("object %s created successfully", middle_of_red);
            ObjectSetInteger(0,middle_of_red,OBJPROP_COLOR,clrWhite);
         }
            if(ObjectGetInteger(ChartID(), object_name,OBJPROP_COLOR)==clrGreen){
           
            if(!ObjectCreate(_Symbol,low_name_green,OBJ_HLINE,0,0,roundDn(ObjectGetDouble(ChartID(), object_name,OBJPROP_PRICE,1))))PrintFormat("Error object %s not created!",low_name_green);          
            else PrintFormat("object %s created successfully", low_name_green);
            ObjectSetInteger(0,low_name_green,OBJPROP_COLOR,clrYellow);
            
            if(!ObjectCreate(_Symbol,high_name_green ,OBJ_HLINE,0,0,roundDn(ObjectGetDouble(ChartID(), object_name,OBJPROP_PRICE,0))))PrintFormat("Error object %s not created!",high_name_green);
            else PrintFormat("object %s created successfully", high_name_green);
            ObjectSetInteger(0,high_name_green,OBJPROP_COLOR,clrOrangeRed);
            
            double MiddlePriceSupport = roundDn((ObjectGetDouble(ChartID(), object_name,OBJPROP_PRICE,0)-(((ObjectGetDouble(ChartID(), object_name,OBJPROP_PRICE,0)-ObjectGetDouble(ChartID(), object_name,OBJPROP_PRICE,1))/2))));
                 Print(MiddlePriceSupport);
            if(!ObjectCreate(_Symbol,middle_of_green ,OBJ_HLINE,0,0,MiddlePriceSupport))PrintFormat("Error object %s not created!",middle_of_green);
            else PrintFormat("object %s created successfully", middle_of_green);
            ObjectSetInteger(0,middle_of_green,OBJPROP_COLOR,clrBlack);
         }
 
Yango #: that's just the name for the objects in the for loop

What type of objects "in the for loop?" Stop going to other things and answer the question!

William Roeder #: What object type are you processing here? You previously only wanted HLines.
 
William Roeder # :

What kind of objects " in the for loop "? Stop going to other things and answer the question!


Yes still. only HLines.. It goes through them in this loop. Add them back, it goes through all the HLines with the for loop, doesn't it? Tell me if I'm wrong

 for ( int i = ObjectsTotal ( ChartID (), 0 , OBJ_HLINE )- 1 ; i>= 0 ; i--){

   string objects_lines = ObjectName ( ChartID (), i);
   
   double price_green_down_position   = 0 ;
   double price_green_up_position     = 0 ; 
   double price_green_middle_position = 0 ;
   
   double price_red_down_position     = 0 ;
   double price_red_up_position       = 0 ; 
   double price_red_middle_position   = 0 ;
    
       if ( ObjectGetInteger ( 0 ,objects_lines, OBJPROP_COLOR )== clrYellow )    price_green_down_position   = ObjectGetDouble ( ChartID (),objects_lines, OBJPROP_PRICE );
       if ( ObjectGetInteger ( 0 ,objects_lines, OBJPROP_COLOR )== clrBlack )     price_green_middle_position = ObjectGetDouble ( ChartID (),objects_lines, OBJPROP_PRICE );
       if ( ObjectGetInteger ( 0 ,objects_lines, OBJPROP_COLOR )== clrOrangeRed ) price_green_up_position     = ObjectGetDouble ( ChartID (),objects_lines, OBJPROP_PRICE );
      
       if ( ObjectGetInteger ( 0 ,objects_lines, OBJPROP_COLOR )== clrBrown )     price_red_down_position     = ObjectGetDouble ( ChartID (),objects_lines, OBJPROP_PRICE );
       if ( ObjectGetInteger ( 0 ,objects_lines, OBJPROP_COLOR )== clrWhite )     price_red_middle_position   = ObjectGetDouble ( ChartID (),objects_lines, OBJPROP_PRICE );
       if ( ObjectGetInteger ( 0 ,objects_lines, OBJPROP_COLOR )== clrAqua )      price_red_up_position       = ObjectGetDouble ( ChartID (),objects_lines, OBJPROP_PRICE ); 
      
      price_red_middle_position =  roundUp(price_red_middle_position);    

       Print ( "Middle" ,roundUp(price_red_middle_position));
      
       if ( PositionsTotal ()== 0 && Loss == Percent){
         if (ask <= price_green_up_position   && ask >= price_green_middle_position && ask >= price_green_down_position) BUYPercent();
         if (bid >= price_red_down_position   && bid <= price_red_middle_position   && bid <= price_red_up_position  )   SELLPercent();
         
         }
         
  
}