here is the code for
Current price is within 1% of the 10 period high
Code:
def x = highest(high,10);
def x_scan_value = absValue((close - x) / x)*100;
plot Periodhigh10 = x_scan_value<1;
ill let you do the rest however your example of
Condition1 = scan the last 10 bars for the pattern and make sure the current price is within 1% of the 10 period high
would be as follows
you would take the code i gave you previously and do the following:
Code:
plot finalscan = count >0 and x_scan_value<1;
for a final code of: (10 bar scan for patter and make sure price within 1% of 10 period high)
Code:
input length = 21;
input pct=3;
def corr=1+(pct/100);
def lastbar = if IsNaN(close[-1]) and !IsNaN(close) then BarNumber() else lastbar[1];
def from = (HighestAll(lastbar) - length);
def hi = if BarNumber() >= (HighestAll(lastbar) - length) and high > hi[1] then high else hi[1];
def hibar = if BarNumber() > (HighestAll(lastbar) - length) and high == hi then BarNumber() else hibar[1];
def lo = if BarNumber() > (HighestAll(hibar)) and lo[1] == 0 then low else if BarNumber() > (HighestAll(hibar)) and low < lo[1] then low else lo[1];
def fhi=if !IsNaN(close) then high[20] else fhi[1];
def con= hi/lo>=corr and lo>0 and lo>fhi ;
def scan=con;
#true in last 10 bars
input barsago = 10;
def var =scan >=1;
def count = Sum(var, barsago);
def finalscan = count >0;
def x = highest(high,10);
def x_scan_value = absValue((close - x) / x)*100;
plot Periodhigh10 = count > 0 and x_scan_value<1;
im sorry but im not going to have time for such a intricate scan, you somehow got me too far into it already, like i said this code would be time consuming, good luck.