Extern String List

 

I have a variable "Ord" which I use it as extern string:

extern string Ord = "BUY";


It should have only two values: "BUY" or "SELL".

How can I create a list for easyer input when EA starts?

The best would be, if it looks like extern bool variable, where we have TRUE and FALSE.

 

As extern you can use:

extern bool Ord = true;

and in the body:

string O_rd;

if(Ord)O_rd="BUY"; else O_rd="SELL";

 
Roger:

As extern you can use:

extern bool Ord = true;

and in the body:

string O_rd;

if(Ord)O_rd="BUY"; else O_rd="SELL";

Yes, this is a good idea. But anyway: is it possible to make drop down list with string not bool?

 

Unfortunately, no.

 
markog wrote >>

Yes, this is a good idea. But anyway: is it possible to make drop down list with string not bool?

The only dropdown I know of besides bool is color.

You could do this:

extern color GreenBuy_RedSell = Green;

A lot of EA's also use comments to explain what to enter like this:

extern string OrdComment = "Please enter only BUY or SELL";
extern string Ord = "BUY";

void init()
{   
   if (Ord == "BUY" || Ord == "SELL"){}
      else Alert("Please enter only BUY or SELL for ''Ord'' input");
}
 
I do not know if you still have this doubt, but it's easy. First create a new type of variable with the enum command, enumerating the options:

enum typeoftrade
   {
    BUY = 1,
    SELL = 2,
   };

Then just create a variable of the type created by the enum, in our case, "typeoftrade".

I'm going to create the "orderstype" variable as an example.

extern typeoftrade orderstype = Both;

There you will have a dropbox.

I know that you have solved the problem, but the topic is not left unresolved.

I have attached an image where I used something similar, the user chooses BUY, SELL or Both. But my EA is in Portuguese.

Files:
dropbox.PNG  18 kb
 
I agree with Cesar.
enum typeoftrade{ BUY, SELL};
extern string Ord = BUY;
 
whroeder1:
I agree with Cesar.
Old topic. Enum was not available at that time.
Reason: