Need more details, but it seems the SL is in stop-level.
Need more details, but it seems the SL is in stop-level.
thank you Mohammad Hossein Sadeghi. you are right i increase the tp and sl to 10000 and 15000 . and now its working . . . . .
thank you Mohammad Hossein Sadeghi. you are right i increase the tp and sl to 10000 and 15000 . and now its working . . . . .
According to the screenshot it looks like a rounding issue (look at the TP SL values after the . ) See this post https://www.mql5.com/en/forum/216065#comment_5795267
![NormalizeDouble not "working" NormalizeDouble not "working"](/i/community/logo_mql5_small.png)
- 2017.09.21
- www.mql5.com
According to the screenshot it looks like a rounding issue (look at the TP SL values after the . ) See this post https://www.mql5.com/en/forum/216065#comment_5795267
Agree, but tick size other than a multiple of 0.00001 is rare. So I believe the case is stop level, since it is solved by increasing the stop distance as stated.
It's rare if you trade Forex.
It's common if you trade Metals or CFDs.
It's almost never the case if you trade Futures or Stocks.
So depending of your target, your code will work or not. It's far better to made universal code, don't you think ?
It's rare if you trade Forex.
It's common if you trade Metals or CFDs.
It's almost never the case if you trade Futures or Stocks.
So depending of your target, your code will work or not. It's far better to made universal code, don't you think ?
I agree, it's best if MQL would provide a built-in function for this purpose.
They do! It's called Tick Size, in the same way that they also provide a function for the Lot Step and also for the Stop Level.
Forum on trading, automated trading systems and testing trading strategies
Fernando Carreiro, 2017.09.22 23:22
This is valid for both MQL4 and MQL5:
double tickSize = SymbolInfoDouble( _Symbol, SYMBOL_TRADE_TICK_SIZE );Forum on trading, automated trading systems and testing trading strategies
Fernando Carreiro, 2017.09.21 22:44
In short, NormalizeDouble() does nothing useful at all, and what does solve the problem is making sure the price is a aligned to the symbol's tick size.
For example, if the tick size is 0.00025 then all prices must be multiples of that, so a price like 1.34035 would be invalid, and the only valid prices closest to that would either be 1.34050 or 1.34025, with the later being the closest/better choice (rounding).
double normalised_price = round( price / tick_size ) * tick_size;Forum on trading, automated trading systems and testing trading strategies
Fernando Carreiro, 2017.09.23 00:41
Just as a side note.
Initially, when I started with MQL, I would manipulate prices as "doubles". Nowadays, especially in the more complex EA's, I manipulate prices as "ints". At the very first opportunity, I convert a price into ticks:
int priceTicks = (int) round( price / tickSize );From then on, all my calculations and manipulations are done with "ints". Not only is it more memory compact and much faster, but comparisons are much easier to handle. Doing a "priceA == priceB" for "doubles" is quite problematic, but not for "ints" because it gives exact matches. Not to mention, that in this way prices, stop sizes, etc. are ALWAYS aligned.
Then, just before I have to place or modify an order, I then convert it back:
priceTicks * tickSizeEDIT: I do the same for volume/lots by using the broker's Lot-Step.
They do! It's called Tick Size, in the same way that they also provide a function for the Lot Step and also for the Stop Level.
double Round2TickSize (double price)It gets price of any value and rounds it to Symbol's tick size.
Is it that difficult to make your own function to do the same?
double Round2Ticksize( double price ) { double tick_size = SymbolInfoDouble( _Symbol, SYMBOL_TRADE_TICK_SIZE ); return( round( price / tick_size ) * tick_size ); }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
i have an EA working on all currency pairs except BTCUSD pair
the file is attached