Need some help with my Multi-Currency EA

 

Hello

I just programmed my first Multi-Currency EA. Its working but there are 2 thing I don't know how to use.

The first thing is to Inizialize the RSI indicator with a changeable Timeframe:

Why cant I use the Array mPeriod[s] instead of PERIOD_H1?

It gives me an compiling error "mPeriod'- can't convert enum" .

I tried some things but I didn't figured it out. 

input ENUM_TIMEFRAMES   mPeriod_01     =PERIOD_H1;
input ENUM_TIMEFRAMES   mPeriod_02     =PERIOD_H1;

int      mPeriod[NUMBER_OF_SYMBOLS];           // Period

//int OnInit()
 
for(int s=0; s<NUMBER_OF_SYMBOLS; s++)
     {
      if(Use_Symbol[s]!=false)
        {
           rsi_handle[s] = iRSI(Symbols[s],PERIOD_H1,rsi_period[s],PRICE_CLOSE);
//why not  rsi_handle[s] = iRSI(Symbols[s],mPeriod[s],rsi_period[s],PRICE_CLOSE); ??
        }
     }

And second thing:

For the rsi Price I use one array/Pair. 

double rsi_01[]; //Pair one
double rsi_02[]; //Pair two

void OnTick()
  {
   ArraySetAsSeries(rsi_01,true);
   CopyBuffer(rsi_handle[0],0,0,3,rsi_01);
   
   ArraySetAsSeries(rsi_02,true);
   CopyBuffer(rsi_handle[1],0,0,3,rsi_02);
   
   MqlTick price[NUMBER_OF_SYMBOLS];
   SymbolInfoTick(Symbols[0],price[0]);
   SymbolInfoTick(Symbols[1],price[1]);
   
   BuyCondition[0]  =(rsi_01[1]<30);
   SellCondition[0] =(rsi_01[1]>70);
   
   BuyCondition[1]  =(rsi_02[1]>70);
   SellCondition[1] =(rsi_02[1]<30);

Isn't it possible to make a 2 dimensional array so that I can use the code on the OnTick() function in an for loop like I do with the other stuff? But I don't know how to set 2 dimensional array. Can someone explain it to me?

 Thanks a lot :) 

Files:
 

1° You have to use an ENUM not an int

ENUM_TIMEFRAMES      mPeriod[NUMBER_OF_SYMBOLS];           // Period

2° You can use a struct. See this topic.

 
angevoyageur:

1° You have to use an ENUM not an int

Ah yes of course.
 
angevoyageur:

2° You can use a struct. See this topic.

Thanks a lot :)
 

I just wanted to upload the edited version with the tips from angevoyageur.

It works just like I wanted to.

Files:
 
YANND:

I just wanted to upload the edited version with the tips from angevoyageur.

It works just like I wanted to.

Hi my 

Please check below code

  if(Use_Symbol[s]!=false)
        {
         ArraySetAsSeries(rsi[s].ar,true);
         CopyBuffer(rsi_handle[s],0,0,3,rsi[s].ar);
     
         BuyCondition[s]  =(rsi[s].ar[s]<30);
// rsi[s].ar[s] ? rsi[s].ar[2]
         SellCondition[s] =(rsi[s].ar[s]>70);
       //    printf("Symbol %s %f %f %f  "
        }


 why you used rsi[s].ar[s] 

 
kourosh1347:

Hi my 

Please check below code


 why you used rsi[s].ar[s] 

Haha. I’m not really sure why. This is the first time I use such a code. 

I tried the EA on visualmode and he works like I wanted so I decided to let the code like this. 

Why is something wrong with it? I don’t understand your correction.

thx 

Reason: