Scan for certain percent moves in certain time frames


Need a little syntax help:
Just trying to find a certain percent move in a certain amount of time:

current price + up 3% is greater than price from 1 bar ago?
close + close*103 > close [1]   #going up

Is my thinking right?


New member
sort of.
the factor number should be , not 103.
if you are converting the percent to a number with , then you don't need to add close to the product.

( close * 1.03 ) > close[1]

input percent = 3;
#  divide number by 100, then add 1, to get the factor number
#  multiply the factor by the close, to get the value to test against
#  if close times a % is > prev close, then true
def iscls_higher = ((close * (1 + percent/100)) > close[1]);
addlabel(yes, "is close x% higher than prev " + iscls_higher, color.yellow);

to make your formula work, it would be
( close + ( close * 0.03 )) > close[1]

don't forget the ( ) , to make sure the formula is evaluated the way you think it should be

Similar threads