Alert when current price is specified percent from high or low of day


0
1

Hi,

I’m trying to create a study that indicates 4% above the low of day.  Or 4% below the high of day to a specific stock.  See screenshot attached for example low of day.  LOD is 176.27 as shown in chart.  4% above it is 183.32 (176.27+(176.27*0.04)).  I’d like to have some type of indicator or an alert when the price reaches 183.32.  Please help!

Thanks,

Jon

Attachments:
Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on June 30, 2020 11:33 pm
86 views
0
Private answer

Since you asked for an indicator or an alert I chose alert and moved this out of the Chart Studies topic and into the Alerts and Notifications topic.

The way I would do this for a chart study is not the same as I would do it for a study alert or scan. So I will provide code that will work as a Study Alert or a Scan.

The following code is to be applied to any of the intraday time frames supported for Study Alerts or Scans:

input percentThreshold = 4.0;
def newDay = GetDay() <> GetDay()[1];
rec trackHigh = if newDay then high else if high > trackHigh[1] then high else trackHigh[1];
rec trackLow = if newDay then low else if low > 0 and low < trackLow[1] then low else trackLow[1];
# use this to scan for current price specified percent below the high
plot scan = close < trackHigh * (1 - percentThreshold * 0.01);
# use this to scan for current price specified percent above the low
#plot scan = close > trackLow * (1 + percentThreshold * 0.01);

Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on July 1, 2020 11:36 am