SELLLIMIT & BUYLIMIT Orders - Reopening Issue - page 3

 
Jimdandy:

.. in the meantime here are some functions you can try.

deVries:


With your code you do twice a orderloop while you can do this also with using it one time at most a tick

it is also needed that you count the count of trades of the different OrderType()


Thanks both for your suggestions. I'm going to try those functions, but before doing that, I was wondering maybe inverting the orders place could solve the problem, I mean:

How can I do that? (invert the order "positions").

 

So this is what I have so far. The Expert is working fine, until return above the first open order.

This is an example in BUYLIMIT, with 5 orders in "quantity".

At the start, the expert set the 5 BUYLIMIT orders, that's OK.

The price goes down, the BUYLIMIT orders become BUY orders, and the expert add new BUYLIMIT orders below. That's OK.

Then the price goes up, without adding new BUYLIMIT orders. That's OK.

The problem is when the Price goes above the first BUY order opened, the Expert set another BUYLIMIT order. How can I avoid to open that #10 BUYLIMIT order?. I just want BUYLIMIT orders below the lowest BUY opened order, not above.

This is the code for opening BUYLIMIT orders:

//----Set orders BuyLimit
 if(!ExistPositions(Symbol(),OP_SELLLIMIT,MagicNumber)){
   for(int y =0;y<quantity;y++)
    {
    double levels_s = level_sell-y*steps*Point; 
    if(!ExistOrdersByPrice(Symbol(), OP_BUYLIMIT, MagicNumber, levels_s) && 
       !ExistPosByPrice(Symbol(), OP_BUY, MagicNumber, levels_s) && 
       Bid - levels_s > STOPLEVEL)
    {
    if (StopLoss  >0)  sl=levels_s+StopLoss*Point;   else sl=0;
    if (TakeProfit >0) tp=levels_s-TakeProfit*Point; else tp=0;
    SetOrder(Symbol(), OP_BUYLIMIT, Lots, levels_s, sl, tp, MagicNumber);
    }        
    }
   //----Delete if there is excess of BuyLimit orders
   for(int yd =0;yd<=10;yd++)
    {
    double levels_sd = level_sell-(yd+quantity)*steps*Point; 
    if(ExistOrdersByPrice(Symbol(), OP_BUY, MagicNumber, levels_sd))
    CloseOrderBySelect();       
    }
 }

 
af1:

So this is what I have so far. The Expert is working fine, until return above the first open order.

This is an example in BUYLIMIT, with 5 orders in "quantity".

At the start, the expert set the 5 BUYLIMIT orders, that's OK.

The price goes down, the BUYLIMIT orders become BUY orders, and the expert add new BUYLIMIT orders below. That's OK.

Then the price goes up, without adding new BUYLIMIT orders. That's OK.

The problem is when the Price goes above the first BUY order opened, the Expert set another BUYLIMIT order. How can I avoid to open that #10 BUYLIMIT order?. I just want BUYLIMIT orders below the lowest BUY opened order, not above.

This is the code for opening BUYLIMIT orders:


totally you want to keep having 5 buylimittrades if you had count your EA the number of buylimittrades then you can make a condition if buylimttrades < 5 &&.... other conditions OrderSend your new buylimittrade
Reason: