this is strictly counting from the right correct?? if the pattern appears in the middle of the range it wont come up right?the scan i posted scan each bar for the last 12 bars to see if the scan happened at the time of that bar.
in other words if at for the past 12 bars, if at ANY TIME within the last 12 bars your scan was true it will come up on the scanner
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
i dont know what your definition of "middle" is... all i know is that the code i added per your request scans for your pattern at ANYTIME it occurred within the last 12 bars. (or as you would say, starting the count from right to left)
Condition1 = scan the last 10 bars for the pattern and make sure the current price is within 1% of the 10 period high
Condition2 = scan for the last 11 bars for the pattern and make sure the current price is within 1% of the 11 period high
Condition 3= scan the last 12 bars for the pattern and make sure the current price is within 1% of the 12 period high
Plot scan =condition1 or condition2 or condition3
looks like it came up true with your original code
def x = highest(high,10);
def x_scan_value = absValue((close - x) / x)*100;
plot Periodhigh10 = x_scan_value<1;
plot finalscan = count >0 and x_scan_value<1;
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;
I would have to start medeeling with the "VAR" to get what im trying to do right?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.
im attempting to accomplishdepends on what your attempting to accomplish. i would suggest you using trial and error and some reading if you plan on learning.
Condition1 = scan the last 10 bars for the pattern and make sure the current price is within 1% of the 10 period high
Condition2 = scan for the last 11 bars for the pattern and make sure the current price is within 1% of the 11 period high
Condition 3= scan the last 12 bars for the pattern and make sure the current price is within 1% of the 12 period high
Plot scan =condition1 or condition2 or condition3
depends on what your attempting to accomplish. i would suggest you using trial and error and some reading if you plan on learning.
def count = Sum(var, barsago);
I think I got it!! is it this?depends on what your attempting to accomplish. i would suggest you using trial and error and some reading if you plan on learning.
#true in last 10 bars
def x = highest(high,10);
def x_scan_value = absValue((close - x) / x)*100;
input barsago = 21;
def var =scan >=1;
def count = Sum(var and x_scan_value, barsago);
def finalscan = count >0;
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
T | How t o find 4th highest close in last 100 bars? | Questions | 6 | |
M | Highest of the Time Interval | Questions | 1 | |
highest closing for any prior Quarter | Questions | 1 | ||
Scan for highest volume ever In a stock? | Questions | 3 | ||
S | highest volume labels | Questions | 14 |
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.