Questions from Beginners MQL5 MT5 MetaTrader 5 - page 890
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
There is an Expert Advisor that allows you to determine when a pending order has triggered
https://www.mql5.com/ru/code/17610
I use it to get a ticket for a SELL_STOP order
I have changed the code to
Everything is fine until a certain moment. Until another order type appears in the history.
For example, SELL_LIMIT.
As soon as SELL_LIMIT appears in the history, I cannot get a ticket of the last SELL_STOP.
The Expert Advisor throws an error.
The order 9 is not pending
Although there is SELL_STOP in the history
And why do I have to do with 9th if I need the 7th ticket?
Hello. I get error ifStopLoss_=0
failed modify #2 sell 3.00 Si-9.18 sl: 0, tp: 62749 -> sl: 0, tp: 62774 [Invalid stops]
Hello. I get an error ifStopLoss_=0
failed modify #2 sell 3.00 Si-9.18 sl: 0, tp: 62749 -> sl: 0, tp: 62774 [Invalid stops]
Incorrect logic in writing the program.
When StopLoss_=0, the upper condition triggers - an attempt to modify TakeProfit. The error is that you subtract from the OPEN PRICE - in this case TakeProfit level may be higher than the CURRENT PRICE and this is an error.
In your case, subtract from the RIGHT PRICE (m_position.PriceCurrent).
A sell position was opened and selllimit was activated, I need to move the tp relative to the new price of the position, not relative to the current price.
What kind of check should I do to avoid trying to modify to an invalid price?
A sell position was opened and selllimit was activated, I need to move the tp relative to the new position price, not the current price.
What kind of check should I do to not try to modify to an invalid price?
Check:
if(m_position.PriceOpen()-ExtTakeProfit<m_position.PriceCurrent() { m_trade.PositionModify(m_position.Ticket(), m_position.StopLoss(), m_symbol.NormalizePrice(m_position.PriceOpen()-ExtTakeProfit) ); ...
Check:
Thank you, but the error remains.
Could be unacceptably close to the current price. How can I check this?
Thank you, but the error remains.
Could be unacceptably close to the current price. How do you check this?
I don't have access to an exchange, so either do it yourself or work on forex instruments. Sorry.
Added: introduce another check - for a Sell position the new TakeProfit (calculated value) must not be HIGHER or EQUAL to the current TakeProfit of the position.
I don't have access to an exchange, so either do it yourself or work on forex instruments. Sorry.
Added: introduce another check - for a Sell position the new TakeProfit (calculated value) must not be HIGHER or EQUAL to the current TakeProfit of the position.
Probably the opening price (POSITON_PRICE_OPEN) ?
Probably the opening price (POSITON_PRICE_OPEN) ?
This option was above. See the posts above. You answered in the middle of the conversation.
Does not fit, modify by ATR What other checks can be done for this error? All possible. In mt4 there isSTOPLEVEL, but here what?