I don't think it is a case of a large S/L, but rather that your calculation is not checking for the possibility of a negative S/L vakue. Example, in the case of a Buy order for EURGBP and you have a S/L = Ask - 10000 pips and lets say the price is 0.8584 which would give a S/L of -0.1416 which is invalid.
Also, make sure you are adjusting your S/L to be a factor of the Tick Size ( round( SL / TickSize ) * TickSize ).
Forum on trading, automated trading systems and testing trading strategies
How To Manage 0.5 or 0.05 Price Steps (Tick Value, Tick Size) in order to avoid Error 130
Fernando Carreiro, 2018.01.04 12:13
You must NOT use NormalizeDouble(). You must use the Tick-Size to correctly set the price values. This has been discussed on the forum many times, so do a search but the most common post you will see goes something like this ...
In essence, make sure that your price quotes, are properly aligned to the Tick size (see following examples).
... double tickSize = SymbolInfoDouble( _Symbol, SYMBOL_TRADE_TICK_SIZE ); ... double normalised_price = round( price / tick_size ) * tick_size; ... // Or use a function double Round2Ticksize( double price ) { double tick_size = SymbolInfoDouble( _Symbol, SYMBOL_TRADE_TICK_SIZE ); return( round( price / tick_size ) * tick_size ); }
You may also benefit from reading this: https://www.mql5.com/en/forum/223705#comment_6279080
I don't think it is a case of a large S/L, but rather that your calculation is not checking for the possibility of a negative S/L vakue. Example, in the case of a Buy order for EURGBP and you have a S/L = Ask - 10000 pips and lets say the price is 0.8584 which would give a S/L of -0.1416 which is invalid.
Also, make sure you are adjusting your S/L to be a factor of the Tick Size ( round( SL / TickSize ) * TickSize ).
Thanks, it was not a problem with negative value but something with decimals. SL on 1% did not work, but 1.0% did go trough.. Don't know why, but it works if I write it with the decimals.. Thanks for the hint of the problem.
If you are using literal constants and don't use decimals it will assume it is an integer, and carry out integer division instead of floating point division.
Example:
price * ( 1 / 100 ) = price * 0 (integer division)
price * (1.0 / 100 ) = price * 0.01 (floating point division)
price * (1 / 100.0 ) = price * 0.01 (floating point division)
- 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
I get OrderSent error 130 if I put a StoppLoss or Take Profit during OrderSend when I seems to have a to large value (SL > 1% ) .. ( that is an invalid stop loss ). I am use to get this if I have to tight stop loss, but is there a limitation on how fare away stop loss can be? The limit seems to be at 1% from my entry price (IC market).
I need to have a SL as backup if my EA gets disconnected, but the EA will normal / should use a parametric exit.
Am I doing something obvious wrong, or will I need to write something that will change my SL on the way down until I reach my > 1% ?
BR /