Download MetaTrader 5

Do not want to run script on more than one chart

To add comments, please log in or register
janakpatel3210
37
janakpatel3210  

I am fed up of searching on Google and various forums. Any help w'd be greatly appreciated.

I have a script which I am attaching to any one of the open charts. I want to make sure the script does not run on two open charts. so, if someone tries to attach to another chart, it should not attach. However, if he tries to attach it to the same chart on which it was running, he can..

I tried to use global variables. here is my code in OnStart().

int i = GlobalVariableGet("MT5ETRunning");

if (i == 1)

GlobalVariableSet("SecondInst",1);

int j = GlobalVariableGet("SecondInst");

if (i == 1 && j == 1)

{

GlobalVariableSet("SecondInst",0);

return(0);

}

else

{

GlobalVariableSet("MT5ETRunning",1);

GlobalVariableSet("SecondInst",0);

}

This runs OK, but I get two issues.

1. When I try to attach it to the chart on which it was running, it removes the running script and after that if I try to attach it to same chart or any other chart, it won't atttach.

2. Even if I close and start client terminal, I am not able to attach the script to any chart.

Any pointers will be life-saver..

Thanks,

Janak

Simon Gniadkowski
Moderator
18021
Simon Gniadkowski  
janakpatel3210:

I am fed up of searching on Google and various forums. Any help w'd be greatly appreciated.

I have a script which I am attaching to any one of the open charts. I want to make sure the script does not run on two open charts. so, if someone tries to attach to another chart, it should not attach. However, if he tries to attach it to the same chart on which it was running, he can..

I tried to use global variables. here is my code in OnStart().

<REMOVED>

Do you want an answer here or here:  https://www.mql5.com/en/forum/150250  ?
Do not want to run script on more than one chart - MQL4 forum
  • www.mql5.com
Do not want to run script on more than one chart - MQL4 forum
Ubzen
5390
Ubzen  
janakpatel3210:

I am fed up of searching on Google and various forums. Any help w'd be greatly appreciated.

I have a script which I am attaching to any one of the open charts. I want to make sure the script does not run on two open charts. so, if someone tries to attach to another chart, it should not attach. However, if he tries to attach it to the same chart on which it was running, he can..

I tried to use global variables. here is my code in OnStart().

You've received three good responses in mql4_forum.

I believe that should get you started.

janakpatel3210
37
janakpatel3210  
Ubzen:

You've received three good responses in mql4_forum.

I believe that should get you started.

RaptorUK:
Do you want an answer here or here:  https://www.mql5.com/en/forum/150250  ?

This script is written in MQL5. I have posted the question in both the forums, so that if MQL5 has any additional features that may be helpful to crack my issue then that w'd be great.

 

Thanks,

Janak 

Alain Verleyen
Moderator
32810
Alain Verleyen  
janakpatel3210:

This script is written in MQL5. I have posted the question in both the forums, so that if MQL5 has any additional features that may be helpful to crack my issue then that w'd be great.

 

Thanks,

Janak 

Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.

And don't worry, there is no problem posting on both forums.
To add comments, please log in or register