how to have an EA use a manual entry as input

 
//Open Buy Order, instant signal is tested first
   RefreshRates();
   if(Cross(0,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))
      )
     {
      RefreshRates();
      price=Ask;

      if(IsTradeAllowed() && NoNewTrades==FALSE)
        {
         switch_action=1;
         
        }
     }

//Open Sell Order, instant signal is tested first
   RefreshRates();
   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))
      )
     {
      RefreshRates();
      price=Bid;

      if(IsTradeAllowed() && NoNewTrades==FALSE)
        {
         switch_action=0;
       
        }

     
     }

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.

 

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
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.
 
  1. Soewono Effendi: I would use this https://www.mql5.com/en/docs/globals
    Global variables are for interprocess communication. No need here, the iCustom is the communication.

  2. 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))
    
    1. 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;

    2. You are looking at the forming bar — you will get multiple signals as price fluctuates. Look at bar one/two.

    3. 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.
 
William Roeder:
  1. Global variables are for interprocess communication. No need here, the iCustom is the communication.

    1. You are not looking for a cross. You are looking if main > signal. Looking for a cross requires two candles and four values.

    2. You are looking at the forming bar — you will get multiple signals as price fluctuates. Look at bar one/two.

    3. 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.
This answer doesnt help in any way.

3. I did not copy and paste code
 
Soewono Effendi:

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.

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.
Reason: