Dear all,
Can someone help me convert the following chart indicator code into a scanner?
Thank you in advance!
# https://usethinkscript.com/threads/double-top-and-double-bottom-for-thinkorswim.11391/
# Tops \ Bottoms
# Mobius
# Modified C.Ricks 12/22/22
input Percent_A_to_C = .1;
input nP = 13;
input DisplayLabels = Yes;
def AC = Percent_A_to_C / 100;
def h = high;
def l = low;
def bar = BarNumber();
def Ps = 1 + AC;
def Ns = 1 - AC;
def hh = fold j = 1 to nP + 1
with q = 1
while q
do h > GetValue(h, -j);
def PivotH = if (bar > nP and
h == Highest(h, nP) and
hh)
then h
else Double.NaN;
def PH1 = if !isNaN(PivotH)
then h
else PH1[1];
def PH2 = if PH1 != PH1[1]
then PH1[1]
else PH2[1];
def CheckH1 = if between(PH2, PH1 * Ns, PH1 * Ps)
then 1
else 0;
plot CondH1 = HighestAll(if CheckH1
then PH2
else double.nan);
CondH1.SetDefaultColor(Color.WHITE);
plot PivotHDot = PivotH;
PivotHDot.SetDefaultColor(Color.WHITE);
PivotHDot.SetPaintingStrategy(PaintingStrategy.POINTS);
# Double Bottom
def ll = fold jl = 1 to nP + 1
with ql = 1
while ql
do l < GetValue(low, -jl);
def PivotL = if (bar > nP and
l == Lowest(l, nP) and
ll)
then l
else Double.NaN;
def PL1 = if !isNaN(PivotL)
then l
else PL1[1];
def PL2 = if PL1 != PL1[1]
then PL1[1]
else PL2[1];
def Check1 = if between(PL2, PL1 * Ns, PL1 * Ps)
then 1
else 0;
plot Cond1 = HighestAll(if Check1
then PL2
else double.nan);
Cond1.SetDefaultColor(Color.White);
plot PivotLDot = PivotL;
PivotLDot.SetDefaultColor(Color.White);
PivotLDot.SetPaintingStrategy(PaintingStrategy.POINTS);
AddChartBubble(DisplayLabels && PivotLDot, low, "DB", Color.YELLOW, yes);
AddChartBubble(DisplayLabels && PivotHDot, high, "DT", Color.WHITE, yes);
# End Code
Can someone help me convert the following chart indicator code into a scanner?
Thank you in advance!
# https://usethinkscript.com/threads/double-top-and-double-bottom-for-thinkorswim.11391/
# Tops \ Bottoms
# Mobius
# Modified C.Ricks 12/22/22
input Percent_A_to_C = .1;
input nP = 13;
input DisplayLabels = Yes;
def AC = Percent_A_to_C / 100;
def h = high;
def l = low;
def bar = BarNumber();
def Ps = 1 + AC;
def Ns = 1 - AC;
def hh = fold j = 1 to nP + 1
with q = 1
while q
do h > GetValue(h, -j);
def PivotH = if (bar > nP and
h == Highest(h, nP) and
hh)
then h
else Double.NaN;
def PH1 = if !isNaN(PivotH)
then h
else PH1[1];
def PH2 = if PH1 != PH1[1]
then PH1[1]
else PH2[1];
def CheckH1 = if between(PH2, PH1 * Ns, PH1 * Ps)
then 1
else 0;
plot CondH1 = HighestAll(if CheckH1
then PH2
else double.nan);
CondH1.SetDefaultColor(Color.WHITE);
plot PivotHDot = PivotH;
PivotHDot.SetDefaultColor(Color.WHITE);
PivotHDot.SetPaintingStrategy(PaintingStrategy.POINTS);
# Double Bottom
def ll = fold jl = 1 to nP + 1
with ql = 1
while ql
do l < GetValue(low, -jl);
def PivotL = if (bar > nP and
l == Lowest(l, nP) and
ll)
then l
else Double.NaN;
def PL1 = if !isNaN(PivotL)
then l
else PL1[1];
def PL2 = if PL1 != PL1[1]
then PL1[1]
else PL2[1];
def Check1 = if between(PL2, PL1 * Ns, PL1 * Ps)
then 1
else 0;
plot Cond1 = HighestAll(if Check1
then PL2
else double.nan);
Cond1.SetDefaultColor(Color.White);
plot PivotLDot = PivotL;
PivotLDot.SetDefaultColor(Color.White);
PivotLDot.SetPaintingStrategy(PaintingStrategy.POINTS);
AddChartBubble(DisplayLabels && PivotLDot, low, "DB", Color.YELLOW, yes);
AddChartBubble(DisplayLabels && PivotHDot, high, "DT", Color.WHITE, yes);
# End Code