# Set Price Between a Range / Shrink Price

#### WbKiki

##### New member
VIP
How could I shrink the plotted price to always be a value between a range?

Here's what I've got:
Code:
``````def p = movingaverage(averagetype.exponential, close, 5);

def c = p - sin(p);
def c1 = c - sin(c);
plot c2 = c1 - sin(c1);``````

When price is high:

When price is low:

Essentially, when price is high the line is too accurate, when price is low it's too inaccurate. Ideally I would like to set price to be within the 40s to 60s range.

Any ideas?

Here's an ex using the same concept on a lower study:
Code:
``````declare lower;

input averagetype = averagetype.exponential;
input length = 5;

def price_avg = movingaverage(averagetype, close, length);
def st = 50*(price_avg-(lowest(price_avg)))/(highest(price_avg)-lowest(price_avg));

def p1 = (st - sin(st));
def p2 = (p1 - sin(p1));
def p3 = (p2 - sin(p2));
def p4 = (p3 - sin(p3));
def p5 = (p4 - sin(p4));
def p6 = (p5 - sin(p5));
def p7 = (p6 - sin(p6));
def p8 = (p7 - sin(p7));
def p9 = (p8 - sin(p8));

plot main = (p1+p2+p3+p4+p5+p6+p7+p8+p9)/9;
main.assignvaluecolor(color.red); main.setlineweight(1);

plot midline = (highestall(main)+lowestall(main))/2;
midline.assignvaluecolor(color.cyan); midline.setlineweight(1);``````