Within %

Hi,

I have this:

P1=LOWESTLOW(RANGE=ALL TIME);

P2=HIGHESTHIGH(RANGE=ALL TIME);

R1=(P2-P1)*0.5;

P1+R1

I’d like to use it in a watchlist (True/False) with the addition of “Within 2%”.
I want a “True” signal if the price is within 2% above/below the 50% line.
Your help is appreciated.

Regards,
Julius

Hi Julius,

I’ve not tested this, but it should give you some pointers on how to do this.

All the best

Mathew

P1=LOWESTLOW(RANGE=ALL TIME);

P2=HIGHESTHIGH(RANGE=ALL TIME);

R1=(P2-P1)*0.5;

// calculate the midpoint price
M1 = P1+R1;

// get the absolute value of the difference from the close
D1 = abs(Close() - M1);

// calculate the percentage 
PC1 = (D1 / M1) * 100;

// is it within 2 %
PC1 <= 2

Hi Julius,

Matt Humphreys reminded me about the WithinRange fucntion which makes this even easier.

 

P1=LOWESTLOW(RANGE=ALL TIME);
P2=HIGHESTHIGH(RANGE=ALL TIME);
R1=(P2-P1)*0.5;
RES1 = P1+R1;
WITHINRANGE(Close(),RES1, PERCENT=2.00)

 

unnamed

Thank you!