Track and control both the total number of open tickets/account and the number of each specific open Order Symbol/Instrument(types?) - page 2

 
WHRoeder:

When you respond, you give the troll power. When you ignore the troll, he starves for attention and eventually dies.

Well as you can see WHRoeder et al(), it is having !no effect on me;
 { 
   Therefore, IpSoFacto I am !not a Troll!;
     {
       Run this through your Logic Compiler and you will see that it does indeed 'compute';
     }
   Keep wogging on anyway WH;
 }
return(TRUE);

// (< 8)
 
Thanks for your help anyway WHRoeder.
 

Took the KISS route:

// Simple MA Cross EA using OCO:


// Global variables

int i_BuyTicketCount  = 0;
int i_SellTicketCount = 0;
  //... continues on....


int start()
 ;
  // Lot Size calculations etc.   ... continues on.......


/////////////////////////////////////////////////////////////////////////////////////////////

  // Start of Close SELL Orders  and  Open BUY Orders   OCO Logic: 

    if(FastMA > SlowMA && BuyTicket == 0)
       // .... continues on .....

     // Close SELL orders:
        bool Closed = OrderClose(SellTicket,CloseLots,ClosePrice,UseSlippage,Red);
        if(Closed == true) 
        && i_SellTicketCount > 0) 
        i_SellTicketCount--;
          // .... continues on

///////////////////////////////

     // Open BUY Orders:
        BuyTicket = OrderSend(Symbol(),OP_BUY,LotSize,Ask,UseSlippage,0,0,s_Comment,i_MagicNumber,0,Green);
        if (BuyTicket != -1) 
        i_BuyTicketCount++;
          // .... continues on.......

///////////////////////////////

      // BUY Order Modification:
          else
            {
              // .... continues on....


/////////////////////////////////////////////////////////////////////////////////////////////

  // Start of Close SELL Tickets  and  Open SELL Orders  OCO Logic: 

    if(FastMA < SlowMA && BuyTicket == 0)
       // .... continues

     // Close BUY Orders:
        bool Closed = OrderClose(BuyTicket,CloseLots,ClosePrice,UseSlippage,Red);
        if(Closed == true && i_BuyTicketCount > 0) 
        i_BuyTicketCount--;
                  
///////////////////////////////

     // Place SELL Orders:                              
        SellTicket = OrderSend(Symbol(),OP_SELL,LotSize,Bid,UseSlippage,0,0,s_Comment,i_MagicNumber,0,Red);
        if (SellTicket != -1) 
        i_SellTicketCount++;
          // Error Handling:   continues on .......
///////////////////////////////

      // SELL Orders Modification:
          else
            {
              // .... continues

Works well except:

1 - Loses track of orders if EA de/reattached, compiled, restarted etc

So going to add in 'Open Order 'loop'' anyway.

In Back Test or Optimization, it only has one order open at a time as it is supposed to.

But in Live trading, it runs amuck and opens new orders ad infinitum )< 8(

2 - Messes up the orders modifications which amongst other things keeps SL set amount behind current price (Immediate TSL)

This is currently rather fragile anyway and doesn't take much, such as ANY alterations to above two Order Close & Open functions within the same broad scope, to mess it up.

This has Money Management (MM), but I've added in more to limit # of open orders with inclusion of Account Equity test which works OK but likewise messes up the Orders Modifications logic

 
FourX:
When you respond, you give the troll power. When you ignore the troll, he starves for attention and eventually dies.
 
WHRoeder:
When you respond, you give the troll power. When you ignore the troll, he starves for attention and eventually dies.
Then stop looking in the mirror at the Troll and IGNORE me then!!!
Reason: