Scan for certain percent moves in certain time frames

ezrollin

Member
VIP
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?
Code:
close + close*103 > close [1]   #going up

Is my thinking right?
 

halcyonguy

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

( close * 1.03 ) > close[1]

Code:
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

Top