NikoSeneca:
Hi, i'm using OrderModify to change TP and SL of floating orders but I need a simple idea to make this happen only once.
Right now I had to put SL as 0 when I open the order, so when I change it and gets a value, then it stops... but i'd like to use another thing to make it dynamic (similar to trailing stop) and keep on changing SL at my will while order is still open.
I have to say that I use same EA for many differents currency pairs.
Which idea you suggest? Probably is an obvious and easy thing, but I'm just mind blocked.
Here's my actual code.
Thank you in advance!
OrderModify to put StopLoss and TakeProfit for(int l=0; l<OrdersTotal(); l++) { int once =0;// you can also define this in global scope if(OrderSelect(l,SELECT_BY_POS,MODE_TRADES)==true) { if(OrderSymbol()==SYM1 && OrderStopLoss()==0 && OrderMagicNumber()==MagNum) { double vpoint=MarketInfo(OrderSymbol(),MODE_POINT); double vdigits=MarketInfo(OrderSymbol(),MODE_DIGITS); if(OrderType()==1 && once ==0) //Sell { bool Mod=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+StopLoss*vpoint,OrderOpenPrice()-TakeProf*vpoint,0,clrNONE); if(!Mod) { Print("Error in OrderModify. Error code=",GetLastError());} else { once ++ }
if(OrderType()==0 && once == 0)
{ bool Mod=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-StopLoss*vpoint,OrderOpenPrice()+TakeProf*vpoint,0,clrNONE); if(!Mod) { Print("Error in OrderModify. Error code=",GetLastError());} else { once ++} } } }
ejmin ejoni:
I'll give it a try. Thanks!!!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi, i'm using OrderModify to change TP and SL of floating orders but I need a simple idea to make this happen only once.
Right now I had to put SL as 0 when I open the order, so when I change it and gets a value, then it stops... but i'd like to use another thing to make it dynamic (similar to trailing stop) and keep on changing SL at my will while order is still open.
I have to say that I use same EA for many differents currency pairs.
Which idea you suggest? Probably is an obvious and easy thing, but I'm just mind blocked.
Here's my actual code.
Thank you in advance!