Questions from Beginners MQL5 MT5 MetaTrader 5 - page 799
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thank you! I searched and couldn't find it...
Then the next question, let's say the step is 25, then how to arrange rounding to a number divisible by 25, maybe there is a function?
https://www.mql5.com/ru/docs/standardlibrary/tradeclasses/csymbolinfo/csymbolinfonormalizeprice
https://www.mql5.com/ru/docs/standardlibrary/tradeclasses/csymbolinfo/csymbolinfonormalizeprice
Thanks, but I'm not using the standard trade library.
No code, no comments.
Yeah, that's weird. Attached the file, but didn't check it. My bad. Now I am attaching both code and code excerpt where tester gives out a line with [Invalid stops]. I want to understand how MqlTradeRequest structure works when modifying position. In my case it's when change of stop on SAR. I can't get rid of [Invalid stops] message from the tester. RTS Splice Tool.
Yeah, that's weird. Attached the file, but didn't check it. My bad. Now I am attaching both code and excerpt from code where the tester gives out a line with [Invalid stops]. I want to understand how MqlTradeRequest structure works when modifying position. In my case it's when change of stop on SAR. I can't get rid of [Invalid stops] message from the tester. RTS Splice Tool.
This is not that code fragment where we should look for an error, at first sight. It is only triple selection of one and the same position that bothers me. It is redundant.
You have an error in incorrect stops, you should probably start your search from the place where these stops are calculated.
Yeah, that's weird. Attached the file, but didn't check it. My bad. Now I am attaching both code and code excerpt where tester gives out a line with [Invalid stops]. I want to understand how MqlTradeRequest structure works when modifying position. In my case it's when change of stop on SAR. I can't get rid of [Invalid stops] message from the tester. RTS Splice.
For full understanding it is necessary to specify what type of account hadge or netting
If the account type wasge
You have chosen a position for the symbol, but it may not be exactly what you wanted to see...
But now we choose the exact position we wanted.
Next, try again to choose the right position
Again, the probability that you have chosen the wrong position is very high
To check how the OrderSend() function behaves in this case, you should do so, but it is better to do it as it should be and if the error does not disappear, print not only the error code, but also the position ticket, the position price, the price of the new stop and take. This is the minimum.
For a full understanding you need to specify what type of account hadge or netting
Thank you for your comments. Type of account is netting. RTS Splice. Is that the tricky part? One position on one symbol. You can choose any way you like, you'll still get to that position. These are not pending orders, are they? That's why I don't understand even more - what's wrong? I tried all the variants.
Thanks for the comments. Account type netting. RTS Splice instrument. Is that the tricky part? One position on one symbol. You can choose any way you like, you'll still get to that position. These are not pending orders, are they? That's why I don't understand even more - what's wrong? I tried all the variants.
Forum on Trading, Automated Trading Systems and Strategy Tests
Questions from Beginners MQL5 MT5 MetaTrader 5
Alexey Viktorov, 2017.11.22 09:29
To check how the OrderSend() function behaves in this case, you need to do so and check, but it is better to do as it should be and if the error is not gone print not only the error code but also the position ticket, position price, price of new stop and take. This is the minimum.
That's why I don't understand even more - WHAT'S WRONG??? Tried all the options.
Insert this line where the error occurs
Print(ToString(request) + ToString(result));
Forum on trading, automated trading systems and trading strategies testing
Peculiarities of mql5 language, subtleties and tricks
fxsaber, 2017.02.25 16:27
Translating MqlTrade-structures into a string#define TOSTRING2(A) #A + " = " + EnumToString(A) + " (" + (string)(A) + ")\n"
string ToString( const MqlTradeTransaction &Trans )
{
return(TOSTRING(Trans.deal) + TOSTRING(Trans.order) + TOSTRING(Trans.symbol) +
TOSTRING2(Trans.type) + TOSTRING2(Trans.order_type) + TOSTRING2(Trans.order_state) +
TOSTRING2(Trans.deal_type) + TOSTRING2(Trans.time_type) +
TOSTRING(Trans.time_expiration) + TOSTRING(Trans.price) + TOSTRING(Trans.price_trigger) +
TOSTRING(Trans.price_sl) + TOSTRING(Trans.price_tp) + TOSTRING(Trans.volume) +
TOSTRING(Trans.position) + TOSTRING(Trans.position_by));
}
string ToString( const MqlTradeRequest &Request )
{
return(TOSTRING2(Request.action) + TOSTRING(Request.magic) + TOSTRING(Request.order) +
TOSTRING(Request.symbol) + TOSTRING(Request.volume) + TOSTRING(Request.price) +
TOSTRING(Request.stoplimit) + TOSTRING(Request.sl) + TOSTRING(Request.tp) +
TOSTRING(Request.deviation) + TOSTRING2(Request.type) + TOSTRING2(Request.type_filling) +
TOSTRING2(Request.type_time) + TOSTRING(Request.expiration) + TOSTRING(Request.comment) +
TOSTRING(Request.position) + TOSTRING(Request.position_by));
}
string ToString( const MqlTradeResult &Result )
{
return(TOSTRING(Result.retcode) + TOSTRING(Result.deal) + TOSTRING(Result.order) +
TOSTRING(Result.volume) + TOSTRING(Result.price) + TOSTRING(Result.bid) +
TOSTRING(Result.ask) + TOSTRING(Result.comment) + TOSTRING(Result.request_id) +
TOSTRING(Result.retcode_external));
}
#undef TOSTRING
#undef TOSTRING2
Insert this line where the error occurs
Pasted. Here is the result of the tester:
2017.11.22 18:22:51.127 2016.11.09 12:00:00 exchange buy 1.00 RTS Splice at 98080 sl: 94130 (98070 / 98080 / 98070)
2017.11.22 18:22:51.127 2016.11.09 12:00:00 deal #4 buy 1.00 RTS Splice at 98080 done (based on order #4)
2017.11.22 18:22:51.127 2016.11.09 12:00:00 deal performed [#4 buy 1.00 RTS Splice at 98080]
2017.11.22 18:22:51.127 2016.11.09 12:00:00 order performed buy 1.00 at 98080 [#4 buy 1.00 RTS Splice at 98080]
2017.11.22 18:22:53.561 2016.11.09 14:05:00:00 failed modify #4 buy 1.00 RTS Splice sl: 94130, tp: 0 -> sl: 94316, tp: 0 [Invalid stops]
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.action = TRADE_ACTION_SLTP (6)
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.magic = 0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.order = 0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.symbol = RTS Splice
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.volume = 0.0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.price = 0.0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.stoplimit = 0.0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.sl = 94316.0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.tp = 0.0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.deviation = 0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.type = ORDER_TYPE_BUY (0)
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.type_filling = ORDER_FILLING_FOK (0)
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.type_time = ORDER_TIME_GTC (0)
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.expiration = 1970.01.01 00:00:00
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.comment =
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.position = 4
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Request.position_by = 0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Result.retcode = 10016
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Result.deal = 0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Result.order = 0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Result.volume = 0.0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Result.price = 0.0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Result.bid = 0.0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Result.ask = 0.0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Result.comment = Invalid stops
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Result.request_id = 0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Result.retcode_external = 0
2017.11.22 18:22:53.576 2016.11.09 14:05:00 Alert: Position modification error by TP and SL error code: 4756
Put it in. Here's the result of the tester:
Server and tester mode?