Also other problem is that this is an H12 bot and the fail is on H1 and D1 netting.
I don't think the error has to do with this code:
//--- inputs for main signal input int Signal_ThresholdOpen =10; // Signal threshold value to open [0...100] input int Signal_ThresholdClose =10; // Signal threshold value to close [0...100] input double Signal_PriceLevel =0.0; // Price level to execute a deal input double Signal_StopLevel =50.0; // Stop Loss level (in points) input double Signal_TakeLevel =50.0; // Take Profit level (in points) double NormalizePrice(double price) { double m_tick_size=SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE); return(NormalizeDouble(MathRound(price/m_tick_size)*m_tick_size,_Digits)); }
-
You can't move stops (or pending prices) closer to the market than the minimum: MODE_STOPLEVEL * _Point or SymbolInfoInteger(SYMBOL_TRADE_STOPS_LEVEL).
Requirements and Limitations in Making Trades - Appendixes - MQL4 TutorialOn some ECN type brokers the value might be zero (broker doesn't know.) Use a minimum of two (2) PIPs.
- NormalizeDouble, It's use is usually wrong
-
Floating point has 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 encyclopedia -
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) (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
-
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 Metals. So do it right: Trailing Bar Entry EA - MQL4 programming forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 programming forum
-
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.
-
MathRound() and NormalizeDouble() are rounding in a different way. Make it explicit.
MT4:NormalizeDouble - MQL5 programming forum
How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum - Prices you get from the terminal are already normalized.
- PIP, Point, or Tick are all different in general.
What is a TICK? - MQL4 programming forum 2014.08.03
-
- 2013.08.16
- www.mql5.com
I keep running into this error at the automated validation testing:
Everything else is a pass:
I kept trying to change # of ticks, symbols, trade frequency, trailing, etc. but nothing have worked.
I also tried messing with the stops and take levels back and forth, but still to no avail fixing it.
Any suggestions?
I already tried this: https://www.mql5.com/en/forum/285056
Did you forget to check the symbol freeze levels? Read the article: THE CHECKS A TRADING ROBOT MUST PASS BEFORE PUBLICATION IN THE MARKET
- www.mql5.com
The sky is blue. | Is the sky blue? |
The ocean is wet. | Is the Ocean wet? |
It won't work on Metals. So do it right | ANDREW MAGDY KAMAL: have I used the NormalizeDouble() function wrong or not in this instance? |
Did you forget to check the symbol freeze levels? Read the article: THE CHECKS A TRADING ROBOT MUST PASS BEFORE PUBLICATION IN THE MARKET
Yes didn't work
Also how do you prevent or catch:
Modification failed due to order or position being close to market
That may fix it, although the error is never set when it trades on its intended time frame. Just the automatic validation stuff.
The same problem with me. to solve the problem, I just create a function to place stop loss:
#
The same problem with me. to solve the problem, I just create a function to place stop loss: #property library //import the trade function #include <Trade\trade.mqh> CTrade trade; void Placestoploss(string Positioncomment="",long SL_point=250)export { for(int i=PositionsTotal()-1; i>=0; i--) { ulong PositionTicket=PositionGetTicket(i); string symbol=PositionGetSymbol(i); int Symbol_Digit=SymbolInfoInteger(symbol,SYMBOL_DIGITS); double Symbol_Point=SymbolInfoDouble(symbol,SYMBOL_POINT); double checkcurrentstoploss=PositionGetDouble(POSITION_SL); double PositionPriceOpen=PositionGetDouble(POSITION_PRICE_OPEN); long stopLevels = SymbolInfoInteger(symbol, SYMBOL_TRADE_STOPS_LEVEL)+SymbolInfoInteger(symbol, SYMBOL_SPREAD); SL_point=MathMax(stopLevels,SL_point); if(PositionGetString(POSITION_COMMENT)==Positioncomment) { if(checkcurrentstoploss==0||(MathAbs(checkcurrentstoploss-PositionPriceOpen)>=(SL_point+200)*Symbol_Point) ) { if(PositionGetInteger(POSITION_TYPE)==ORDER_TYPE_SELL) { trade.PositionModify(PositionTicket,NormalizeDouble(PositionPriceOpen+(Symbol_Point*SL_point),Symbol_Digit),0); } else { if(PositionGetInteger(POSITION_TYPE)==ORDER_TYPE_BUY) { trade.PositionModify(PositionTicket,NormalizeDouble(PositionPriceOpen-(Symbol_Point*SL_point),Symbol_Digit),0); } } } } } }
-
Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
Messages Editor -
PositionPriceOpen+(_Point*Autoplacestoploss) PositionPriceOpen+(_Point*Autoplacestoploss),
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
-
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close to a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 -
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes.
My GBPJPY shows average spread = 26 points, average maximum spread = 134.
My EURCHF shows average spread = 18 points, average maximum spread = 106.
(your broker will be similar).
Is it reasonable to have such a huge spreads (20 pip spreads) in EURCHF? - General - MQL5 programming forum (2022)
-
- 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 keep running into this error at the automated validation testing:
Everything else is a pass:
I kept trying to change # of ticks, symbols, trade frequency, trailing, etc. but nothing have worked.
I also tried messing with the stops and take levels back and forth, but still to no avail fixing it.
Any suggestions?
I already tried this: https://www.mql5.com/en/forum/285056