I am trying to create a study Alert for the Mobius's TTM Scalper.
https://usethinkscript.com/threads/ttm_scalperalert-source-code-for-thinkorswim.914/
I would like an Alert when a new Pivot (Support/Resistance Line or High/Low Line) is plotted on the chart. I have been working on this with no results. Any and all thoughts would be greatly appreciated. Thank you in advance.
Attached below is the original code:
# Mobius
# Mobius on My Trade
# TTM Scalper Replica or High_Low_Pivots
# V001.06.2012
# jpwel added alerts 06/26/2015
input n = 8;
input ShowLines = yes;
input SoundAlerts = yes;
def h = high;
def l = low;
def Firstbar = BarNumber();
def Highest = fold i = 1
to n + 1
with p = 1
while p
do h > GetValue(h, -i);
def A = if (Firstbar > n
and h == Highest(h, n)
and Highest)
then h
else Double.NaN;
def Lowest = fold j = 1
to n + 1
with q = 1
while q
do l < GetValue(l, -j);
def B = if (Firstbar > n
and l == Lowest(l, n)
and Lowest)
then l
else Double.NaN;
rec Al = if !IsNaN(A)
then A
else Al[1];
rec Bl = if !IsNaN(B)
then B
else Bl[1];
plot ph = Round(A, 2);
ph.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
plot hL = if Al > 0
then Al
else Double.NaN;
hL.SetHiding(!ShowLines);
hL.SetPaintingStrategy(PaintingStrategy.DASHES);
hL.SetDefaultColor(Color.GREEN);
plot pl = Round(B, 2);
pl.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
plot ll = if Bl > 0
then Bl
else Double.NaN;
ll.SetHiding(!ShowLines);
ll.SetPaintingStrategy(PaintingStrategy.DASHES);
ll.SetDefaultColor(Color.RED);
# Alerts
Alert(SoundAlerts and h > al , "Up", Alert.BAR, Sound.Bell);
Alert(SoundAlerts and l < bl, "Down", Alert.BAR, Sound.Ding);
https://usethinkscript.com/threads/ttm_scalperalert-source-code-for-thinkorswim.914/
I would like an Alert when a new Pivot (Support/Resistance Line or High/Low Line) is plotted on the chart. I have been working on this with no results. Any and all thoughts would be greatly appreciated. Thank you in advance.
Attached below is the original code:
# Mobius
# Mobius on My Trade
# TTM Scalper Replica or High_Low_Pivots
# V001.06.2012
# jpwel added alerts 06/26/2015
input n = 8;
input ShowLines = yes;
input SoundAlerts = yes;
def h = high;
def l = low;
def Firstbar = BarNumber();
def Highest = fold i = 1
to n + 1
with p = 1
while p
do h > GetValue(h, -i);
def A = if (Firstbar > n
and h == Highest(h, n)
and Highest)
then h
else Double.NaN;
def Lowest = fold j = 1
to n + 1
with q = 1
while q
do l < GetValue(l, -j);
def B = if (Firstbar > n
and l == Lowest(l, n)
and Lowest)
then l
else Double.NaN;
rec Al = if !IsNaN(A)
then A
else Al[1];
rec Bl = if !IsNaN(B)
then B
else Bl[1];
plot ph = Round(A, 2);
ph.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
plot hL = if Al > 0
then Al
else Double.NaN;
hL.SetHiding(!ShowLines);
hL.SetPaintingStrategy(PaintingStrategy.DASHES);
hL.SetDefaultColor(Color.GREEN);
plot pl = Round(B, 2);
pl.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
plot ll = if Bl > 0
then Bl
else Double.NaN;
ll.SetHiding(!ShowLines);
ll.SetPaintingStrategy(PaintingStrategy.DASHES);
ll.SetDefaultColor(Color.RED);
# Alerts
Alert(SoundAlerts and h > al , "Up", Alert.BAR, Sound.Bell);
Alert(SoundAlerts and l < bl, "Down", Alert.BAR, Sound.Ding);