Scanner using RSI?


Category:
0
0

Hi Pete,

Using the code below, how do I set up the scanner to alert with sound when price crosses up 50 or crosses down 50 (it must be a fresh cross though to avoid chops). Please advise.

declare lower;
input length = 14;
input price = close;
input averageType = AverageType.WILDERS;
plot rsi = RSI(length, 70, 30, price, averageType).RSI;
plot centerLine = 50;
AddCloud(rsi, centerLine, Color.GREEN, Color.RED);

Thank you.

RESOLVED
Marked as spam
Posted by (Questions: 23, Answers: 57)
Asked on July 24, 2017 6:38 am
518 views
0

You will need to describe what you mean by ”…a fresh cross.. ..to avoid chops”.

( at July 24, 2017 8:46 am)
0

Hi Pete,
Please ignore that condition. Just have the scanner script to alert with sound when price crosses up 50 or crosses down 50. Thank you!

( at July 24, 2017 9:54 am)
0
Private answer

Ok, since you are requesting a scan we’ll provide the code statements needed to get this working in the scan engine. You also say you want the scan to generate an audible alert. This requires a few extra steps on your part, as the code within the scan had no ability to generate alerts. The scan must be saved, then you set the alert to trigger based on the results of the scan output. We demonstrate how to create alerts from a custom scan in this video: https://www.hahn-tech.com/thinkorswim-overnight-range-scan-alert/

Here is the scan version of the code you posted in your question:
input length = 14;
input price = close;
input averageType = AverageType.WILDERS;
def rsi = RSI(length, 70, 30, price, averageType).RSI;
def centerLine = 50;
# use this to scan for rsi crossing above the center line
plot scan = rsi[1] < centerLine and rsi > centerLine;
# use this to scan for rsi crossing below the center line
#plot scan = rsi[1] > centerLine and rsi < centerLine;

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on July 24, 2017 11:23 am
0

Hi Pete, please check over the code below for the scan to generate an audible alert. Is it correct? Also, if I want to alert 24 hours, do I put zero (0) both into the ”alertPeriodStart” and ”alertPerioddEnd”?
input length = 14;
input price = close;
input averageType = AverageType.WILDERS;
def rsi = RSI(length, 70, 30, price, averageType).RSI;
def centerLine = 50;
def crossabovecenterline = rsi[1] < centerLine and rsi > centerLine;
def crossbelowcenterline = rsi[1] > centerLine and rsi < centerLine; input alertPeriodStart = 730; input alertPeriodEnd = 930; input minimumRange = 10; input alertOnBreak = yes; input alertOnPullBack = yes; input numberOfDays = 0; input numberOfYears = 0; def okToPlot = GetLastDay() - numberOfDays = 0 then 1 else 0; def regularSessionHours = RegularTradingStart(GetYYYYMMDD()) = GetTime(); def extendedSessionStart = regularSessionHours[1] and extendedSessionHours; def regularSessionStart = extendedSessionHours[1] and regularSessionHours; def extendedSessionHigh = CompoundValue(1, if extendedSessionStart then high else if extendedSessionHours then Max(high, extendedSessionHigh[1]) else extendedSessionHigh[1], 0); def extendedSessionLow = CompoundValue(1, if extendedSessionStart then low else if extendedSessionHours then Min(low, extendedSessionLow[1]) else extendedSessionLow[1], 0); def regularSessionHigh = CompoundValue(1, if regularSessionStart then high else if regularSessionHours then Max(high, regularSessionHigh[1]) else regularSessionHigh[1], 0); def regularSessionLow = CompoundValue(1, if regularSessionStart then low else if regularSessionHours then Min(low, regularSessionLow[1]) else regularSessionLow[1], 0); def overnightHigh = if okToPlot and regularSessionHours then extendedSessionHigh else Double.NaN; def overnightLow = if okToPlot and regularSessionHours then extendedSessionLow else Double.NaN; def overnightRange = overnightHigh - overnightLow; plot scan = if alertPeriod and overnightRange >= minimumRange * TickSize() then crossabovecenterline or crossbelowcenterline else no;

( at July 24, 2017 2:13 pm)
0

Sorry, but you have misunderstood. When I provided the link to that video I explained that it was going to show you how to create an alert from a saved custom scan. You do not need to use any of the code from that video. The only code you need is the code I provided in my previous answer to your post. The instructions for creating alerts from a saved scan begins at the 29:52 mark of that video I linked earlier.

( at July 24, 2017 2:30 pm)
0

My bad. I watched the video again at the mark you said and set up the scanner. It works now. Thank you, Pete!

( at July 24, 2017 4:10 pm)