- The code you showed has NOTHING to do with your question
- The error messages you showed has NOTHING to do with your question
- Don't DOUBLE POST
- I still have no Idea what you're askingoriginal stoploss is 20 pips.but if it reaches 15 pip I want it to set 8What is 'it'
- Post your code. No Slaves here, learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
int Spread = (Ask - Bid) / Point + 0.1;
Spread not adjusted for 4/5 digit brokers. Adding 0.1 to an int won't change much.
APeng 2011.07.30 01:10 void Skip_SL_to_openprice() { if(Use_skip_SL_to_open_price == true) { OrderSelect(ticket,SELECT_BY_TICKET); //BUY order: if price is above skip level -> SL = OrderOpenPrice if (OrderType() == OP_BUY && Bid > OrderOpenPrice()+Skip_SL_to_Open_price*Point) { SL = OrderOpenPrice(); Alert("SL is set to open Price: ",SL); } //SELL order: if price is below skip level -> SL = OrderOpenPrice if (OrderType() == OP_SELL && Ask < OrderOpenPrice()-Skip_SL_to_Open_price*Point) { SL = OrderOpenPrice(); Alert("SL is set to open Price: ",SL); } } } he said but I dont know how to add it to code.my true SL is 15.if it reaches -15 I dont want it to close order,but give it 5 more pips to make it max -20,then I will wait it to fall -10.so my loss is not 15 or 20.it will be 10 for some of trades.its like modify order(trailing stop).until it reaches 7 pips trail is 5,then when my profit reaches 7 or more,trailingstop will be 2,so if the chart falls my profit is 5(7-2) instead of 2(7-5). |
Error:4051 means you have error in the part of calling OrderClose() function https://docs.mql4.com/trading/OrderClose
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
}
2011.07.30 23:09:47 2011.05.03 06:01 bulduk11 EURUSD,M5: Order 0 failed to close. Error:0
2011.07.30 23:09:47 2011.05.03 06:01 bulduk11 EURUSD,M5: Alert: Order 0 failed to close. Error:4051
2011.07.30 23:09:47 2011.05.03 06:01 bulduk11 EURUSD,M5: OrderClose error 4051
2011.07.30 23:09:47 2011.05.03 06:01 bulduk11 EURUSD,M5: invalid ticket for OrderClose function
2011.07.30 23:09:47 2011.05.03 06:01 bulduk11 EURUSD,M5: Order opened : EURUSD Buy @ 1.47877000 SL @ 1.47747000 TP @1.48877000 ticket =1
2011.07.30 23:09:47 2011.05.03 06:01 bulduk11 EURUSD,M5: open #1 buy 0.10 EURUSD at 1.47877 sl: 1.47747 tp: 1.48877 ok
------------------------------------------------
I mean for example my original stoploss is 20 pips.but if it reaches 15 pip I want it to set 8.........like trailing stop.
modifying stop loss..
-20...................
-18 => -11
-17 => -10
-16 => -9
-15 => -8
negative trailingstop is -7 for example.it reachs 17 I dont want to wait till it became positive or it comes -20.