Download MetaTrader 5

Pls help me to check this code!!!

To add comments, please log in or register
Jimmy_Vu
13
Jimmy_Vu  

I code a simple RSI alert,

i use M15 timeframe, if the RSI value of last bar < 40, it display box and alert sound.

I tried to code but it not work. Anyone could help me to fix it. Thanks so much!


double MIN_LEVEL = 40;

double actualRSI = iRSI(NULL, PERIOD_M15 , 9 , PRICE_LOW);


void OnTick()

  {

if (actualRSI < MIN_LEVEL)

{

Alert( "RSI Alert on "+Symbol());

Alert (actualRSI);

PlaySound("alert.wav");

}


//---

   return;

  }

honest_knave
Moderator
2293
honest_knave  

You have to update the value of actualRSI each tick.

You are also missing a parameter in your iRSI call (the last one, shift).

double MIN_LEVEL = 40;

void OnTick()
  {
   double actualRSI = iRSI(NULL, PERIOD_M15 , 9 , PRICE_LOW , 0);
   if (actualRSI < MIN_LEVEL)
     {
      Alert( "RSI Alert on "+Symbol());
      Alert (actualRSI);
      PlaySound("alert.wav");
     }
   return;
  }
Jimmy_Vu
13
Jimmy_Vu  
honest_knave:

You have to update the value of actualRSI each tick.

You are also missing a parameter in your iRSI call (the last one, shift).


Dear Honest,

Thanks so much for your comment!

But the RSI value each tick is a lot, what should we do if we need only RSI value of last bar of M15 chart?

whroeder1
16572
whroeder1  
Jimmy_Vu: what should we do if we need only RSI value of last bar of M15 chart?

Only look when a new M15 bar forms.

Jimmy_Vu
13
Jimmy_Vu  
whroeder1:

Only look when a new M15 bar forms.


Dear,

How to do that? What function I need to do that? Thanks.

whroeder1
16572
whroeder1  
Jimmy_Vu: How to do that? What function I need to do that?

You can lead a horse to water but you can't make him click.

To add comments, please log in or register