Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1420
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
What is the correct way to use OnSetColorBackground for a CButton object? I need to colour the button from OnTick depending on the conditions. No clicking on the button is expected.
I declare and use the "colouring" function like this:
Is there an example where this is implemented in the code? I haven't found it in the library.
Hello!
Can you tell me why the script for changing stop loss does not work and gives error 4756?
At the same time, the same script for changing take profit works fine.
Hello!
Can you tell me why the script for changing stop loss doesn't work and gives error 4756?
At the same time, the same script for changing take profit works fine.
There is a good example on this topic in the manual
Structure of a trade request
SL & TP Modification
Trade order for modification of StopLoss and/or TakeProfit levels. Requires specifying 4 fields:
When modifying or closing a position in the hedging system, be sure to specify its ticket (MqlTradeRequest::position). In the netting system the ticket can also be specified, but the position is identified by the symbol name.
https://www.mql5.com/ru/docs/constants/structures/mqltraderequest
The handbook has a good example on this topic
When modifying or closing a position in a hedging system, be sure to specify its ticket (MqlTradeRequest::position). In the netting system, the ticket can also be specified, but the position is identified by the symbol name.
https://www.mql5.com/ru/docs/constants/structures/mqltraderequest
Thanks for the answer!
Reworked the script like this:
Take profit changes fine. But when trying to change the stop loss with an explicitly set value, error 4756 is generated, and in the log it is:
Take profit changes perfectly. But when trying to change the stop loss with an explicitly set value, error 4756 is generated, and in the log it is:
What is the Ask price equal to at this moment?
The position was opened at the price of 0.85098. The same story is true for other pairs, and at different distances to the stop.
It does not matter at what price the position is opened, it is the price at the moment of stop modification that matters. For a sell position, this is the Ask price.
This is forex, the current price is constantly changing, but is deliberately far away from the stop being placed.