I would use this
https://www.mql5.com/en/docs/globals
https://www.mql5.com/en/docs/globals/globalvariableget
Press F3 on MT Terminal you can set manually any global variables.
Good luck.

Documentation on MQL5: Global Variables of the Terminal
- www.mql5.com
Global variables are kept in the client terminal for 4 weeks since the last access, then they will be deleted automatically. An access to a global variable is not only setting of a new value, but reading of the global variable value, as well.
- Soewono Effendi: I would use this https://www.mql5.com/en/docs/globalsGlobal variables are for interprocess communication. No need here, the iCustom is the communication.
- marth tanaka: Right now I am using a stochastic cross over to determine my switch action.
if(Cross(1,iStochastic(NULL,PERIOD_CURRENT,34,3,3,MODE_SMA,0,MODE_MAIN,0)<iStochastic(NULL,PERIOD_CURRENT,34,3,3,MODE_SMA,0,MODE_SIGNAL,0))
- You are not looking for a cross. You are looking if main > signal. Looking for a cross requires
two candles and four values.
double aPrev = …, aCurr = …, bPrev = …, bCurr = …; bool wasUp = aPrev > bPrev, isUp = aCurr > bCurr, isCross = isUp != wasUp;
- You are looking at the forming bar — you will get multiple signals as price fluctuates. Look at bar one/two.
- Are your books one column but two feet wide? No because that is unreadable. They are 6 inches, sometimes two columns, so you can read it easily. So should be your code. I'm not going to go scrolling (or moving my eyes) back and forth trying to read it. Don't copy and paste code, write self documenting code.
- You are not looking for a cross. You are looking if main > signal. Looking for a cross requires
two candles and four values.
William Roeder:
This answer doesnt help in any way.- Global variables are for interprocess communication. No need here, the iCustom is the communication.
- You are not looking for a cross. You are looking if main > signal. Looking for a cross requires two candles and four values.
- You are looking at the forming bar — you will get multiple signals as price fluctuates. Look at bar one/two.
- Are your books one column but two feet wide? No because that is unreadable. They are 6 inches, sometimes two columns, so you can read it easily. So should be your code. I'm not going to go scrolling (or moving my eyes) back and forth trying to read it. Don't copy and paste code, write self documenting code.
3. I did not copy and paste code
Soewono Effendi:
This might work, not sure, but Ive worked with global variables before and found them ugly to use. Any other alternative way you can think of? Im
still brainstorming.
I would use this
https://www.mql5.com/en/docs/globals
https://www.mql5.com/en/docs/globals/globalvariableget
Press F3 on MT Terminal you can set manually any global variables.
Good luck.

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
Right now I am using a stochastic cross over to determine my switch action. What my EA does is that when switch_action=1, it places a buy and when switch_action=0, it places a sell. What I would like to do, instead of using stochastic cross, is to do this manually like manual trading instead of having the decision making automated. For example if I want to place a buy or a sell, switch action should go to 1 or 0 respectively. I dont want to do any order counting because it will mess things up in the rest of my code. Is there a way to automate it so that I can use an if(manual_buy) and if(manual_sell)? I was thinking about creating a gui button that if I click, it will automatically change switch action to 1 if I click the green button and switch action to 0 if I click the red button.
Im stumped, does anyone know how to do this? I know my explanation might have been hard. Please ask any questions.