Closing One min trade only

 

Anyone can advise me, how should I go about closing only my 1min open trade and left my 5min trade still running using script? Is it possible to filter out?

 
georgecheng:

Anyone can advise me, how should I go about closing only my 1min open trade and left my 5min trade still running using script? Is it possible to filter out?

If they are opened manually, then you can use the comment field to label them differently (for example "M1" and "M5"). Then u can have a script close only the orders that belong to one of them according to this comment. The problem with this method is that some servers modify the comment and so this might be potentially unreliable if not done properly (the server can only rewrite the last 6 characters according to this official answer -> https://www.mql5.com/en/forum/101419).


A much more reliable solution would be to open the orders via a script that labels them using magic number (this can't be done with manual trading). A second script would then close all orders that belong to a specific magic number. Both scripts should have the properties window pop-up and allow the user to set magic number, etc.).

 
Thanks, I will try out the script using the magic number as you suggest first.
 
Any way to display the magic number in the terminal? Very difficult to view using cusor to go over one by one. Thanks
 
georgecheng:
Any way to display the magic number in the terminal? Very difficult to view using cusor to go over one by one. Thanks

U can set the comment to be the same as magic number. The comments can be seen in the Terminal (right-click and choose Comments).

 

Many thanks gordon, I finally get all things work the way i want, except, I dont' understand the excution a bit lag.


Anyway, sorry I like to ask, I seen some script with

#include <stdlib.mqh>
#include <WinUser32.mqh>

Can advise me, what does that mean.

Thanks again

 
georgecheng:

Many thanks gordon, I finally get all things work the way i want, except, I dont' understand the excution a bit lag.


Anyway, sorry I like to ask, I seen some script with

#include <stdlib.mqh>
#include <WinUser32.mqh>

Can advise me, what does that mean.

Thanks again

It means that stdlib.mqh and WinUser32.mqh files are included by the preprocessor -> https://docs.mql4.com/basis/preprosessor/include. You can open the files and c their content, they should be in in your "mt4\experts\include\" folder.

Reason: