I seem to be having a problem. I want to select an order and then when that order is in a certain amount of profit I want to send another order. Below is my code. When it reaches the certain amount in profit it places continuously as it oscillates around the profit point at which I want it to send the order. I just want it to send one order.
if(Hour()==X && Minute()==Y) //Specific time for pending/limit order placement
if (Bars!=ThisBarTrade) //One trade per bar
buyticket=OrderSend(Symbol(),OP_BUYSTOP,Lotsize,PendingPrice,3,Stoploss,TakeProfit,"Buy Stop Order",MagicNumber,0,clrBlue);
if(buyticket>0)Print("Order Send success, Buy Stop Order placed");
if(buyticket<0) Print("Buy Stop Order Send failed, error # ",GetLastError());
sellticket=OrderSend(Symbol(),OP_SELLSTOP,Lotsize,PendingPrice,3,Stoploss,Takeprofit,"Sell stop order",MagicNumber,0,clrRed);
if(sellticket<0) Print("Sell order failed," , GetLastError());
If I create a for() it places 999 orders at that point.
static int sellticket=-1;
if(sellticket<0 && OrderSelect(ticketnumber1,SELECT_BY_TICKET))
You will need to reset sellticket when it is closed
To add comments, please log in or register