Greetings
why is closing price higher than the stop loss? As soon as it hits my stop loss, stop loss price and closing price are not the same. When my pending orders (buy stop & sell stop) are placed everything is perfect. Once it turns into a position, price changes and stop loss changes. I tried searching on the web & I came across "order filled" I assumed it might be the solution to my problem, but no. here is the EA Below:
void FillAgain() { for(int u=OrdersTotal()-1;u>=0;u--) { if(m_order.SelectByIndex(u)) if(m_order.Symbol()==Symbol()) { bool ForceSL; if(m_order.Type()==ORDER_TYPE_BUY_STOP||m_order.Type()==ORDER_TYPE_SELL_STOP) { ForceSL=MathAbs(m_order.PriceCurrent()-m_order.StopLoss()<=0.5*Pips()); } } } }It does not solve my problem. Hence when order turns into position everything changes opening price including the stoploss
My Closing price is higher than the stop loss. Since I'm trading Indices, to be specific US30 (spread is 70 points). I tried using this average spread function but I'm not winning.
double AverageSpread() { double Spread=NormalizeDouble(Ask-Bid,Digits()); ArrayCopy(SpreadHistory,SpreadHistory,0,1,29); SpreadHistory[29]=Spread; if(SpreadHistoryCount<30)SpreadHistoryCount++; double SpreadHistorySum=0; for(int i=29;i>=30-SpreadHistoryCount;i--)SpreadHistorySum+=SpreadHistory[i]; double SpreadAverage=SpreadHistorySum/SpreadHistoryCount; double SpreadWithCom=NormalizeDouble(SpreadAverage,Digits()); return(SpreadWithCom); }
if(spreadAmount*Pips()>AverageSpread()) { //buy & sell trade }
Greetings
why is closing price higher than the stop loss? As soon as it hits my stop loss, stop loss price and closing price are not the same. When my pending orders (buy stop & sell stop) are placed everything is perfect. Once it turns into a position, price changes and stop loss changes. I tried searching on the web & I came across "order filled" I assumed it might be the solution to my problem, but no. here is the EA Below:
The problem isn’t with your code, it’s simply how trading works.
You’ll only get an exact execution price if you use limit orders. When you use stop orders (Stop Loss, Buy Stop or Sell Stop) your order is executed when price reaches a certain level, but it's executed as a market order. This means it fills at the best available price at that moment, which can be different from your stop price, especially during high volatility or low liquidity.
This behavior is normal and is a fundamental aspect of how financial markets operate. It’s not something that can be fixed, it’s just how stop orders are designed to work.
If you need more precise control over execution price, you’ll need to use limit orders. But they might not get filled if the market doesn't reach your specified price.
Same "problem" happened here. It's called slippage, a very simple and common situation in trading.
The problem isn’t with your code, it’s simply how trading works.
You’ll only get an exact execution price if you use limit orders. When you use stop orders (Stop Loss, Buy Stop or Sell Stop) your order is executed when price reaches a certain level, but it's executed as a market order. This means it fills at the best available price at that moment, which can be different from your stop price, especially during high volatility or low liquidity.
This behavior is normal and is a fundamental aspect of how financial markets operate. It’s not something that can be fixed, it’s just how stop orders are designed to work.
If you need more precise control over execution price, you’ll need to use limit orders. But they might not get filled if the market doesn't reach your specified price.
I see, the same person is encountering the same problem as I 'am but he/she is using MT4. There are certain individuals who can limit/reduce spread or close at a minimum spread I'd like to know if it's possible?
Trades are always closed at the first valid price. It can be the same exact of your stop loss or deviate by it if the tick triggering the closure is bigger.
I ran the My EA on a live account & I fully understand what you're saying especially indices and its slippage.
void CalulateProfit() { double Profit=0; for(int i=PositionsTotal()-1;i>=0;i--) { if(m_position.SelectByIndex(i)) { Profit=m_position.Commission()+m_position.Profit()+m_position.Swap(); } } }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Greetings
why is closing price higher than the stop loss? As soon as it hits my stop loss, stop loss price and closing price are not the same. When my pending orders (buy stop & sell stop) are placed everything is perfect. Once it turns into a position, price changes and stop loss changes. I tried searching on the web & I came across "order filled" I assumed it might be the solution to my problem, but no. here is the EA Below: