Hi all
I would like to delete a pending order after 10 pips, that's if the buy order is in profit after 10 pips. With the code below it will delete sell stop all the time. I know you can delete by time function after a few minutes, hours & days etc. I would like to know is it possible to delete after certain amount of pips?
If so please help
using
OrderOpenTime()
It still deletes everything like OrderOpenPrice().
double Pips=0; double Ticksize=MarketInfo(Symbol(),MODE_TICKSIZE); if(Ticksize==0.00001||Ticksize==0.001) Pips=Ticksize*10; else Pips=Ticksize; for(int Loop3=OrdersTotal()-1;Loop3>=0;Loop3--) { if(OrderSelect(Loop3,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber) { if(OrderType()==OP_BUYSTOP) { if(OrderOpenTime()<=Ask-10*Pips) { bool Delete=OrderDelete(OrderTicket(),clrHotPink); } } else if(OrderType()==OP_SELLSTOP) { if(OrderOpenTime()>=Bid-10*Pips) { bool Delete=OrderDelete(OrderTicket(),clrHotPink); } } }
-
else if(OrderType()==OP_SELLSTOP) { if(OrderOpenPrice()>=Bid-10*Pips)
Bid plus.
-
if(OrderOpenTime()>=Bid-10*Pips)
Time <= price is meaningless.
Hi all
I would like to delete a pending order after 10 pips, that's if the buy order is in profit after 10 pips. With the code below it will delete sell stop all the time. I know you can delete by time function after a few minutes, hours & days etc. I would like to know is it possible to delete after certain amount of pips?
If so please help
Convert Pips back to price and use OrderOpenPrice.
Example: PriceDifference = CurrentPrice - OrderOpenPrice(). OrderClose = Pips (converted to price).
Therefore if PriceDifference >= OrdersClose.......Proceed to close your pending order.
I'm not that good at coding yet so I hope the above gives you my line of thinking or approach.
Changed it, as you mentioned above but expiration as soon as pending order is open.
double Pips=0; double Ticksize=MarketInfo(Symbol(),MODE_TICKSIZE); if(Ticksize==0.00001||Ticksize==0.001) Pips=Ticksize*10; else Pips=Ticksize; for(int Loop3=OrdersTotal()-1;Loop3>=0;Loop3--) { if(OrderSelect(Loop3,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber) { if(OrderType()==OP_BUYSTOP) { if(OrderOpenTime()<Ask-10*Pips) { bool Delete=OrderDelete(OrderTicket(),clrHotPink); } } else if(OrderType()==OP_SELLSTOP) { if(OrderOpenTime()<Bid+10*Pips) { bool Delete=OrderDelete(OrderTicket(),clrHotPink); } } } }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all
I would like to delete a pending order after 10 pips, that's if the buy order is in profit after 10 pips. With the code below it will delete sell stop all the time. I know you can delete by time function after a few minutes, hours & days etc. I would like to know is it possible to delete after certain amount of pips?
If so please help