EA doens't run with open orders

 

Hi all,

I know there's numerous topics around this issue, but none seem to provide a proper answer. So, I was hoping to see if anyone could clarify this for me.

EA, that I have, places one order per symbol if required criteria is met. It also has a trailing SL, portion of the code included below, which seems to be causing problems. I run EA continuously, and tend to use the account to place other various orders either manually or with other EAs. By itself, EA works seemiously, however, whenever there's an open order (Buy or Sell) or Pending orders. The EA won't run.

Now, some topics have suggested to included MagicNumber() function to filter through open orders, however I can't get my head around the fact that if i exclude it wouldn't it just assume as condition has met? Also, buy including MagicNumber function it won't consider any orders that I may have placed manually (as a result won't have MagicNumber) for that symbol which isn't what i want. Am I missing anything?

thanks    


      bool XAU_exists = false;
      for(int i=OrdersTotal()-1; i >= 0; i--)
        {
         if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
           {
            if(OrderSymbol() == Symbol())
              {
               if((OrderType()==OP_BUY)&&(OrderStopLoss()<LTSL))
                 {
                  bool  res = OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(LTSL,Digits),OrderTakeProfit(),0);
                  if(!res) Print("Error in OrderModify. Error code=",GetLastError());
                  else     Print("Order modified successfully.");
                 }
               if((OrderType() ==OP_SELL)&&(OrderStopLoss()>UTSL))
                 {
                  bool  res = OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(UTSL,Digits),OrderTakeProfit(),0);
                  if(!res) Print("Error in OrderModify. Error code=",GetLastError());
                  else     Print("Order modified successfully.");
                 }
               XAU_exists = true;
	     }
	   }	
        }
if(XAU_exists == false)&&(ATR<ATR_Trig)...
 
Dolphh:

Hi all,

I know there's numerous topics around this issue, but none seem to provide a proper answer. So, I was hoping to see if anyone could clarify this for me.

EA, that I have, places one order per symbol if required criteria is met. It also has a trailing SL, portion of the code included below, which seems to be causing problems. I run EA continuously, and tend to use the account to place other various orders either manually or with other EAs. By itself, EA works seemiously, however, whenever there's an open order (Buy or Sell) or Pending orders. The EA won't run.

Now, some topics have suggested to included MagicNumber() function to filter through open orders, however I can't get my head around the fact that if i exclude it wouldn't it just assume as condition has met? Also, buy including MagicNumber function it won't consider any orders that I may have placed manually (as a result won't have MagicNumber) for that symbol which isn't what i want. Am I missing anything?

thanks    


there several way to solve this problem , since your are mix manual and auto trading at the same time thus making your problem more complex . i dont say it cannot be solve   .

Since your dont post the whole code i assume the ea was originally design to open one trade per time hence if you add another trades manually this will cause conflict logic within the ea . If this the case your need to check your open totals order by using loop and filter them using magicnumber and other relevant  input. 

Let say you gonna do manual and auto trade at the same time , my best advise is making your own graphical interfaces such as tradepanel ( where you have buy/sell panel then assign them with unique magic num for manual trade ) to control your trade . Within this control panel your can set to  mix or not to mix trade manually and automatically according to your discretion.

Reason: