Pls help me to check this code!!!

 

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;

  }

 

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;
  }
 
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?

 
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.

 
whroeder1:

Only look when a new M15 bar forms.


Dear,

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

 
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.

Reason: