Hello,
Can someone help me?
maybe i can't normalize my ST and TP properly.
The parameters for the calculation of the SL and TP are
08.19.2022 13: 44: 18.049 StopLossShort = 1.05
2022.08.19 13: 44: 18.049 TakeProfitShort = 0.995
When I run The EA it gives me the following error
08.19.2022 13: 44: 25.819 23.06.2010 00:00:00 market sale 0.01 CORN (350.25 / 350.50 / 350.25)
2022.08.19 13: 44: 25.819 2010.06.23 00:00:00 deal no. 2 sell 0.01 CORN at 350.25 done (based on order # 2)
08.19.2022 13: 44: 25.819 23.06.2010 00:00:00 operation performed [# 2 sale 0.01 CORN at 350.25]
2022.08.19 13: 44: 25.819 2010.06.23 00:00:00 executed order sell 0.01 at 350.25 [# 2 sell 0.01 CORN at 350.25]
2022.08.19 13: 44: 25.822 2010.06.23 00:00:00 retcode = 10009 Deal = 2 Order = 2
2022.08.19 13: 44: 25.822 2010.06.23 00:00:00 Position: # 2 -Symbol: CORN -TipoOperazione: POSITION_TYPE_SELL -Volume: 0.01 -Price: 350.25 -sl: 0.00 -tp: 0.00 -MagicNumber: [1]
08.19.2022 13: 44: 25.822 23.06.2010 00:00:00 23.06.2010 00:00:00: Bid = 350.25 Ask = 350.5 Volume = 0
08.19.2022 13: 44: 25.822 23.06.2010 00:00:00 Change Position: # 2 -Symbol: CORN -TipoOperazione: POSITION_TYPE_SELL
2022.08.19 13: 44: 25.822 2010.06.23 00:00:00 failed change n. 2 sale 0.01 CORN sl: 0.00, tp: 0.00 -> sl: 368.03, tp: 348.75 [Invalid stops]
2022.08.19 13: 44: 25.822 2010.06.23 00:00:00 OrderSend error 4756
2022.08.19 13: 44: 25.822 2010.06.23 00:00:00 retcode = 10016 Deal = 0 Order = 0
350.5 * 0.995
I have tried several scripts to set up ST and TP and this is the last one.
It seems correct to me but if there are roundings it does not work
In this example the real values would be:
TP is 350.5 * 0.995 = 348.7475
SL is 350.5 * 1.05 = 368.025
The script is
Thanks
Try making 2 calls - one for SL and then for TP.
You can figure out if both are invalid or just one - your TP looks like it is too close to the position open price and that could be the reason why the call fails
sl=NormalizeDouble(bid*StopLossLong,digits); tp=NormalizeDouble(bid*TakeProfitLong,digits);
A price times a multiplier is meaningless. TP/SL are prices. The TP must be above the Bid and SL below.
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 Tutorial
On some ECN type brokers, the value might be zero (the broker doesn't know). Use a minimum of two (2) PIPs.
The checks a trading robot must pass before publication in the Market - MQL5 Articles (2016)
Prova a fare 2 chiamate: una per SL e poi per TP.
Puoi capire se entrambi non sono validi o solo uno: il tuo TP sembra essere troppo vicino al prezzo di apertura della posizione e questo potrebbe essere il motivo per cui la chiamata non riesce
thanks, I only tried with the stoploss but it doesn't work
2022.08.19 14:34:05.764 2010.06.23 00:00:00 failed modify #2 sell 0.01 CORN sl: 0.00, tp: 0.00 -> sl: 368.03, tp: 0.00 [Invalid stops]
Un prezzo moltiplicato per un moltiplicatore non ha significato. TP/SL sono prezzi. Il TP deve essere al di sopra del Bid e SL al di sotto.
Non puoi spostare gli stop (o i prezzi in sospeso) più vicini al mercato del minimo: MODE_STOPLEVEL * _Point o SymbolInfoInteger(SYMBOL_TRADE_STOPS_LEVEL) .
Requisiti e Limitazioni nell'Effettuare Operazioni - Appendici - Tutorial MQL4
Su alcuni broker di tipo ECN, il valore potrebbe essere zero (il broker non lo sa). Utilizzare un minimo di due (2) PIP .
thanks I try to set only Sl in less than ASK but it doesn't work
2022.08.19 14:41:36.852 2010.06.23 00:00:00 failed modify #2 sell 0.01 CORN sl: 0.00, tp: 0.00 -> sl: 348.75, tp: 0.00 [Invalid stops]
grazie provo a impostare solo Sl in meno di ASK ma non funziona
2022.08.19 14:41:36.852 2010.06.23 00:00:00 non riuscita modifica n. 2 vendita 0.01 CORN sl: 0.00, tp: 0.00 -> sl: 348.75, tp: 0.00 [Soste non valide]
the trade stop level is
2022.08.19 14:47:29.802 2010.06.23 00:00:00 Trade stop level=100
so how much should my minimum stoploss be?
thanks, I only tried with the stoploss but it doesn't work
2022.08.19 14:34:05.764 2010.06.23 00:00:00 failed modify #2 sell 0.01 CORN sl: 0.00, tp: 0.00 -> sl: 368.03, tp: 0.00 [Invalid stops]
I see you are computing it as 1.05 * open price - you need to figure out an approach which works. Run some tests with larger numbers to get an idea.
And look at William's suggestion above
I see you are computing it as 1.05 * open price - you need to figure out an approach which works. Run some tests with larger numbers to get an idea.
And look at William's suggestion above
and I ran it as a test. Also in this case I get an invalid stops error
2022.08.19 22:55:41.834 MetaTester 5 started on 127.0.0.1:3000
2022.08.19 22:55:41.840 initialization finished
2022.08.19 22:55:42.038 login (build 3391)
2022.08.19 22:55:42.117 4412 bytes of account info loaded
2022.08.19 22:55:42.117 1478 bytes of tester parameters loaded
2022.08.19 22:55:42.117 3268 bytes of input parameters loaded
2022.08.19 22:55:42.118 6739 bytes of symbols list loaded (799 symbols)
2022.08.19 22:55:42.119 expert file added: Experts\positionpropertiesplus.ex5. 140062 bytes loaded
2022.08.19 22:55:42.131 8477 Mb available, 105 blocks set for ticks generating
2022.08.19 22:55:42.131 initial deposit 10000.00 EUR, leverage 1:1
2022.08.19 22:55:42.133 successfully initialized
2022.08.19 22:55:42.133 148 Kb of total initialization data received
2022.08.19 22:55:42.133 AMD Ryzen 5 2400G with Radeon Vega, 14243 MB
2022.08.19 22:55:42.163 connected
2022.08.19 22:55:42.164 US_500: symbol to be synchronized
2022.08.19 22:55:42.164 US_500: symbol synchronized, 4280 bytes of symbol info received
2022.08.19 22:55:42.164 US_500: history synchronization started
2022.08.19 22:55:42.169 US_500: load 27 bytes of history data to synchronize in 0:00:00.002
2022.08.19 22:55:42.169 US_500: history synchronized from 2011.01.17 to 2022.08.18
2022.08.19 22:55:42.169 US_500: start time changed to 2011.05.18 00:00 to provide data at beginning
2022.08.19 22:55:42.169 US_500,Daily: history cache allocated for 3037 bars and contains 101 bars from 2011.01.17 00:00 to 2011.05.17 00:00
2022.08.19 22:55:42.169 US_500,Daily: history begins from 2011.01.17 00:00
2022.08.19 22:55:42.169 US_500,Daily (Ava-Real 1-MT5): every tick generating
2022.08.19 22:55:42.169 testing with execution delay 20 milliseconds
2022.08.19 22:55:42.169 US_500,Daily: testing of Experts\positionpropertiesplus.ex5 from 2011.01.17 00:00 to 2022.08.18 00:00 started with inputs:
2022.08.19 22:55:42.169 NumberOfBars=2
2022.08.19 22:55:42.169 Lot=0.1
2022.08.19 22:55:42.169 StopLoss=50.0
2022.08.19 22:55:42.169 TakeProfit=100.0
2022.08.19 22:55:42.169 TrailingStop=10.0
2022.08.19 22:55:42.169 Reverse=true
2022.08.19 22:55:42.196 2011.05.18 00:00:00 CheckNewBar: Initialization [US_500][TF: D1][2011.05.17 00:00:00]
2022.08.19 22:55:43.566 2011.05.19 00:00:00 failed market buy 0.1 US_500 sl: 1338.74 tp: 1340.50 [Invalid stops]
2022.08.19 22:55:43.566 2011.05.19 00:00:00 CTrade::OrderSend: market buy 0.10 US_500 sl: 1338.74 tp: 1340.50 [invalid stops]
2022.08.19 22:55:43.566 2011.05.19 00:00:00 Error opening the position: 4756 - Failed to send the trade request
2022.08.19 22:55:43.584 2011.05.20 00:00:00 failed market buy 0.1 US_500 sl: 1340.74 tp: 1342.50 [Invalid stops]
2022.08.19 22:55:43.584 2011.05.20 00:00:00 CTrade::OrderSend: market buy 0.10 US_500 sl: 1340.74 tp: 1342.50 [invalid stops]
Could it be a broker-related problem?
I don't think anything is posted on the site that isn't working
and I ran it as a test. Also in this case I get an invalid stops error
2022.08.19 22:55:41.834 MetaTester 5 started on 127.0.0.1:3000
2022.08.19 22:55:41.840 initialization finished
2022.08.19 22:55:42.038 login (build 3391)
2022.08.19 22:55:42.117 4412 bytes of account info loaded
2022.08.19 22:55:42.117 1478 bytes of tester parameters loaded
2022.08.19 22:55:42.117 3268 bytes of input parameters loaded
2022.08.19 22:55:42.118 6739 bytes of symbols list loaded (799 symbols)
2022.08.19 22:55:42.119 expert file added: Experts\positionpropertiesplus.ex5. 140062 bytes loaded
2022.08.19 22:55:42.131 8477 Mb available, 105 blocks set for ticks generating
2022.08.19 22:55:42.131 initial deposit 10000.00 EUR, leverage 1:1
2022.08.19 22:55:42.133 successfully initialized
2022.08.19 22:55:42.133 148 Kb of total initialization data received
2022.08.19 22:55:42.133 AMD Ryzen 5 2400G with Radeon Vega, 14243 MB
2022.08.19 22:55:42.163 connected
2022.08.19 22:55:42.164 US_500: symbol to be synchronized
2022.08.19 22:55:42.164 US_500: symbol synchronized, 4280 bytes of symbol info received
2022.08.19 22:55:42.164 US_500: history synchronization started
2022.08.19 22:55:42.169 US_500: load 27 bytes of history data to synchronize in 0:00:00.002
2022.08.19 22:55:42.169 US_500: history synchronized from 2011.01.17 to 2022.08.18
2022.08.19 22:55:42.169 US_500: start time changed to 2011.05.18 00:00 to provide data at beginning
2022.08.19 22:55:42.169 US_500,Daily: history cache allocated for 3037 bars and contains 101 bars from 2011.01.17 00:00 to 2011.05.17 00:00
2022.08.19 22:55:42.169 US_500,Daily: history begins from 2011.01.17 00:00
2022.08.19 22:55:42.169 US_500,Daily (Ava-Real 1-MT5): every tick generating
2022.08.19 22:55:42.169 testing with execution delay 20 milliseconds
2022.08.19 22:55:42.169 US_500,Daily: testing of Experts\positionpropertiesplus.ex5 from 2011.01.17 00:00 to 2022.08.18 00:00 started with inputs:
2022.08.19 22:55:42.169 NumberOfBars=2
2022.08.19 22:55:42.169 Lot=0.1
2022.08.19 22:55:42.169 StopLoss=50.0
2022.08.19 22:55:42.169 TakeProfit=100.0
2022.08.19 22:55:42.169 TrailingStop=10.0
2022.08.19 22:55:42.169 Reverse=true
2022.08.19 22:55:42.196 2011.05.18 00:00:00 CheckNewBar: Initialization [US_500][TF: D1][2011.05.17 00:00:00]
2022.08.19 22:55:43.566 2011.05.19 00:00:00 failed market buy 0.1 US_500 sl: 1338.74 tp: 1340.50 [Invalid stops]
2022.08.19 22:55:43.566 2011.05.19 00:00:00 CTrade::OrderSend: market buy 0.10 US_500 sl: 1338.74 tp: 1340.50 [invalid stops]
2022.08.19 22:55:43.566 2011.05.19 00:00:00 Error opening the position: 4756 - Failed to send the trade request
2022.08.19 22:55:43.584 2011.05.20 00:00:00 failed market buy 0.1 US_500 sl: 1340.74 tp: 1342.50 [Invalid stops]
2022.08.19 22:55:43.584 2011.05.20 00:00:00 CTrade::OrderSend: market buy 0.10 US_500 sl: 1340.74 tp: 1342.50 [invalid stops]
Could it be a broker-related problem?
I don't think anything is posted on the site that isn't working
Can't say.
I suggest changing your way of computing the SL/TP - add/subtract a number of points rather than using a percentage multiplier.
Write a test script and use a demo account - keep the TP/SL setting as separate calls and create a loop with an increasing number of points. That will help you identify what the minimum must be for your scenario
Thanks Everybody,
for now I've solved with MathRound Function
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
Can someone help me?
maybe i can't normalize my ST and TP properly.
The parameters for the calculation of SL and TP are
08.19.2022 13:44: 18.049 StopLossShort = 1.05
2022.08.19 13: 44: 18.049 TakeProfitShort = 0.995
When I run the EA it gives me the following error
08.19.2022 13:44: 25.819 23.06.2010 00:00:00 market sale 0.01 CORN (350.25 / 350.50 / 350.25)
19.08.2022 13:44: 25.819 23.06.2010 00:00:00 deal n. 2 sell 0.01 CORN at 350.25 done (based on order # 2)
08.19.2022 13:44: 25.819 23.06.2010 00:00:00 operation performed [# 2 sale 0.01 CORN at 350.25]
2022.08.19 13: 44: 25.819 2010.06.23 00:00:00 executed order sell 0.01 at 350.25 [# 2 sell 0.01 CORN at 350.25]
2022.08.19 13: 44: 25.822 2010.06.23 00:00:00 retcode = 10009 Deal = 2 Order = 2
2022.08.19 13:44: 25.822 2010.06.23 00:00:00 Position: # 2 -Symbol: CORN -TipoOperazione: POSITION_TYPE_SELL -Volume: 0.01 -Price: 350.25 -sl: 0.00 -tp: 0.00 -MagicNumber: [1]
08.19.2022 13: 44: 25.822 23.06.2010 00:00:00 23.06.2010 00:00:00: Bid = 350.25 Ask = 350.5 Volume = 0
08.19.2022 13:44: 25.822 23.06.2010 00:00:00 Change Position: # 2 -Symbol: CORN -TipoOperazione: POSITION_TYPE_SELL
19.08.2022 13:44: 25.822 23.06.2010 00:00:00 failed change n. 2 rooms 0.01 CORN sl: 0.00, tp: 0.00 -> sl: 368.03, tp: 348.75 [Invalid stops]
2022.08.19 13: 44: 25.822 2010.06.23 00:00:00 OrderSend error 4756
2022.08.19 13: 44: 25.822 2010.06.23 00:00:00 retcode = 10016 Deal = 0 Order = 0
350.5 * 0.995
I have tried several scripts to set up ST and TP and this is the last one.
It seems correct to me but if there are roundings it does not work
In this example the real values would be:
TP is 350.5 * 0.995 = 348.7475
SL is 350.5 * 1.05 = 368.025
Thank you