Download MetaTrader 5
To add comments, please log in or register
MQL5 Cloud Network is a distributed computing network. Just give it a try!
Dominic Gilbert
1632
Dominic Gilbert 2014.10.09 12:26 

I am wanting to have a drop-down box on the parameter window of my EA that correspond to a string variable within OnInit()

// --- Global ---

enum Bias         {None = "None", H4_up = "H1 is up"};
extern string     SELECT_maBIAS_ONINIT;
extern Bias       MA_High_Bias = None;
extern Bias       MA_Middle_Bias = H1_up ;


//--------------
int OnInit()
  {
    D1_Bias = MA_High_Bias; // D1_Bias is global string
    H4_Bias = MA_Middle_Bias; // H4_Bias is global string

...

//-------------



CheckMaBias()
{
...  

// Check for Moving Averages Fanned up ON THE DAILY TIME FRAME, creating an UP bias.   
    if(D1_Bias=="None") 
      if(Daily_3>Daily_5)
         if(Daily_5>Daily_8)
            if(Daily_8>Daily_10)
               if(Daily_10>Daily_12)
                  if(Daily_12>Daily_15)
                     if(Daily_15>Daily_30)
                        if(Daily_30>Daily_35)
                           if(Daily_35>Daily_40)
                              if(Daily_40>Daily_45)
                                 if(Daily_45>Daily_50)
                                    if(Daily_50>Daily_60)
                                       {
                                       D1_Bar = iTime(NULL, high, 1); // How can I extern assign a specific datetime within OnInit() to override this?
                                       D1_Bias="Daily is Up"; // You can see here that I am wanting to override with extern via OnInit() if applicable
                                       Comment("D1 Bias is: "+D1_Bias+" since: "+TimeToStr(D1_Bar,TIME_DATE|TIME_MINUTES),
                                          "\nH4 Bias is: "+H4_Bias,
                                          "\nH1 Bias is: ",H1_Bias);
                                       }
...

 I could just use extern string and type in the exact wordings that correspond to the given function within my EA, but i'd rather have a drop down box to make 100% sure that I have not made a mistake. This is so that when I first drop my EA onto the chart I can provide it's bias accurately OnInit() and then once a new bar comes in, it'll take over and change bias if applicable.

Any ideas how I can assign an extern enum to a string?

ALSO: In alignment with these strings OnInit() that I am trying to work out above, I also want to be able to specify a specific "datetime" myself and assign it to example datetime variable above: "D1_Bar" (second code window - notes attached within it)

Dominic Gilbert
1632
Dominic Gilbert 2014.10.09 13:25  
So I come up with this:

// global 

extern string     SELECT_maBIAS_ONINIT;
extern string     MA_High_Bias;
extern datetime   D1_Bar_OnInit;
extern string     MA_Middle_Bias;
extern datetime   H4_Bar_OnInit;
extern string     MA_Low_Bias;
extern datetime   H1_Bar_OnInit;

...


int OnInit()
  {
    D1_Bias = MA_High_Bias; 
    H4_Bias = MA_Middle_Bias; 
    H1_Bias = MA_Low_Bias; 
    
    D1_Bar = D1_Bar_OnInit; 
    H4_Bar = H4_Bar_OnInit; 
    triggerBarTime = H1_Bar_OnInit; 

...

Now because I am using extern string and datetime that correspond with strings and datetimes in EA, whenever the EA wants to change variables like D1_Bias or H4_Bias or D1_Bar, the extern will just override it even though those externs are no where else to be found other than OnInit()?

 I ONLY want to use these extern variables all the while the EA finds a new replacement value for them... then I want to discard these extern variables for good? 

/
To add comments, please log in or register