Fill 2D array with prices

 

Hello


can not find my error. Have two 2D arrays, one to be filled with the prices of the HLINES and the other with the prices of the RECTANGLE (first loop for the lines, second loop for the rectangles). Within each loop, a function (HasPriceBeenCheckedRectangles and HasPriceBeenCheckedRectangles) looks to see if the prices already exist. I print out the arrays... but somehow it only gives me the prices of the rectangles (top and bottom, which is what I want), but not those of the lines.

double   RectanglePrices[2][1000];
int      RectanglePricesIdx = -1;
double   LinePrices[2][1000];
int      LinesPricesIdx = -1;

int obj_index = ObjectsTotal(0,0,-1);

for (int i = obj_index; i>=0; i--){
    
      string object_name = ObjectName(ChartID(), i);
      double Price_Line_Up = 0;
      double Price_Line_Do = 0;
      
         if (ObjectGetInteger(ChartID(), object_name, OBJPROP_TYPE) != OBJ_HLINE) continue;
               
      if (ObjectGetInteger(ChartID(), object_name, OBJPROP_COLOR)  == clrMaroon )Price_Line_Up = ObjectGetDouble(_Symbol,object_name,OBJPROP_PRICE);
      if (ObjectGetInteger(ChartID(), object_name, OBJPROP_COLOR)  == clrBrown ) Price_Line_Do = ObjectGetDouble(_Symbol,object_name,OBJPROP_PRICE);        
      
      if( !HasPriceBeenCheckedLines(Price_Line_Up, Price_Line_Do) ){
      LinesPricesIdx++;
      LinePrices[0][LinesPricesIdx] = Price_Line_Up;
      LinePrices[1][LinesPricesIdx] = Price_Line_Do;
      Print("Lines");
      ArrayPrint(LinePrices,_Digits,NULL,0,LinesPricesIdx,ARRAYPRINT_INDEX);
      }      
 }
            
for (int i = obj_index; i>=0; i--){
    
      string object_name = ObjectName(ChartID(), i);
      double Price_Rectangle_Up = 0;
      double Price_Rectangle_Do = 0;
            
            if (ObjectGetInteger(ChartID(), object_name, OBJPROP_TYPE) != OBJ_RECTANGLE) continue;
             
      if (ObjectGetInteger(ChartID(), object_name, OBJPROP_COLOR)  == clrRed || ObjectGetInteger(ChartID(), object_name, OBJPROP_COLOR) == clrGreen){     
      Price_Rectangle_Up = ObjectGetDouble(_Symbol,object_name,OBJPROP_PRICE,0);
      Price_Rectangle_Do = ObjectGetDouble(_Symbol,object_name,OBJPROP_PRICE,1); }         
           
         if( !HasPriceBeenCheckedRectangles(Price_Rectangle_Up, Price_Rectangle_Do) ){
         RectanglePricesIdx++;
         RectanglePrices[0][RectanglePricesIdx] = Price_Rectangle_Up;
         RectanglePrices[1][RectanglePricesIdx] = Price_Rectangle_Do;
         Print("Recs");
         ArrayPrint(RectanglePrices,_Digits,NULL,0,RectanglePricesIdx,ARRAYPRINT_INDEX);
         }       
} 

bool HasPriceBeenCheckedRectangles(double rectanglepriceUP, double rectanglepriceDO)
{
   int i;
   for (i=0;i<=RectanglePricesIdx;i++)
   {
      if ( (RectanglePrices[0][i]==rectanglepriceUP)||(RectanglePrices[1][i]==rectanglepriceDO) )
      {
         return true;
      }
   }
   return false;
}

bool HasPriceBeenCheckedLines(double linepriceUP, double linepriceDO)
{
   int i;
   for (i=0;i<=LinesPricesIdx;i++)
   {
      if ( (LinePrices[0][i]==linepriceUP)||(LinePrices[1][i]==linepriceDO) )
      {
         return true;
      }
   }
   return false;
}   
 
Yango: kann meinen Fehler nicht finden. Habe zwei 2D-Arrays, von denen eines mit den Preisen der HLINES und das andere mit den Preisen der RECTANGLE befüllt werden soll (erste Schleife für die Linien, zweite Schleife für die Rechtecke). Jeweils innerhalb der Schleife schaut eine Funktion (HasPriceBeenCheckedRectangles und HasPriceBeenCheckedRectangles), ob die Preise schon vorhanden sind. Lasse mir die Arrays über Print ausgeben.. nur irgendwie gibt er mir immer nur die Preise der Rechtecke (oben und unten aus, was so gewollt ist), aber nicht die, der Linien.
Yango: can't find my mistake. Have two 2D arrays, one to be filled with the prices of the HLINES and the other with the prices of the RECTANGLE (first loop for the lines, second loop for the rectangles). Within each loop, a function (HasPriceBeenCheckedRectangles and HasPriceBeenCheckedRectangles) checks whether the prices are already there. Let me output the arrays via print.. somehow it only gives me the prices of the rectangles (top and bottom, which is what I want), but not those of the lines.

You have posted in the English forum. If you prefer, you can use the German forum.

Forum für Händler - MQL5.community
Forum für Händler - MQL5.community
  • www.mql5.com
MQL5: Forum über Handel, automatische Handelssysteme und Strategietests
 
Fernando Carreiro #:

You have posted in the English forum. If you prefer, you can use the German forum.

thanks for the info. i have updated my post

 
do you have an idea?