How can I detect RSI spikes?

Is the below code correct? How can I improve it? I need to detect RSI spikes like shown in the screenshot below (red arrow):
RSI Spikes


A = RSI(14);
Change = A - Ref(A, -1);
// Increase = 80 - 40 => +40
//Decrease  = 40 - 70 => -30

Price = GetRTData("Last");
Positive = IIf(Change>20, Price, -Price);
Negative = IIf(Change<-20, -Price, Price);

AlertIf(Positive=Price OR Negative=-Price, "SOUND C:\\Users\\pinba\\Downloads\\SELL.wav", "RSI Spike on "+FullName(), 0, 15, 1); 

How can I make it work? Please help.

Where is your TimeFrameRestore ?

I just realized I don't really know how to use the TimeFrameSet() properly. :sweat_smile:

I'll try to figure it out.

Hello Mr. Wilson,

Thanks for your reply. Is this okay?



No. Read and follow the examples, after you make the example works change it to acomplish what you want

You only need to use TimeFrame if you need to detect spikes in periods greater than the one set in the chart. For example, you are using a 5min chart but want to detect a daily RSI spike.

Whoa. Okay. I didn't know. Given that logic, I probably don't even need to use TimeFrameSet() function. I'll be working with a 5 minute chart and that's where I need the RSI spikes to be detected.

Thanks so much!

PS: I'll get back to you on this.

PPS: Is everything else okay with the code?

In this case you propably only need this (not tested)

A = RSI(14);

Change = abs(A - Ref(A, -1));
// Increase = 80 - 40 => +40
//Decrease  = 40 - 70 => -30

AlertIf(Change>20, "SOUND C:\\Users\\pinba\\Downloads\\SELL.wav", "RSI Spike on "+FullName(), 0, 15, 1); 

You can add PlotShapes when A greater than 20 so you can debug when Ami would have throw the alert

1 Like

That is so simpler. I will apply that & tell you how it goes.

Thanks for the help & suggestions!
I'm deeply grateful.

Hey, Mr. @awilson.

Just wanted to let you know that your solution has been of real help to me. Thanks a bunch!