Download MetaTrader 5

Need some help with my Multi-Currency EA

To add comments, please log in or register
Interested in MetaTrader 5 features? Learn more about them!
Yannick Deubel
13120
Yannick Deubel 2013.10.09 23:18 

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:
Alain Verleyen
Moderator
30719
Alain Verleyen 2013.10.09 23:45  

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.

Yannick Deubel
13120
Yannick Deubel 2013.10.09 23:50  
angevoyageur:

1° You have to use an ENUM not an int

Ah yes of course.
Yannick Deubel
13120
Yannick Deubel 2013.10.09 23:50  
angevoyageur:

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

Thanks a lot :)
Yannick Deubel
13120
Yannick Deubel 2013.10.10 21:04  

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

It works just like I wanted to.

Files:
Kourosh Davallou
40175
Kourosh Davallou 2013.10.11 08:49  
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] 

Yannick Deubel
13120
Yannick Deubel 2013.10.11 10:31  
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 

To add comments, please log in or register