Problem with position open !!!

 
                                          


Hi all !

Please Help or advice ! Currently i'm using the code at above to open/close a trade and it working fine.

But problem happen when i trade more than one pair currency ! (Same EA loaded into different pair currency chart).

Thanks in advance.

 

if you run multiple EA's, on multiple currencies/charts and instances, you DEFINITELY NEED MAGIC NUMBER. :-|

 
diostar:

if you run multiple EA's, on multiple currencies/charts and instances, you DEFINITELY NEED MAGIC NUMBER. :-|

It is good practice, but the same EA on multiple pairs does not require a MagicNumber.
 
BugBenny:


But problem happen when i trade more than one pair currency ! (Same EA loaded into different pair currency chart).

What problem ? you need to be more specific about what is or isn't happening.
 
BugBenny:


Sorry ! Forgot to specific my problem. When i loaded the code below to a pair of currency,it work fine and only allow to open a new position when

condition meet.

When i loaded the EA into a second pair of currency/chart, it do nothing !

No position was open when open criteria is meet !


  // Orders accounting 
   Symb=Symbol();                               // Security name   
   datetime lastOP;                                         // Amount of orders   
   for(int i=0; i<OrdersTotal(); i++)          // Loop through orders     
     {
      if (OrderSelect(i,SELECT_BY_POS)==true 
            && OrderSymbol()  ==Symb
            && OrderType()    <=OP_SELL)         // If there is the next one                                                                                                                            // Another security 
       
          Ticket=OrderTicket();                  // Number of selected order         
          Tip   =OrderType();                    // Type of selected order         
          Price =OrderOpenPrice();               // Price of selected order    
          SL    =OrderStopLoss();                // SL of selected order       
          TP    =OrderTakeProfit();              // TP of selected order       
          Lot   =OrderLots();                    // Amount of lots  
          {
           if (OrderOpenTime() > lastOP)
              lastOP=OrderOpenTime();
          }     
     } 
//------------------------------------------------------------------------------------------+ 

   // Check last Open                                           
   datetime lastClose;                                         // Amount of orders   
   for(int pos=0; pos<OrdersHistoryTotal(); pos++)          // Loop through orders     
     {
      if (OrderSelect(pos,SELECT_BY_POS, MODE_HISTORY)
             && OrderCloseTime()  >  lastClose
             && OrderSymbol()     == Symb
             && OrderType()       <= OP_SELL) 
           
                                                                                                            
          lastClose=OrderCloseTime();
          lastOpen=OrderType();
         
     }   
//+---------------------------------------------------------------------------------------+     
   
 
Well the code that you have posted will never open a position . . there is no OrderSend . . .
 
RaptorUK:
Well the code that you have posted will never open a position . . there is no OrderSend . . .


Hi RaptorUK,

Here my OrderSend

 

OK, here is your problem . . .

  // Check last Open                                           
   datetime lastClose;                                         // Amount of orders   
   for(int pos=0; pos<OrdersHistoryTotal(); pos++)          // Loop through orders     
     {
      if (OrderSelect(pos,SELECT_BY_POS, MODE_HISTORY)  //  <----- if this is true . . . 
             && OrderCloseTime()  >  lastClose
             && OrderSymbol()     == Symb
             && OrderType()       <= OP_SELL) 
           
                                                                                                            
          lastClose=OrderCloseTime();                   //  <--- . . . this is executed

          lastOpen=OrderType();                         //  <---  this is executed all the time regardless of  anything in the if statement above
         
     }   

maybe you meant this . . .

// Check last Open                                           
   datetime lastClose;                                         // Amount of orders   
   for(int pos=0; pos<OrdersHistoryTotal(); pos++)          // Loop through orders     
     {
      if (OrderSelect(pos,SELECT_BY_POS, MODE_HISTORY)  //  <----- if this is true . . . 
             && OrderCloseTime()  >  lastClose
             && OrderSymbol()     == Symb
             && OrderType()       <= OP_SELL) 
         {     
         lastClose=OrderCloseTime();                   //  <--- . . . this is executed

         lastOpen=OrderType();                         //  <---  this is executed all the time regardless of  anything in the if statement above
         }
     }  
 
RaptorUK:

OK, here is your problem . . .

maybe you meant this . . .


Hi RaptorUK,

My problem solved ! Thank You Very Much !!!!!!!!!!!!

If can i sincerely wish to buy u a cup of coffee.

Thanks again.....

 
Thanks for the coffee :-)
 
RaptorUK:
diostar:
if you run multiple EA's, on multiple currencies/charts and instances, you DEFINITELY NEED MAGIC NUMBER. :-|
It is good practice, but the same EA on multiple pairs does not require a MagicNumber.
Without a Magic Number, the EA is incompatible with any other including manual trading. It is also incompatable with itself on the same pair but multiple time frames.
Reason: