Download MetaTrader 5
To add comments, please log in or register
Do you have Linux? Find out how to install MetaTrader on it!
Hatem Abou Ouf
500
Hatem Abou Ouf 2015.06.16 02:30 
double CalculateHH ()// This function is to get the highest high price since open price of certain order
         
       {  for ( int n=OrdersTotal()-1; n>=0; n-- )// first i need to loop all orders
          { 
           if (OrderSelect( n ,SELECT_BY_POS,MODE_TRADES)) // select my order of interest
               {
           if(OrderType()== OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==mBMagicf && n<=1 )
                  { 
                   datetime    OOTs         = OrderOpenTime();          // Assumes OrderSelect() done already
                   int         iOOTs        = iBarShift(NULL,0, OOTs);   // Bar of the open.
                   #define     iBarCURRENTs   0                         // Include current bar.
                   int         nSinceS  = iOOTs - iBarCURRENTs + 1;       // No. bars since open.
                   int         iHi         = iHighest(NULL,0, MODE_HIGH, nSinceS, iBarCURRENTs);
                   double      HH          = High [iHi];                // Highest high.
                   return (HH);// Now i need to return this value but i am not sure where i should put the " return" operator???
                  }
                  
               }
           }
        }
I am getting this error:
Hatem Abou Ouf
500
Hatem Abou Ouf 2015.06.16 02:37  

When i put it in this position to terminate the function and return the double value, i got this down error 

double CalculateHH ()// This function is to get the highest high price since open price of certain order
        
         
       {  for ( int n=OrdersTotal()-1; n>=0; n-- )// first i need to loop all orders
          { 
           if (OrderSelect( n ,SELECT_BY_POS,MODE_TRADES)) // select my order of interest
               {
           if(OrderType()== OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==mBMagicf && n<=1 )
                  { 
                   datetime    OOTs         = OrderOpenTime();          // Assumes OrderSelect() done already
                   int         iOOTs        = iBarShift(NULL,0, OOTs);   // Bar of the open.
                   #define     iBarCURRENTs   0                         // Include current bar.
                   int         nSinceS  = iOOTs - iBarCURRENTs + 1;       // No. bars since open.
                   int         iHi         = iHighest(NULL,0, MODE_HIGH, nSinceS, iBarCURRENTs);
                   double (HH)          = High [iHi];                // Highest high.
                   
                  }
                  
               }
           }
           return (HH);// Now i need to return this value but i am not sure where i should put the " return" operator???
        }
Hatem Abou Ouf
500
Hatem Abou Ouf 2015.06.16 03:28  
Ok, i have just read and understood the idea that a UDF has to return a value and for IF statements, we need to make sure that we return a value even with false IFs.  I got that. 
Hatem Abou Ouf
500
Hatem Abou Ouf 2015.06.16 03:34  
However, when i added another function for getting the lowest low. I got this warning
double CalculateLL ()// This function is to get the highest high price since open price of certain order
        
         
       {  for ( int n=OrdersTotal()-1; n>=0; n-- )// first i need to loop all orders
          { 
           if (OrderSelect( n ,SELECT_BY_POS,MODE_TRADES)) // select my order of interest
               {
           if(OrderType()== OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber()==mBMagicf && n<=1 )
                  { 
                  
                  Comment ("Order selected");
                   datetime    OOTs         = OrderOpenTime();          // Assumes OrderSelect() done already
                   int         iOOTs        = iBarShift(NULL,0, OOTs);   // Bar of the open.
                   #define     iBarCURRENTs   0                         // Include current bar.
                   int         nSinceS  = iOOTs - iBarCURRENTs + 1;       // No. bars since open.
                   int         iLi         = iLowest(NULL,0, MODE_LOW, nSinceS, iBarCURRENTs);
                   double LL          = High [iLi];                // Lowest low.
                  
                   
                   
                  }
                  
               }
           }
          return (LL);
        }
Hatem Abou Ouf
500
Hatem Abou Ouf 2015.06.16 04:02  
I solved this macro redefinition issue. By deleting #define code line in both functions and only post one of them on top of EA code just above extern variables. :)
/
To add comments, please log in or register