Jekkt:
Use PositionGetInteger to obtain open time of your position.
Hi all,
I want to code an EA in MQL5 which closes a position after x bars (let´s say after 6 bars or after 6 days in D1 chart) regardless of whether it's a win or a loss. Normally the position is already closed 1-5 bars after entry because of a trailing stop but sometimes not. Therefore I would need such an additional code. Is someone able to help me?
Thank you in advance.
you need to do a position select
see my code https://www.mql5.com/en/forum/10956
can be easily modified to suit your needs
Getting current date without time
- www.mql5.com
day); HistorySelect(StringToTime(CurrDate), TimeCurrent()); are there any simpler ways of getting the current date only?
Thank you both. I solved the problem with your help.
Jekkt:
Thank you both. I solved the problem with your help.
Thank you both. I solved the problem with your help.
Can you please share the lines with this specific code? I need support also.
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
Hi all,
I want to code an EA in MQL5 which closes a position after x bars (let´s say after 6 bars or after 6 days in D1 chart) regardless of whether it's a win or a loss. Normally the position is already closed 1-5 bars after entry because of a trailing stop but sometimes not. Therefore I would need such an additional code. Is someone able to help me?
Thank you in advance.