How EA can read my ENUM choice?

 

Hy,

how is it possible for my Ea to read my Enum-Choice?

enum selectChoice
  {
   Banan=0,     // lolol
   Apple=1,     // lala
  };
input selectChoice WhatIlikeMost=Apple;

//later in EA..

if(WhatIlikeMost==Apple) //Do my stuff...;

// Thats how i did it, and it doesnt work...Do You know better?
 
Do not assign numerical values into the custom enum.
 
hiroshitiu: Do not assign numerical values into the custom enum.

That has nothing to do with it! You can assign numerical values or not!

 
Tim Rittel: how is it possible for my Ea to read my Enum-Choice?

Your sample code will not even compile because of the extra comma after the "Apple=1", so show your real code:

enum selectChoice
  {
   Banan=0,     // lolol
   Apple=1,     // lala
  };
input selectChoice WhatIlikeMost=Apple;

//later in EA..

if(WhatIlikeMost==Apple) //Do my stuff...;

// Thats how i did it, and it doesnt work...Do You know better?
 
Fernando Carreiro:

Your sample code will not even compile because of the extra comma after the "Apple=1", so show your real code:

enum SelectBreakevenCorePlatzhalter

  {

   LnWCorePlatzhalter,    // profitable&nonprofitable Trades

   oWCorePlatzhalter,     // only profitable Trades

   oLCorePlatzhalter,     // only nonprofitable Trades

  };

input SelectBreakevenCorePlatzhalter BreakevenCorePlatzhalter=LnWCorePlatzhalter; // which Trades to Trail?



      if(StartProfit77CorePlatzhalterBuy>RAM_Order77_CorePlatzhalter_Buy&&                                BreakevenCorePlatzhalter==oWCorePlatzhalter) 

      {RAM_Order77_CorePlatzhalter_Buy=KeinBuyStopLoss;}



      if(StartProfit77CorePlatzhalterBuy<RAM_Order77_CorePlatzhalter_Buy&&                                 BreakevenCorePlatzhalter==oLCorePlatzhalter) 

      {RAM_Order77_CorePlatzhalter_Buy=KeinBuyStopLoss;}

// Problem1 above

//+------------------------------------------------------------------+

// pProblem2 below

enum SelectHowToCorePlatzhalter

  {

   VnHCorePlatzhalter,    // Virtual&Hard Stoplosses

   oVCorePlatzhalter,     // only Virtual Stoploss 

   oHCorePlatzhalter,     // only Hard Stoploss

  };

input  SelectHowToCorePlatzhalter HowToCorePlatzhalter=VnHCorePlatzhalter;        // how to use CorePlatzhalter?



      if((GlobalVariableGet(SYmbol+" "+PEriod+" TrailOS "+DoubleToString(OrderOpenPrice(),_Digits)+" Order77 CorePlatzhalter TrailingStop Sell")-ASK)/Point>=STOPLEVEL&&  HowToCorePlatzhalter==(VnHCorePlatzhalter||oHCorePlatzhalter)   

&&GlobalVariableGet(SYmbol+" "+PEriod+" TrailOS "+DoubleToString(OrderOpenPrice(),_Digits)+" Order77 CorePlatzhalter TrailingStop Sell")!=KeinSellStopLoss)
 
Tim Rittel:

Did you even try to compile that? It will give compile errors! You did not even bother to fix it first - as I said, the extra comma:

enum SelectBreakevenCorePlatzhalter
  {
   LnWCorePlatzhalter,    // profitable&nonprofitable Trades
   oWCorePlatzhalter,     // only profitable Trades
   oLCorePlatzhalter    // only nonprofitable Trades
  };

enum SelectHowToCorePlatzhalter
  {
   VnHCorePlatzhalter,    // Virtual&Hard Stoplosses
   oVCorePlatzhalter,     // only Virtual Stoploss 
   oHCorePlatzhalter    // only Hard Stoploss
  };
 
Fernando Carreiro:

Did you even try to compile that? It will give compile errors! You did not even bother to fix it first - as I said, the extra comma:

Thank You very much for the hint with the comma, there must be still another mistake...

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
enum SelectHowToCorePlatzhalter
  {
   VnHCorePlatzhalter=0,
   oVCorePlatzhalter=1,
   oHCorePlatzhalter=2 
  };
input  SelectHowToCorePlatzhalter HowToCorePlatzhalter=VnHCorePlatzhalter;

if(HowToCorePlatzhalter==(VnHCorePlatzhalter||oVCorePlatzhalter))
{}

Problem1 above, Problem2 below, it compiles, but doent work charmingly..
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
enum SelectBreakevenCorePlatzhalter
  {
   LnWCorePlatzhalter=0,
   oWCorePlatzhalter=1, 
   oLCorePlatzhalter=2 
  };
input SelectBreakevenCorePlatzhalter BreakevenCorePlatzhalter=LnWCorePlatzhalter;

if(BreakevenCorePlatzhalter==oWCorePlatzhalter)
{}
if(BreakevenCorePlatzhalter==oLCorePlatzhalter)
{}
i fixed it afterwards, but wanted to response as fast as possible..sorry
 
Tim Rittel:

Thank You very much for the hint with the comma, there must be still another mistake...

i fixed it afterwards, but wanted to response as fast as possible..sorry

"||" is a Boolean operator so it should be used as follows:

if( ( HowToCorePlatzhalter == VnHCorePlatzhalter ) || ( HowToCorePlatzhalter == oVCorePlatzhalter ) )

As for part 2, if you set the default to "LnWCorePlatzhalter" then obviously the two tests will give false and will never be used!

Consider using a switch statement instead of multiple if statements.

 
Fernando Carreiro:

"||" is a Boolean operator so it should be used as follows:

As for part 2, if you set the default to "LnWCorePlatzhalter" then obviously the two tests will give false and will never be used!

THAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAnk You Fernando, :-) ;-) so glad you asked me for the real code.....Thank You, wow, another nut is cracked...thanks

Reason: