How to code extern variable to choose the direction of trading in MT4 EA

 

Hello,


I would like to implement a command  in parameters to choose the direction of trading : Buy or Sell. Like in the example attached.

What type of variable is it ? Bool ?

I'm a real beginner in coding.

Thanks for your help.

Thierry

Files:
EA.jpg  25 kb
 

You need to declare an enum type like so:

enum EnumPositionType
  {
   Buy=0,
   Sell=1
  };
input EnumPositionType Positions=Buy;
 

Similar to @lippmaj's response, but I would have a "both" option.

enum ENUM_TRADE_DIRECTIONS
{
        TD_LONG,
        TD_SHORT,
        TD_BOTH
};
input ENUM_TRADE_DIRECTIONS TRADE_DIRECTIONS = TD_BOTH;


 

Great ! Thanks you for your answers. I will try that.


Thierry

Reason: