EA trading in the opposite direction - page 2

 
YouTrade:

Please accept my apologies. I have made a mistake.

buf1 is fast (3 for example)

buf2 is slow (5 for example) 

Hi Marcelo, note that using such small period (3 or 5), and the moving average method as an input parameter, are you sure your setup is not inverted sometimes? (SMA for fast and EMA for slow, for instance)

 
figurelli:

Hi Marcelo, note that using such small period (3 or 5), and the moving average method as an input parameter, are you sure your setup is not inverted sometimes? (SMA for fast and EMA for slow, for instance)

I do not think so ... check

int OnInit()

  {

   if(period1>period2)

     {

      iMA_handle1=iMA(my_symbol,my_timeframe,period2,0,tipo_media2,PRICE_CLOSE);

      iMA_handle2=iMA(my_symbol,my_timeframe,period1,0,tipo_media1,PRICE_CLOSE);

     }

   else

     {

      iMA_handle1=iMA(my_symbol,my_timeframe,period1,0,tipo_media1,PRICE_CLOSE);

      iMA_handle2=iMA(my_symbol,my_timeframe,period2,0,tipo_media2,PRICE_CLOSE);

     }
 
YouTrade:

I do not think so ... check

Hummm ... to be honest I don't like this solution to filter slow/fast periods and I think this is your root problem, since you are changing periods and handles ... 

 
figurelli:

Hummm ... to be honest I don't like this solution to filter slow/fast periods and I think this is your root problem, since you are changing periods and handles ... 

What do y suggest ?
 
YouTrade:

I do not think so ... check

I suggest you this approach :

   int OnInit()
     {
      ...
      iMA_fast_handle=iMA(my_symbol,my_timeframe,period_fast,0,tipo_media2,PRICE_CLOSE);
      iMA_slow_handle=iMA(my_symbol,my_timeframe,period_slow,0,tipo_media1,PRICE_CLOSE);
      
      if(period_fast>=period_slow) return(INIT_PARAMETERS_INCORRECT);

      ...
      return(INIT_SUCCEEDED);
     }
 
angevoyageur:

I suggest you this approach :

Here is ... Thank you

   if(period_fast<=period_slow)
     {
      iMA_fast_handle=iMA(my_symbol,my_timeframe,period_fast,0,tipo_media_fast,PRICE_CLOSE);
      iMA_slow_handle=iMA(my_symbol,my_timeframe,period_slow,0,tipo_media_slow,PRICE_CLOSE);
     }
   else
     {
      return(INIT_PARAMETERS_INCORRECT);
     }
 

Alain approach is nice.

I suggest you filter some method combinations too, for instance if the  fast MA method is MODE_SMA and slow MA method is MODE_EMA, to avoid new inversions of logic when periods are very near values:

...
if(tipo_media_fast==MODE_SMA && tipo_media_slow==MODE_EMA) return(INIT_PARAMETERS_INCORRECT);
...
 
figurelli:

Alain approach is nice.

I suggest you filter some method combinations too, for instance if the  fast MA method is MODE_SMA and slow MA method is MODE_EMA, to avoid new inversions of logic when periods are very near values:

Roger That !
 
YouTrade:

Here is ... Thank you

Yes it's better.
 

Hi !

Can someone please help me on this ? (figurelli it just happened ... is this what you were explaining?)

Picture 1 shows my EA MA configuration.

Fast MA is 3 Smoothed and Slow MA is 4 Exponential.

Probably because of the TYPE, Slow MA (4) crossed from bottom to top starting a SELL position (picture MMA2) instead of BUY position. As you see, the MA4 is below MA3.

How can I avoid this? Does it have any kind of specification about MA with closer values and its type?

Regards,

Marcelo

Files:
MMA1.PNG  15 kb
MMA2.png  133 kb
Reason: