if(nLongs > 0) { //First stop move at +15 if(SLMoved == 0 && Bid >= OrderOpenPrice() + 15*k*Point) { OrderModify(nOrderTicket, OrderOpenPrice(), OrderOpenPrice() + k*Point, OrderTakeProfit(), 0, CLR_NONE); SLMoved = 1;
Sorry for the sloppy post, hope you can follow.
Anyway, if nlongs is >0 and price has moved 15 pips, this sets the stop loss of an OP_SELLSTOP that I also have pending to break even and I have no idea why. I hope I described this clearly.
When a pending order's open price has been hit, it is no longer pending, its type is now OP_BUY/OP_SELL
Sorry for the sloppy post, hope you can follow.
Anyway, if nlongs is >0 and price has moved 15 pips, this sets the stop loss of an OP_SELLSTOP that I also have pending to break even and I have no idea why. I hope I described this clearly.
if(nLongs > 0) { //First stop move at +15 if(SLMoved == 0 && Bid >= OrderOpenPrice() + 15*k*Point) { OrderModify(nOrderTicket, OrderOpenPrice(), OrderOpenPrice() + k*Point, OrderTakeProfit(), 0, CLR_NONE); SLMoved = 1;
What trade do you select to modify ???
Are you sure nOrderTicket is the number of the trade to modify ??
What trade do you select to modify ???
Are you sure nOrderTicket is the number of the trade to modify ??
"What trade do you select to modify ???"
There is only 1 open trade at a time. The only open trade is the one to be modified.
The EA worked fine and the SL was moved to break even correctly on the open trade until I changed the OP_BUY and OP_SELL to OP_BUYSTOP and OP_SELLSTOP. The system opens 1 pending OP_BUYSTOP and 1 pending OP_SELLSTOP per day. When one is hit it opens and the other remains pending until the next day when it is deleted. When the open order moves x pips the stop is moved to break even. It worked fine before. But now the stop is moved on the pending order, not the open order.
So you're saying to check the nOrderTicket number and the OrderModify return value? I will try to figure out how to do it with the link you included. Thanks...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have to recognize , in this case, a long trade has been opened when a pending OP_BUYSTOP has been hit. It returns it to a variable nlongs. If nlongs is >0 and the price has moved x pips, the stop loss is moved to break even.