Tell me how to add take profit
This is the simplest way, but it leaves a lot to be desired, does not work with ECN brokers.
extern double Lots=0.1; extern int TakeProfit=30; // Take profit value in points datetime NewTime=0; int start() { if(NewTime!=Time[0]) { NewTime=Time[0]; if(Close[1]>=Open[1]) OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+(TakeProfit*_Point),NULL,0,0,Blue); else OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-(TakeProfit*_Point),NULL,0,0,Red); } return(0); } //+------------------------------------------------------------------+
This is the simplest way, but it leaves a lot to be desired, does not work with ECN brokers.
Dear John Davis
its ok i will use normal broker
This is the simplest way, but it leaves a lot to be desired, does not work with ECN brokers.
but why it won't work in ECN brokers?!
Because in ECN you have to open position without TP and SL in the ordersend function and then after the position is opened you use ordermodify function to set TP and SL.
Please dont double post.
Because in ECN you have to open position without TP and SL in the ordersend function and then after the position is opened you use ordermodify function to set TP and SL.
But i tried in one ecn and it was working fine!
Fake ECN !
Haha.
No maybe it's just some broker i dont know but it does cause problem sometimes or most of the time.
Marco vd Heijden: Because in ECN you have to open position without TP and SL in the ordersend function and then after the position is opened you use ordermodify function to set TP and SL.
Fake ECN !
Haha.
No maybe it's just some broker i dont know but it does cause problem sometimes or most of the time.I too was once under that assumption, but @Alain Verleyen informed me that it is no longer the case since many builds ago (a few years back). Now ALL account types or brokers, will accept the S/L and T/P on the OrderSend().
I did not believe him at first, so I did some research and testing and can confirm that he is correct. There is no longer a need to split the operation into two parts.
The discussion was heated due to my ignorance but he was (and is) correct:
Forum on trading, automated trading systems and testing trading strategies
stop loss order not being placed
Fernando Carreiro, 2016.11.08 19:03
Even when I show you proof (via the screen-shots)? Well, it seems you have never traded with a decent ECN broker then!
Forum on trading, automated trading systems and testing trading strategies
stop loss order not being placed
Alain Verleyen, 2016.11.08 19:06
You really don't know what you are talking about.
- Where in the documentation do you see some restrictions about placing SL/TP on Market execution ? Via GUI or code.
- Here a screenshot from a real account, ECN broker :
- Here is the log from an order placed with SL/TP at once :
2016.11.08 19:18:17.430 'XXXXXX': order was opened : #11987283 sell 0.01 EURUSD at 1.10248 sl: 1.10258 tp: 1.10237
2016.11.08 19:18:16.996 'XXXXXX': order sell market 0.01 EURUSD sl: 1.10258 tp: 1.10237
- It's more than 2 years, it's was already well known on forum (by code). It was announced more than 3 years ago on build 500.
- On the MT4 GUI it was available later, but I don't remember from which build.
P.S: I found the announcement about MT4 GUI, it was on build 710.- Terminal: Allowed specification of Stop Loss and Take Profit when opening a position for a Market Execution type symbol.
- Don't double post
- #2 gave you your answer.
I too was once under that assumption, but @Alain Verleyen informed me that it is no longer the case since many builds ago (a few years back). Now ALL account types or brokers, will accept the S/L and T/P on the OrderSend().
I did not believe him at first, so I did some research and testing and can confirm that he is correct. There is no longer a need to split the operation into two parts.
The discussion was heated due to my ignorance but he was (and is) correct:
I followed your threads and learned something new today, thanks. The above code should work on ECN brokers also! Great.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use