happy day for all
my expert advisor idea : putting pending orders in desired place with mouse and keyboard
buylimit = CNTRL + left mouse clic in desired place
selllimit = ALT + left mouse clic
it works great smooth and all ...
but
i discovered that it wont work on YEN pairs like gbpjpy usdjpy...on the other it works great
the code
any idea ??! please
any idea ??! please
Really "your" expert advisor? The error message which it prints to the Experts log is telling you exactly what the problem is...
yes mine
whene it does not work on gbpjpy for exemple it dont telle any message any thing any error ... like it is not putted on the chart or like the mouse and the key are not pressed and thats only on YEN pairs i will become crazy ....i cant sleep thinking of this only on YEN pairs it works 1 time / 10
it dont telle any message any thing any error
It is Print()ing the exact nature of the problem to the Experts log.
ChartXYToTimePrice() can give you fractional prices, at greater granularity than what can be traded. For example, on USDJPY, it can return a price value such as 123.456789. MT4 will reject this. You need to round the price to 123.457 before passing it to OrderSend().
You are doing the following:
prix = NormalizeDouble(price,5);
You need to change the 5 to the number of digits for the instrument. For example:
prix = NormalizeDouble(price, (int)SymbolInfoInteger(Symbol(), SYMBOL_DIGITS));
happy day for all
my expert advisor idea : putting pending orders in desired place with mouse and keyboard
buylimit = CNTRL + left mouse clic in desired place
selllimit = ALT + left mouse clic
it works great smooth and all ...
but
i discovered that it wont work on YEN pairs like gbpjpy usdjpy...on the other it works great
the code
Don't use NormalizeDouble(). It is a kludge! It is useless! If you do things correctly, you don't need it!
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.
... prix = NormalizePrice( price ); ... double NormalizePrice( double price ) { double tick_size = SymbolInfoDouble( _Symbol, SYMBOL_TRADE_TICK_SIZE ); // Valid for both MQL4 and MQL5 return( round( price / tick_size ) * tick_size ); }
EDIT: Also make sure you also align the prices for your stops (Stop-Loss and Take-Profit), not just the opening price.
Don't use NormalizeDouble(). It is a kludge! It is useless! If you do things correctly, you don't need it!
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.
Honestly I am tired to read this on the forum, not only WHRoeder post it almost every day, but now you start with the same too. The OP will not even understand why you write it.
There is no problem with NormalizeDouble(). It can be used, if done correctly. If you trade non-forex symbol it will not be sufficient to get a correct price.
There is no problem with NormalizeDouble(). It can be used, if done correctly. If you trade non-forex symbol it will not be sufficient to get a correct price.
For the simple fact, that no other language has a NormaliseDouble function. It was only created due to "bad" design by the initial versions of MetaTrader which was initially designed only for Forex market.
That "bad" design has since been corrected, but the bad habit of its continued use is due to the persistent usage by fellow coders and due to MetaQuotes not removing it for good from the system.
MT5 has now extended its use to non-forex markets where the correct tick size alignment is much more important than ever before.
In all my code I don't use it at all and all prices are aligned by tick size and all volumes are aligned by lot step, and not once do I get any errors due to not using NormalizeDouble.
Defending its use is only making it more difficult for newbie coders to understand the correct way to set the price and adding to the confusion. Please don't defend its use.
Just because it exists, does not mean its usage is valid or correct. MetaTrader and MQL have many failings and this is one of them. So, defending these faults, does not help anyone.
It is Print()ing the exact nature of the problem to the Experts log.
ChartXYToTimePrice() can give you fractional prices, at greater granularity than what can be traded. For example, on USDJPY, it can return a price value such as 123.456789. MT4 will reject this. You need to round the price to 123.457 before passing it to OrderSend().
You are doing the following:
You need to change the 5 to the number of digits for the instrument. For example:
i had a dout about thik you very match
For the simple fact, that no other language has a NormaliseDouble function. It was only created due to "bad" design by the initial versions of MetaTrader which was initially designed only for Forex market.
That "bad" design has since been corrected, but the bad habit of its continued use is due to the persistent usage by fellow coders and due to MetaQuotes not removing it for good from the system.
MT5 has now extended its use to non-forex markets where the correct tick size alignment is much important than ever before.
In all my code I don't use it at all and all prices are aligned by tick size and all volumes are aligned by lot step, and not once do I get any errors due to not using NormalizeDouble.
Defending its use is only making it more difficult for newbie coders to understand the correct way to set the price and adding to the confusion. Please don't defend its use.
Just because it exists, does not mean its usage is valid or correct. MetaTrader and MQL have many failings and this is one of them. So, defending these faults, does not help anyone.
thinks a lot
For the simple fact, that no other language has a NormaliseDouble function. It was only created due to "bad" design by the initial versions of MetaTrader which was initially designed only for Forex market.
My view likes somewhere between yours and Alain's.
NormalizeDouble() can be viewed as equivalent to the Math.Round(number, digits) found in many languages, and thus has legitimate uses.
I'd say that the number of instruments whose tick-size is not a multiple of 10 is now decreasing, not increasing. For example, lots of brokers used to have S&P contracts which moved in increments of 0.25, like the CME e-mini contract. But I now can't immediately think of a broker whose S&P contract isn't priced in increments of 0.01 like the underlying index.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
happy day for all
my expert advisor idea : putting pending orders in desired place with mouse and keyboard
buylimit = CNTRL + left mouse clic in desired place
selllimit = ALT + left mouse clic
it works great smooth and all ...
but
i discovered that it wont work on YEN pairs like gbpjpy usdjpy...on the other it works great
the code