OrderOpenPrice() not working for buy low

Back to topics list To post a new topic, please log in or register
avatar
89
chudanever 2015.06.19 11:00
 

please can someone tell me the reason why order      ask < OrderOpenPrice()--------->buy  is not working. i have been using the function for long to open buy low but

suddenly i discovered my ea is no longer opening buy order anymore but open sell very well which i sell high like  bid > OrderOpenPrice()    ------------>sell

i have though that it may be my orderselected. like i did it like this .....

  for(int i=0; i < OrdersTotal(); i++) // Loop through orders
     {
      if(!OrderSelect(i,SELECT_BY_POS, MODE_TRADES))

yet i orderselected to start count from 1 instead of 0 like this.........


 for(int i=1; i < OrdersTotal(); i++) // Loop through orders
     {
      if(!OrderSelect(i,SELECT_BY_POS, MODE_TRADES))
yet is still not working pls any help is appreciated
avatar
Moderator
3206
angevoyageur 2015.06.19 12:08 #
 
Your post is unintelligible. Show your actual code. i should start at 0.
avatar
89
chudanever 2015.06.19 14:00 #
 
angevoyageur:
Your post is unintelligible. Show your actual code. i should start at 0.


 

ok angevoyageur i have got it right while waiting for your reply, i actually did not add ordertype() so thats why it fail


but pls i wonder why is it that i did not add Type==OP_SELL

Type==OP_SELL 

in sell signal and its working fine. WHY i did not add it to its opposite buy and it failed


2 QUESTION .pls below is my orderselect specifically for buy low, did i got it right ? why i ask is check this lines in red to know whether i got the argument right !. i have to put bool argument on my selections like false buy/sell  to prevent my ea FROM  opening buy above ask



     Symb=Symbol();   
                      
   double  OpenPrice=0;       <-----------------
      Ticket =0;               <-----------------  
      lastTradeLots=0;         <-----------------     
   for(int i=0; i < OrdersTotal(); i++) // Loop through orders
     {
      if(OrderSelect(i,SELECT_BY_POS, MODE_TRADES)) // If there is the next one
        {  
        
         if(OrderSymbol()!=Symb)continue;     // Another security
          if( Type == OP_BUY )
         if(OrderMagicNumber()!= magicbuy && OrderMagicNumber()!= msellmagic)continue;
         Total++;                          // Counter of market orders
        if(lastTradeLots > 0 && Ticket > 0 && OpenPrice > 0 )     <--------------------------------------------  prevention from opening above low
         if(Opn_B==false)continue;                                  <--------------------------------------------   if the prevention is right buy is no or false
                           
         Ticket=OrderTicket();                  // Number of selected order
         Type   =OrderType();                    // Type of selected order
         OpenPrice =OrderOpenPrice();               // OPENPrice of selected order     
         lastTradeLots   =OrderLots();                     // Amount of lots
        }
     } 


           Opn_B=Type==OP_BUY && Ask <= OrderOpenPrice())     <--------------------------------------------  worked very well

           Opn_B=Type==OP_BUY && Ask <= OpenPrice )     <--------------------------------------------  failed or no order opened on signal point


why did first raw function worked
OrderOpenPrice() ?

and

why did second linked with function failed 
OrderOpenPrice() ?

Back to topics list  

To add comments, please log in or register