Build 500 № 9 2013.05.09
Need help me mql4 guru add take profit to this EA - Take Profit - MQL4 programming forum 2017.09.27
Hi, in the particular trade I'm creating I want to open a position with the smallest stop-loss that my broker will allow.
I've modified some code I found on these forums but it's still not working right and I'm not sure what I'm doing wrong.
Here's a snippet of my code:
Now, my broker publishes the SYMBOL_TRADE_STOPS_LEVEL with a value of 40 and as a result, when opening a BUY position on EURUSD, the stop-loss is 0.0004 below the ASK price.
My problem is that sometimes this stop-loss still results in a failed trade. Here's a sample from my journal:
My question is, should I change my code or my broker?
Have you tried this.
if (type == POSITION_TYPE_BUY) { currentPrice = State.Symbol.Bid(); slPriceLimit = currentPrice-MathMax(SymbolInfoInteger(Symbol(),SYMBOL_TRADE_STOPS_LEVEL),SymbolInfoInteger(Symbol(),SYMBOL_TRADE_FREEZE_LEVEL))*Point(); } else { currentPrice = State.Symbol.Ask(); slPriceLimit = currentPrice+MathMax(SymbolInfoInteger(Symbol(),SYMBOL_TRADE_STOPS_LEVEL),SymbolInfoInteger(Symbol(),SYMBOL_TRADE_FREEZE_LEVEL))*Point(); }
have you checked the biggest spread possible with your broker? If not yet, you may use a script to check that. Here's one. https://www.mql5.com/en/code/27942. You just need to convert it to MQL5.
Also, try to avoid oveernight spread because it's huge in most brokers.
Just my 2 cents. I hope it helps.

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, in the particular trade I'm creating I want to open a position with the smallest stop-loss that my broker will allow.
I've modified some code I found on these forums but it's still not working right and I'm not sure what I'm doing wrong.
Here's a snippet of my code:
Now, my broker publishes the SYMBOL_TRADE_STOPS_LEVEL with a value of 40 and as a result, when opening a BUY position on EURUSD, the stop-loss is 0.0004 below the ASK price.
My problem is that sometimes this stop-loss still results in a failed trade. Here's a sample from my journal:
My question is, should I change my code or my broker?