Download MetaTrader 5

Setups take profit and stop lost to have the same amount, in a Expert Adviser

To add comments, please log in or register
soddymorais
84
soddymorais  
Hello everyone, help please !!!
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.



whroeder1
15326
whroeder1  
Double stoploss = NormalizeDouble (ASK- SL * Point, Digits)
Double takeprofit = NormalizeDouble (Bid + TP * Point, Digits)
  1. The signs of the above are only for buy orders. Neither stoploss nor takeprofit include the spread.
  2. If you use OrderOpenPrice +/- n then both include the spread (sell: spread at the time of close)
  3. If you pass them on the OrderSend, then they are not symmetrical in the case of slippage. Send and then modify.
To add comments, please log in or register