Some questions about Pending orders

 

Hi Guys,

I need some help with pending orders. For open a pending order I´am using Predefined variables open, close, low and high. When conditions are complete OrderSend start opening pending orders. One for every price change until new bar. But I want only one order for one bar, not for every price.

Can you advice me some function or solution?


small example:

enter=Low[1]-(40*Point)-(Close[1]-Low[1]);

OrderSend(Symbol(), OP_SELLLIMIT, 0.01, enter, roz*Point, SL, TP, NULL, 0, 0, CLR_NONE);


Sorry for my english and thank you for your help.

 

But I want only one order for one bar, not for every price.

Use a TimeStamp.

static int TimeStamp;
if(TimeStamp != Time[0]){
  OrderSend(...);
  TimeStamp=Time[0];
}
Something like that.
 
  1. "40*point" is 4 pips on a 5 digit broker. You Must adjust TP, SL, AND slippage
    //++++ These are adjusted for 5 digit brokers.
    int     pips2points;    // slippage  3 pips    3=points    30=points
    double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
    int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
    int     init(){
        if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                    pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
        } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
        // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
    

  2. On ECN brokers, you must open the order and THEN set the TP, SL
  3. Always check error codes so you know WHY
    if (OrderSend(Symbol(), OP_SELLLIMIT, 0.01, enter, roz*Point, SL, TP, NULL, 0, 0, CLR_NONE) < 0)
       Alert("OrderSend failed: ", GetLastError());

  4. What is MarketInfo(Symbol(), MODE_MINLOT)? on a micro account 0.01 may be too small.
  5. enter=Low[1]-(40*Point)-(Close[1]-Low[1]); What is MarketInfo(Symbol(), MODE_STOPLEVEL)*Point? On IBFX it's 30 points 3 pips. You can't set a pending order any close to market than that.
 
ubzen:

But I want only one order for one bar, not for every price.

Use a TimeStamp.

Something like that.

Thank you for respond, I´ll definetely try it.
 
WHRoeder:
  1. "40*point" is 4 pips on a 5 digit broker. You Must adjust TP, SL, AND slippage
  2. On ECN brokers, you must open the order and THEN set the TP, SL
  3. Always check error codes so you know WHY
  4. What is MarketInfo(Symbol(), MODE_MINLOT)? on a micro account 0.01 may be too small.
  5. enter=Low[1]-(40*Point)-(Close[1]-Low[1]); What is MarketInfo(Symbol(), MODE_STOPLEVEL)*Point? On IBFX it's 30 points 3 pips. You can't set a pending order any close to market than that.

If I good understand to your answer You think that I have problem with opening position but opposite is the true.

Only error I get is:


148The amount of open and pending orders has reached the limit set by the broker.
Anyway thank you for answer.