Double stoploss = NormalizeDouble (ASK- SL * Point, Digits) Double takeprofit = NormalizeDouble (Bid + TP * Point, Digits)
- The signs of the above are only for buy orders. Neither stoploss nor takeprofit include the spread.
- If you use OrderOpenPrice +/- n then both include the spread (sell: spread at the time of close)
- If you pass them on the OrderSend, then they are not symmetrical in the case of slippage. Send and then modify.
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
I'm developing an Expert Adviser on MetaTrader 4. I set the take profit and stop lost at 50 pips. The observation made in the testes with a volume of 0.1 for example, take profit profit gives me 28 euro while a stop lost takes me -38 euro. So what I would like is to have the same amount in the stop lost and the take profit. For instance with Etoro it is possible to fix the same amout with stop lost and take profit. What to do ? Do I must vary the pips in the take profit and stop lost ? what would be the difference of pips in ordrer to have the same amount ?
Below is a snippet of code that I implement in my EA
extern int SL = 500;
extern int TP = 500;
Double stoploss = NormalizeDouble (ASK- SL * Point, Digits)
Double takeprofit = NormalizeDouble (Bid + TP * Point, Digits)
If sale:
int res = OrderSend (Symbol (), OP_SELL, 1, Bid, 3, takeprofit, stoploss, "Morix Trader", 0, Red);
If buying:
res = OrderSend (Symbol (), OP_BUY, 1, Ask, 3, stoploss, takeprofit "Morix Trader", 0, Blue)
Thank you for your valuable help.