You must take in consideration your symbol's contract specifications, taking into account the Freeze Level, Stops Level and also current spread.
Usually you cannot place pending orders so close to current market prices. For such situations, it is best for the EA to monitor conditions and place Market Orders when the conditions are met.
Pending orders are best used for manual trading or long-term trading strategies, not for short-term strategies using EAs.
Hi,
I am trying to place a buy stop and sell stop 1 pip above and below close price of the previous candle but keep getting invalid price error.
I will appreciate insight on where I am going wrong.
Below is what I have:
Thanks.
its about your broker, at first check stoplevel amount with (MarketInfo)
check your strategy on ecn acount and there stoplevel has no meaning
Thanks for this. I just looked at it taking consideration your comments and all is well now.
Thanks so much :)
You must take in consideration your symbol's contract specifications, taking into account the Freeze Level, Stops Level and also current spread.
Usually you cannot place pending orders so close to current market prices. For such situations, it is best for the EA to monitor conditions and place Market Orders when the conditions are met.
Pending orders are best used for manual trading or long-term trading strategies, not for short-term strategies using EAs.
You must take in consideration your symbol's contract specifications, taking into account the Freeze Level, Stops Level and also current spread.
Usually you cannot place pending orders so close to current market prices. For such situations, it is best for the EA to monitor conditions and place Market Orders when the conditions are met.
Pending orders are best used for manual trading or long-term trading strategies, not for short-term strategies using EAs.
Thank you so much Fernando, for the wonderful technical explanation. I am joining this thread because I am having a similar problem.
As of now, most of the terms are vague for me and gradually learning the terms....
I am currently working on one EA beign tested on EURUSD symbol running on a 1 min chart where intermittently reports "Invalid Stop" or "Invalid price" error
The EA attempted following Sell Trade for which it got error: 130: "invalid stops"
All the data at the time of the order entry was logged and is as follows:
ORDER CMD 5 : OP_SELL_STOP
Setup Candle OHLC O[1] 1.18456 H[1] 1.18458 L[1] 1.18445 C[1] 1.18448
Trade Candle OHLC O[0] 1.18449 H[0] 1.18449 L[0] 1.18449 C[0] 1.18449
Bid 1.18449 Ask 1.18464
Indicator1 1.18452 Indicator2 1.18453
Entry 1.18430 S.L. 1.18493 T.P. 1.18365
Entry is set 15 points below L[1]
Stop loss is set 40 points above Indicator2
Take profit is set 80 points L[1]
All the price values were filtered thru NormaliseDouble function
You used NormalizeDouble, It's use is usually wrong, as it is in your case.
-
Floating point has a infinite number of decimals, it's your not understanding floating point and that some numbers can't be represented exactly. (like 1/10.)
Double-precision floating-point format - Wikipedia, the free encyclopediaSee also The == operand. - MQL4 programming forum 2013.06.07
-
Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.
-
SL/TP (stops) need to be normalized to tick size (not Point) — code fails on non-currencies. (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 programming forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 programming forum 2012.02.16
-
Open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on non-currencies. So do it right: Trailing Bar Entry EA - MQL4 programming forum (2013.08.17) or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 programming forum (2012.01.02)
-
Lot size must also be adjusted to a multiple of LotStep and check against min and max. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right. (2013.08.17)
-
MathRound() and NormalizeDouble() are rounding in a different way. Make it explicit.
MT4:NormalizeDouble - MQL5 programming forum 2017.01.04
How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum 2017.05.19 -
Prices you get from the terminal are already correct (normalized).
-
PIP, Point, or Tick are all different in general.
What is a TICK? - MQL4 programming forum 2014.08.03
You used NormalizeDouble, It's use is usually wrong, as it is in your case.
-
Floating point has a infinite number of decimals, it's your not understanding floating point and that some numbers can't be represented exactly. (like 1/10.)
Double-precision floating-point format - Wikipedia, the free encyclopediaSee also The == operand. - MQL4 programming forum 2013.06.07
-
Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.
-
SL/TP (stops) need to be normalized to tick size (not Point) — code fails on non-currencies. (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 programming forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 programming forum 2012.02.16
-
Open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on non-currencies. So do it right: Trailing Bar Entry EA - MQL4 programming forum (2013.08.17) or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 programming forum (2012.01.02)
-
Lot size must also be adjusted to a multiple of LotStep and check against min and max. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right. (2013.08.17)
-
MathRound() and NormalizeDouble() are rounding in a different way. Make it explicit.
MT4:NormalizeDouble - MQL5 programming forum 2017.01.04
How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum 2017.05.19 -
Prices you get from the terminal are already correct (normalized).
-
PIP, Point, or Tick are all different in general.
What is a TICK? - MQL4 programming forum 2014.08.03
Please forgive me WIlliam but I am unable to comprehend so much of information in one go!!
Please first tell me that which one of these three [Entry 1.18430/ S.L. 1.18493/ T.P. 1.18365] for OP_SELL_STOP would need to be rectified to make the "Invalid Stop" error go away
Bid value 1.18449 and Ask value was 1.18464
MarketInfo(Symbol(), MODE_DIGITS) returns 5.00000000
MarketInfo(Symbol(), MODE_TICKSIZE) returns 0.00001000
Global Point variable has value 0.00001000
Referring to the webpage Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
For SellStop order, rules are
R1) Open Price of a Pending Order needs to be below Below the current Bid price
R2) SL - OpenPrice ≥ StopLevel
R3) OpenPrice - TP ≥ StopLevel
--------
My EA's order open price was 1.18430 which was indeed below the Bid at 1.18449
Rule 2 of stop loss also met.
1.18493 - 1.18430 = 0.00063 and stop level is 0.00030 so this field is correct too.
Rule 3 of Target also met.
1.18430 - 1.18365 = 0.00065 which is also above stop level.
In absolute laymen terms, I am honestly unable to comprehend what exactly does "Invalid Stops" error refers to.
What exactly does word "Stops" linked to in this context?
Is it referring to open price of stop order?
Is it referring to stop loss ?
Or is it referring to both target and stop loss since they "stop" (close out) the would be trade...
- book.mql4.com
Entry Price (Order's Opening price) is above Ask
Stop loss / Target is sufficiently far from Bid and ask...
No extra digits.....
All rules mentioned in document are beign followed, why this Invalid Stop?
Entry Price (Order's Opening price) is above Ask
Stop loss / Target is sufficiently far from Bid and ask...
No extra digits.....
All rules mentioned in document are beign followed, why this Invalid Stop?
Found the offending rule
OpenPrice-Ask ≥ StopLevel
1.17366 - 1.17365 = 0.00001 which is less than 0.00030 (stop level)
- 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 am trying to place a buy stop and sell stop 1 pip above and below close price of the previous candle but keep getting invalid price error.
I will appreciate insight on where I am going wrong.
Below is what I have:
Thanks.