Price within percent range of 52 week low


Category:
0
0

Hello Peter,

This is a can from TOS price performance => Near_High_Lows when current price is within 3% of the 252 period low.

#Wizard text: The current price
##Wizard input: price
#Wizard text: is within
#Wizard input: choice1
#Wizard text: % of the
#Wizard input: period
#Wizard text: period
#Wizard input: choice

def price = close;
input period = 252;
input choice = {default High, Low, “High or Low”};
input choice1 = 3.0;

def hi = high;
def lo = low;

plot scan;
switch (choice) {
case High:
scan = price >= highest(hi,period)* ((100 – choice1) /100);
case Low:
scan = price <= lowest(lo,period)* ((100 + choice1) /100);
case “High or Low”:
scan = price >= highest(hi,period)* ((100 – choice1) /100) or price <= lowest(lo,period)* ((100 + choice1) /100)
;
}

Can you help me so it can scan when current price is between 3% and 30% ?

Marked as spam
Posted by (Questions: 16, Answers: 12)
Asked on July 13, 2021 11:23 am
66 views
0
Private answer

It's much easier for me to build this from scratch than try to modify the code you provided in your answer.

Here is your scan:

input lookbackBars = 251;
input upperPercentThreshold = 30.0;
input lowerPercentThreshold = 3.0;
def lowestLow = Lowest(low, lookbackBars);
def lowerThreshold = lowestLow * (1 + lowerPercentThreshold * 0.01);
def upperThreshold = lowestLow * (1 + upperPercentThreshold * 0.01);
plot scan = close > lowerThreshold and close < upperThreshold;

Marked as spam
Posted by (Questions: 39, Answers: 3713)
Answered on July 13, 2021 2:05 pm