Opengates: Please I need enlightenment on this: sometimes by almost 10p Any help |
|
Dear Gurus in the house,
Please I need enlightenment on this: I used 30p for my stoploss and 30p for takeprofit also but after the ea opens the order, I noticed that the stoploss points was higher than takeprofit point sometimes by almost 10p. What do you think might be responsible for this as when the ea makes 1 loss and 1 win. i ended up losing some pips for those trades.
Any help that brings solution to this from you guys would be appreciated.
Thanks in advance.
extern double TakeProfit = 300; // Take Profit extern double StopLoss = 300; // Stop Loss //=============== Open Buy order here ======================== if(Opn_B==true) { RefreshRates(); // Refresh rates bid = NormalizeDouble(MarketInfo(Symb,MODE_BID),Digits); // Request for the value of Bid SL=bid-StopLoss*Point; // Calculating SL of opened TP=bid+TakeProfit*Point; // Calculating TP of opened Ticket=OrderSend(Symb,OP_BUY,lot,Ask,2,SL,TP); //Opening Buy if (Ticket>0) // Success { Print("The Order for BUY was opened ",Ticket); return(0); // Exit start() } if (Error==1) // Processing errors return(1); // Exit start() } //======= Open Sell order here ======================================= if (Opn_S==true) { RefreshRates(); // Refresh rates ask = NormalizeDouble(MarketInfo(Symb,MODE_ASK),Digits); // Request for the value of Ask SL=ask+StopLoss*Point; // Calculating SL of opened TP=ask-TakeProfit*Point; // Calculating TP of opened Ticket=OrderSend(Symb,OP_SELL,lot,Bid,2,SL,TP); //Opening Sell if (Ticket>0) { Print("The Order for SELL was opened ",Ticket); return(0); // Exit start() }
1. The OrderSend() for SELL orders is wrong. SELL orders are opened at Bid price (you are opening them at Ask price).
2. The reason why your loss is bigger than your profit when your win 1 and lose 1 using equal SL and TP is because of the spread.
For example:
You open a BUY order at ASK price. BUY orders are closed at BID price, so you calculate the stop loss and take profit for that order as:
SL=bid-StopLoss*Point; // Calculating SL of opened TP=bid+TakeProfit*Point; // Calculating TP of opened
Now, if the position ends up being a losing one, you will have a loss of StopLoss points. However, if the position ends up being a winner one, you will have a profit of (TakeProfit - SPREAD) points.
So, if you want to win or lose the same amount of points in a position using equal StopLoss and TakeProfit parameters, you must calculate, for a BUY position, the SL and TP levels as:
SL=bid-StopLoss*Point; // Calculating SL of opened TP=ask+TakeProfit*Point; // Calculating TP of opened
But be aware that by adjusting for the spread like this way, the market will have to move StopLoss points to hit your SL, but will have to move (TakeProfit + SPREAD) points to hit your TP.
Regards.
Ticket=OrderSend(Symb,OP_BUY,lot,Ask,2,SL,TP); //Opening BuyCode fails if Symb is not the current pair
Xiruko and WHRoeder,
Thanks so much. I've gotten it right by your guidance.
More grease to your elbow. You are both great!
Best regards

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear Gurus in the house,
Please I need enlightenment on this: I used 30p for my stoploss and 30p for takeprofit also but after the ea opens the order, I noticed that the stoploss points was higher than takeprofit point sometimes by almost 10p. What do you think might be responsible for this as when the ea makes 1 loss and 1 win. i ended up losing some pips for those trades.
Any help that brings solution to this from you guys would be appreciated.
Thanks in advance.