Repaints Profit Taker Trail Stop Pivot Gann9 For ThinkorSwim

Repaints

bigboss

Active member
I modified the Gann9
https://usethinkscript.com/threads/gann-square-of-9-indicator-for-thinkorswim.5816/
to start at 9:20 and use target calculations, ported the Trail Stop and Take Profit indicators and their bar coloring, and added in a study by mobius called scalper pivots that gets pretty close to the pivots used in the original AFL code.

Ruby:
# PROFIT TAKER TRAIL STOP PIVOT GANN9
# ported (cobbled, hacked?!) to thinkscript by bigboss
# original by KrT Group / www.pipcharts.com
#
# Version 1.0 - 20211227 Initial port with Pivot, GANN9, and ATR components
#                        Todo: volume profile and ribbon

# JIMBERG
def EntrySignal = close > ( lowest( low, 20 ) + 2 * ATR( 10 ) );
def ExitSignal = close < ( highest( high, 20 ) - 2 * ATR( 10 ) );
AssignPriceColor(If EntrySignal then color.Blue else if ExitSignal then color.dark_Orange else color.Gray );

plot TrailStop = Highest( Close - 2 * ATR(10), 15 );
plot ProfitTaker = ExpAverage( high, 13 ) + 2 * ATR(10);
profittaker.setdefaultColor(color.lime);
trailstop.setdefaultColor(color.red);

#PIVOTS
# Mobius_Scalper_Pivots
# V01.2011
input n = 12;
#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;
def Al = if !IsNaN(A)
         then A
         else Al[1];
def Bl = if !IsNaN(B)
         then B
         else Bl[1];

plot ph = Round(A, 2);
     ph.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
     ph.SetDefaultColor(Color.RED);


plot pl = Round(B, 2);
     pl.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
     pl.SetDefaultColor(Color.GREEN);

# End Study Mobius_Scalper_Pivots

# GANN9 by bigboss
input normalizeGannToTwoDps = yes; #hint normalizeToTwoSDs: treat small values (e.g. forex, penny stocks) as if they are large values with two digits after the decimal.

# This gets the # of significant digits to round values to.
def rf = fold index = 1 to 10 with c = 1 while power(10,index)*ticksize()%1 != 0 do c+1;
def mf = if normalizeGannToTwoDps then power(10,rf-2) else 1;

def srFactor = .0005;

def rthStart = RegularTradingStart(GetYYYYMMDD());
def rthEnd = RegularTradingEnd(GetYYYYMMDD());

input Gann9StartTime = 0920;

def isupdateTime =
    if secondsTillTime(Gann9StartTime) == 0
or barnumber() == 1
then 1 else 0;

# if Show after hours is yes, then always show the lines, otherwise only between RTH

def gannprice = if isupdateTime then sqrt(open * mf) else gannprice[1];
def gannpricebase = rounddown(gannprice,0);

# Calculate the angle of price, and adjust if it is a multiple of 45 degrees so the buy/sell lines are unique.
def angle = gannprice - gannpricebase;
def angleAdjusted = if angle % .125 == 0 then angle+.001 else angle;

# Calculate the buy and sell lines, which are the nearest angle cleanly divisible by 45 above and below price.
def lowergannangle = rounddown(angleadjusted / .125,0)*.125;
def uppergannangle = roundup(angleadjusted / .125,0)*.125;
plot SellBelow = round(power(gannpricebase + lowergannangle,2)/mf,rf);
plot BuyAbove = round(power(gannpricebase + uppergannangle,2)/mf,rf);

# Calculate the next 5 resistance/targets, each in +45 degrees increments from the BuyAbove price
plot R1 = round(power(gannpricebase + uppergannangle+.125,2)*(1-srfactor)/mf,rf);
plot R2 = round(power(gannpricebase + uppergannangle+.250,2)*(1-srfactor)/mf,rf);
plot R3 = round(power(gannpricebase + uppergannangle+.375,2)*(1-srfactor)/mf,rf);
plot R4 = round(power(gannpricebase + uppergannangle+.500,2)*(1-srfactor)/mf,rf);
plot R5 = round(power(gannpricebase + uppergannangle+.625,2)*(1-srfactor)/mf,rf);
plot R6 = round(power(gannpricebase + uppergannangle+.750,2)*(1-srfactor)/mf,rf);

# Calculate the next 5 support/targets, each in -45 degree increments from the SellBelow price
plot S1 = round(power(gannpricebase + lowergannangle-.125,2)*(1+srfactor)/mf,rf);
plot S2 = round(power(gannpricebase + lowergannangle-.250,2)*(1+srfactor)/mf,rf);
plot S3 = round(power(gannpricebase + lowergannangle-.375,2)*(1+srfactor)/mf,rf);
plot S4 = round(power(gannpricebase + lowergannangle-.500,2)*(1+srfactor)/mf,rf);
plot S5 = round(power(gannpricebase + lowergannangle-.625,2)*(1+srfactor)/mf,rf);
plot S6 = round(power(gannpricebase + uppergannangle+.750,2)*(1-srfactor)/mf,rf);

SellBelow.SetDefaultColor(Color.RED);
BuyAbove.SetDefaultColor(Color.GREEN);

R1.SetDefaultColor(color.dark_gray);
R2.SetDefaultColor(color.dark_gray);
R3.SetDefaultColor(color.dark_gray);
R4.SetDefaultColor(color.dark_gray);
R5.SetDefaultColor(color.dark_gray);
R6.SetDefaultColor(color.dark_gray);

S1.SetDefaultColor(color.dark_gray);
S2.SetDefaultColor(color.dark_gray);
S3.SetDefaultColor(color.dark_gray);
S4.SetDefaultColor(color.dark_gray);
S5.SetDefaultColor(color.dark_gray);
S6.SetDefaultColor(color.dark_gray);

AddLabel(1, "Buy Above: $" + BuyAbove, color.green);
AddLabel(1, "Sell Below: $" + SellBelow, color.red);

/NQ 1 min 12/23

/NQ 5 min 12/27
 
Last edited by a moderator:
@antojoseph take a look at the following code - I modified the Gann9 to start at 9:20 and use target calculations, ported the Trail Stop and Take Profit indicators and their bar coloring, and added in a study by mobius called scalper pivots that gets pretty close to the pivots the AFL code uses.

Ruby:
# PROFIT TAKER TRAIL STOP PIVOT GANN9
# ported (cobbled, hacked?!) to thinkscript by bigboss
# original by KrT Group / www.pipcharts.com
#
# Version 1.0 - 20211227 Initial port with Pivot, GANN9, and ATR components
#                        Todo: volume profile and ribbon

# JIMBERG
def EntrySignal = close > ( lowest( low, 20 ) + 2 * ATR( 10 ) );
def ExitSignal = close < ( highest( high, 20 ) - 2 * ATR( 10 ) );
AssignPriceColor(If EntrySignal then color.Blue else if ExitSignal then color.dark_Orange else color.Gray );

plot TrailStop = Highest( Close - 2 * ATR(10), 15 );
plot ProfitTaker = ExpAverage( high, 13 ) + 2 * ATR(10);
profittaker.setdefaultColor(color.lime);
trailstop.setdefaultColor(color.red);

#PIVOTS
# Mobius_Scalper_Pivots
# V01.2011
input n = 12;
#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;
def Al = if !IsNaN(A)
         then A
         else Al[1];
def Bl = if !IsNaN(B)
         then B
         else Bl[1];

plot ph = Round(A, 2);
     ph.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
     ph.SetDefaultColor(Color.RED);


plot pl = Round(B, 2);
     pl.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
     pl.SetDefaultColor(Color.GREEN);

# End Study Mobius_Scalper_Pivots

# GANN9 by bigboss
input normalizeGannToTwoDps = yes; #hint normalizeToTwoSDs: treat small values (e.g. forex, penny stocks) as if they are large values with two digits after the decimal.

# This gets the # of significant digits to round values to.
def rf = fold index = 1 to 10 with c = 1 while power(10,index)*ticksize()%1 != 0 do c+1;
def mf = if normalizeGannToTwoDps then power(10,rf-2) else 1;

def srFactor = .0005;

def rthStart = RegularTradingStart(GetYYYYMMDD());
def rthEnd = RegularTradingEnd(GetYYYYMMDD());

input Gann9StartTime = 0920;

def isupdateTime =
    if secondsTillTime(Gann9StartTime) == 0
or barnumber() == 1
then 1 else 0;

# if Show after hours is yes, then always show the lines, otherwise only between RTH

def gannprice = if isupdateTime then sqrt(open * mf) else gannprice[1];
def gannpricebase = rounddown(gannprice,0);

# Calculate the angle of price, and adjust if it is a multiple of 45 degrees so the buy/sell lines are unique.
def angle = gannprice - gannpricebase;
def angleAdjusted = if angle % .125 == 0 then angle+.001 else angle;

# Calculate the buy and sell lines, which are the nearest angle cleanly divisible by 45 above and below price.
def lowergannangle = rounddown(angleadjusted / .125,0)*.125;
def uppergannangle = roundup(angleadjusted / .125,0)*.125;
plot SellBelow = round(power(gannpricebase + lowergannangle,2)/mf,rf);
plot BuyAbove = round(power(gannpricebase + uppergannangle,2)/mf,rf);

# Calculate the next 5 resistance/targets, each in +45 degrees increments from the BuyAbove price
plot R1 = round(power(gannpricebase + uppergannangle+.125,2)*(1-srfactor)/mf,rf);
plot R2 = round(power(gannpricebase + uppergannangle+.250,2)*(1-srfactor)/mf,rf);
plot R3 = round(power(gannpricebase + uppergannangle+.375,2)*(1-srfactor)/mf,rf);
plot R4 = round(power(gannpricebase + uppergannangle+.500,2)*(1-srfactor)/mf,rf);
plot R5 = round(power(gannpricebase + uppergannangle+.625,2)*(1-srfactor)/mf,rf);
plot R6 = round(power(gannpricebase + uppergannangle+.750,2)*(1-srfactor)/mf,rf);

# Calculate the next 5 support/targets, each in -45 degree increments from the SellBelow price
plot S1 = round(power(gannpricebase + lowergannangle-.125,2)*(1+srfactor)/mf,rf);
plot S2 = round(power(gannpricebase + lowergannangle-.250,2)*(1+srfactor)/mf,rf);
plot S3 = round(power(gannpricebase + lowergannangle-.375,2)*(1+srfactor)/mf,rf);
plot S4 = round(power(gannpricebase + lowergannangle-.500,2)*(1+srfactor)/mf,rf);
plot S5 = round(power(gannpricebase + lowergannangle-.625,2)*(1+srfactor)/mf,rf);
plot S6 = round(power(gannpricebase + uppergannangle+.750,2)*(1-srfactor)/mf,rf);

SellBelow.SetDefaultColor(Color.RED);
BuyAbove.SetDefaultColor(Color.GREEN);

R1.SetDefaultColor(color.dark_gray);
R2.SetDefaultColor(color.dark_gray);
R3.SetDefaultColor(color.dark_gray);
R4.SetDefaultColor(color.dark_gray);
R5.SetDefaultColor(color.dark_gray);
R6.SetDefaultColor(color.dark_gray);

S1.SetDefaultColor(color.dark_gray);
S2.SetDefaultColor(color.dark_gray);
S3.SetDefaultColor(color.dark_gray);
S4.SetDefaultColor(color.dark_gray);
S5.SetDefaultColor(color.dark_gray);
S6.SetDefaultColor(color.dark_gray);

AddLabel(1, "Buy Above: $" + BuyAbove, color.green);
AddLabel(1, "Sell Below: $" + SellBelow, color.red);

/NQ 1 min 12/23

/NQ 5 min 12/27
Wow, this is beautiful. Thanks a lot BigBoss!
 
@bigboss Thanks for providing your code, i loaded it. It looks dope, when I was running it today, can you let me know if those up and down arrows (ph and pl) are supposed to be real-time or is it like end of the day, it will refresh? i didn't see any arrow pop up today for the first 2.5hours, but now that I went back, i'm seeing a lot more arrows. Thanks
 
@bigboss Thanks for providing your code, i loaded it. It looks dope, when I was running it today, can you let me know if those up and down arrows (ph and pl) are supposed to be real-time or is it like end of the day, it will refresh? i didn't see any arrow pop up today for the first 2.5hours, but now that I went back, i'm seeing a lot more arrows. Thanks

The arrows lag by a certain number of bars depending on what input you put for "n". I'm not that happy with the pivot points so I'll probably change it out to use something more responsive -- there are quite a few pivot point studies around here.
 
The arrows lag by a certain number of bars depending on what input you put for "n". I'm not that happy with the pivot points so I'll probably change it out to use something more responsive -- there are quite a few pivot point studies around here.
got it; i'll play around with it, if you happen to see a better pivot set up and update the code. I'd appreciate it truly if you share it here too. thanks!
 
@antojoseph take a look at the following code - I modified the Gann9 to start at 9:20 and use target calculations, ported the Trail Stop and Take Profit indicators and their bar coloring, and added in a study by mobius called scalper pivots that gets pretty close to the pivots the AFL code uses.

Ruby:
# PROFIT TAKER TRAIL STOP PIVOT GANN9
# ported (cobbled, hacked?!) to thinkscript by bigboss
# original by KrT Group / www.pipcharts.com
#
# Version 1.0 - 20211227 Initial port with Pivot, GANN9, and ATR components
#                        Todo: volume profile and ribbon

# JIMBERG
def EntrySignal = close > ( lowest( low, 20 ) + 2 * ATR( 10 ) );
def ExitSignal = close < ( highest( high, 20 ) - 2 * ATR( 10 ) );
AssignPriceColor(If EntrySignal then color.Blue else if ExitSignal then color.dark_Orange else color.Gray );

plot TrailStop = Highest( Close - 2 * ATR(10), 15 );
plot ProfitTaker = ExpAverage( high, 13 ) + 2 * ATR(10);
profittaker.setdefaultColor(color.lime);
trailstop.setdefaultColor(color.red);

#PIVOTS
# Mobius_Scalper_Pivots
# V01.2011
input n = 12;
#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;
def Al = if !IsNaN(A)
         then A
         else Al[1];
def Bl = if !IsNaN(B)
         then B
         else Bl[1];

plot ph = Round(A, 2);
     ph.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
     ph.SetDefaultColor(Color.RED);


plot pl = Round(B, 2);
     pl.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
     pl.SetDefaultColor(Color.GREEN);

# End Study Mobius_Scalper_Pivots

# GANN9 by bigboss
input normalizeGannToTwoDps = yes; #hint normalizeToTwoSDs: treat small values (e.g. forex, penny stocks) as if they are large values with two digits after the decimal.

# This gets the # of significant digits to round values to.
def rf = fold index = 1 to 10 with c = 1 while power(10,index)*ticksize()%1 != 0 do c+1;
def mf = if normalizeGannToTwoDps then power(10,rf-2) else 1;

def srFactor = .0005;

def rthStart = RegularTradingStart(GetYYYYMMDD());
def rthEnd = RegularTradingEnd(GetYYYYMMDD());

input Gann9StartTime = 0920;

def isupdateTime =
    if secondsTillTime(Gann9StartTime) == 0
or barnumber() == 1
then 1 else 0;

# if Show after hours is yes, then always show the lines, otherwise only between RTH

def gannprice = if isupdateTime then sqrt(open * mf) else gannprice[1];
def gannpricebase = rounddown(gannprice,0);

# Calculate the angle of price, and adjust if it is a multiple of 45 degrees so the buy/sell lines are unique.
def angle = gannprice - gannpricebase;
def angleAdjusted = if angle % .125 == 0 then angle+.001 else angle;

# Calculate the buy and sell lines, which are the nearest angle cleanly divisible by 45 above and below price.
def lowergannangle = rounddown(angleadjusted / .125,0)*.125;
def uppergannangle = roundup(angleadjusted / .125,0)*.125;
plot SellBelow = round(power(gannpricebase + lowergannangle,2)/mf,rf);
plot BuyAbove = round(power(gannpricebase + uppergannangle,2)/mf,rf);

# Calculate the next 5 resistance/targets, each in +45 degrees increments from the BuyAbove price
plot R1 = round(power(gannpricebase + uppergannangle+.125,2)*(1-srfactor)/mf,rf);
plot R2 = round(power(gannpricebase + uppergannangle+.250,2)*(1-srfactor)/mf,rf);
plot R3 = round(power(gannpricebase + uppergannangle+.375,2)*(1-srfactor)/mf,rf);
plot R4 = round(power(gannpricebase + uppergannangle+.500,2)*(1-srfactor)/mf,rf);
plot R5 = round(power(gannpricebase + uppergannangle+.625,2)*(1-srfactor)/mf,rf);
plot R6 = round(power(gannpricebase + uppergannangle+.750,2)*(1-srfactor)/mf,rf);

# Calculate the next 5 support/targets, each in -45 degree increments from the SellBelow price
plot S1 = round(power(gannpricebase + lowergannangle-.125,2)*(1+srfactor)/mf,rf);
plot S2 = round(power(gannpricebase + lowergannangle-.250,2)*(1+srfactor)/mf,rf);
plot S3 = round(power(gannpricebase + lowergannangle-.375,2)*(1+srfactor)/mf,rf);
plot S4 = round(power(gannpricebase + lowergannangle-.500,2)*(1+srfactor)/mf,rf);
plot S5 = round(power(gannpricebase + lowergannangle-.625,2)*(1+srfactor)/mf,rf);
plot S6 = round(power(gannpricebase + uppergannangle+.750,2)*(1-srfactor)/mf,rf);

SellBelow.SetDefaultColor(Color.RED);
BuyAbove.SetDefaultColor(Color.GREEN);

R1.SetDefaultColor(color.dark_gray);
R2.SetDefaultColor(color.dark_gray);
R3.SetDefaultColor(color.dark_gray);
R4.SetDefaultColor(color.dark_gray);
R5.SetDefaultColor(color.dark_gray);
R6.SetDefaultColor(color.dark_gray);

S1.SetDefaultColor(color.dark_gray);
S2.SetDefaultColor(color.dark_gray);
S3.SetDefaultColor(color.dark_gray);
S4.SetDefaultColor(color.dark_gray);
S5.SetDefaultColor(color.dark_gray);
S6.SetDefaultColor(color.dark_gray);

AddLabel(1, "Buy Above: $" + BuyAbove, color.green);
AddLabel(1, "Sell Below: $" + SellBelow, color.red);

/NQ 1 min 12/23

/NQ 5 min 12/27
@bigboss hi, just chance upon this script, it looks pretty impressive on SPY, just like to know if the signal will repaint? thank u
 
@antojoseph take a look at the following code - I modified the Gann9 to start at 9:20 and use target calculations, ported the Trail Stop and Take Profit indicators and their bar coloring, and added in a study by mobius called scalper pivots that gets pretty close to the pivots the AFL code uses.

Ruby:
# PROFIT TAKER TRAIL STOP PIVOT GANN9
# ported (cobbled, hacked?!) to thinkscript by bigboss
# original by KrT Group / www.pipcharts.com
#
# Version 1.0 - 20211227 Initial port with Pivot, GANN9, and ATR components
#                        Todo: volume profile and ribbon

# JIMBERG
def EntrySignal = close > ( lowest( low, 20 ) + 2 * ATR( 10 ) );
def ExitSignal = close < ( highest( high, 20 ) - 2 * ATR( 10 ) );
AssignPriceColor(If EntrySignal then color.Blue else if ExitSignal then color.dark_Orange else color.Gray );

plot TrailStop = Highest( Close - 2 * ATR(10), 15 );
plot ProfitTaker = ExpAverage( high, 13 ) + 2 * ATR(10);
profittaker.setdefaultColor(color.lime);
trailstop.setdefaultColor(color.red);

#PIVOTS
# Mobius_Scalper_Pivots
# V01.2011
input n = 12;
#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;
def Al = if !IsNaN(A)
         then A
         else Al[1];
def Bl = if !IsNaN(B)
         then B
         else Bl[1];

plot ph = Round(A, 2);
     ph.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
     ph.SetDefaultColor(Color.RED);


plot pl = Round(B, 2);
     pl.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
     pl.SetDefaultColor(Color.GREEN);

# End Study Mobius_Scalper_Pivots

# GANN9 by bigboss
input normalizeGannToTwoDps = yes; #hint normalizeToTwoSDs: treat small values (e.g. forex, penny stocks) as if they are large values with two digits after the decimal.

# This gets the # of significant digits to round values to.
def rf = fold index = 1 to 10 with c = 1 while power(10,index)*ticksize()%1 != 0 do c+1;
def mf = if normalizeGannToTwoDps then power(10,rf-2) else 1;

def srFactor = .0005;

def rthStart = RegularTradingStart(GetYYYYMMDD());
def rthEnd = RegularTradingEnd(GetYYYYMMDD());

input Gann9StartTime = 0920;

def isupdateTime =
    if secondsTillTime(Gann9StartTime) == 0
or barnumber() == 1
then 1 else 0;

# if Show after hours is yes, then always show the lines, otherwise only between RTH

def gannprice = if isupdateTime then sqrt(open * mf) else gannprice[1];
def gannpricebase = rounddown(gannprice,0);

# Calculate the angle of price, and adjust if it is a multiple of 45 degrees so the buy/sell lines are unique.
def angle = gannprice - gannpricebase;
def angleAdjusted = if angle % .125 == 0 then angle+.001 else angle;

# Calculate the buy and sell lines, which are the nearest angle cleanly divisible by 45 above and below price.
def lowergannangle = rounddown(angleadjusted / .125,0)*.125;
def uppergannangle = roundup(angleadjusted / .125,0)*.125;
plot SellBelow = round(power(gannpricebase + lowergannangle,2)/mf,rf);
plot BuyAbove = round(power(gannpricebase + uppergannangle,2)/mf,rf);

# Calculate the next 5 resistance/targets, each in +45 degrees increments from the BuyAbove price
plot R1 = round(power(gannpricebase + uppergannangle+.125,2)*(1-srfactor)/mf,rf);
plot R2 = round(power(gannpricebase + uppergannangle+.250,2)*(1-srfactor)/mf,rf);
plot R3 = round(power(gannpricebase + uppergannangle+.375,2)*(1-srfactor)/mf,rf);
plot R4 = round(power(gannpricebase + uppergannangle+.500,2)*(1-srfactor)/mf,rf);
plot R5 = round(power(gannpricebase + uppergannangle+.625,2)*(1-srfactor)/mf,rf);
plot R6 = round(power(gannpricebase + uppergannangle+.750,2)*(1-srfactor)/mf,rf);

# Calculate the next 5 support/targets, each in -45 degree increments from the SellBelow price
plot S1 = round(power(gannpricebase + lowergannangle-.125,2)*(1+srfactor)/mf,rf);
plot S2 = round(power(gannpricebase + lowergannangle-.250,2)*(1+srfactor)/mf,rf);
plot S3 = round(power(gannpricebase + lowergannangle-.375,2)*(1+srfactor)/mf,rf);
plot S4 = round(power(gannpricebase + lowergannangle-.500,2)*(1+srfactor)/mf,rf);
plot S5 = round(power(gannpricebase + lowergannangle-.625,2)*(1+srfactor)/mf,rf);
plot S6 = round(power(gannpricebase + uppergannangle+.750,2)*(1-srfactor)/mf,rf);

SellBelow.SetDefaultColor(Color.RED);
BuyAbove.SetDefaultColor(Color.GREEN);

R1.SetDefaultColor(color.dark_gray);
R2.SetDefaultColor(color.dark_gray);
R3.SetDefaultColor(color.dark_gray);
R4.SetDefaultColor(color.dark_gray);
R5.SetDefaultColor(color.dark_gray);
R6.SetDefaultColor(color.dark_gray);

S1.SetDefaultColor(color.dark_gray);
S2.SetDefaultColor(color.dark_gray);
S3.SetDefaultColor(color.dark_gray);
S4.SetDefaultColor(color.dark_gray);
S5.SetDefaultColor(color.dark_gray);
S6.SetDefaultColor(color.dark_gray);

AddLabel(1, "Buy Above: $" + BuyAbove, color.green);
AddLabel(1, "Sell Below: $" + SellBelow, color.red);

/NQ 1 min 12/23

/NQ 5 min 12/27
I was curious. When does the does the arrows get triggered or when does the arrow actually show up. Is it after the move had already happened? Is there a way the indicator shows up 1 bar after?
 
I was curious. When does the does the arrows get triggered or when does the arrow actually show up. Is it after the move had already happened? Is there a way the indicator shows up 1 bar after?
Those arrows repaint. The arrows are painted after the fact when the low or high has been established.
This is not the traditional manner of using Mobius Trend Pivots. They are meant to be used as Support&Resistance bands not arrows.
The support or the resistance gets repainted when price breaks below / above.
Here is the original study: https://usethinkscript.com/threads/...ort-resistance-indicator-for-thinkorswim.158/
 
@jrj4774 Just my opinion - i don't think putting the Gann Osc on the upper will tell you anything more than price action is already telling you, I would use the Profit Taker Gann on the upper instead -
https://usethinkscript.com/threads/profit-taker-trail-stop-pivot-gann9-for-thinkorswim.21960/

I would not recommend the
https://usethinkscript.com/threads/profit-taker-trail-stop-pivot-gann9-for-thinkorswim.21960/
due to its use of Mobius’s scalper pivots repainting logic.

For macrostructure analysis; we now have bands, channels, ranges, Ehlers‑based levels, volatility envelopes, and structural markers that don’t repaint; Mobius’s scalper pivots naturally fall way down the priority list for macrostructure work.

Mobius’s pivots were brilliant in their time, but they were built for a very different style of trading: ultra‑short‑term tick‑chart scalping, where swings form quickly and confirmation happens fast. In that environment, repainting isn’t a big deal because the trader is reacting to micro‑bursts of structure. But in a modern macrostructure framework—the pivots are not appropriate.

The core issue is that macrostructure needs stability, not retroactive confirmation. You want levels that define the environment as it exists, not as it will be revised once future bars arrive. That’s why Ehlers levels, adaptive bands, channels, and ranges—are so powerful: they give you a real‑time map that doesn’t shift under your feet.

Here’s the hierarchy as it actually plays out for a day trader who thinks in terms of trend, rotation, and volatility:

Tool TypeStabilityForward UtilityMacro Value
Ehlers levelsExtremely highHighCore
Volatility bands/channelsHighHighCore
Ranges / session structureHighHighCore
ATR‑based trend filtersHighMediumSupportive
Gann levelsHighMediumBias‑setting
Mobius pivotsMedium‑low (during formation)LowOptional

The conclusion becomes obvious: Mobius pivots are a poor addition to provide the macrostructure when there are stronger, non‑repainting tools.

They can still add flavor—mainly as a way to visualize confirmed swing points—but they’re not foundational.
They’re not giving you anything you can’t already infer from your existing structure tools, and they certainly aren’t giving you anything predictive.

If anything, they’re more of a visual annotation than a structural tool.
Here’s the real functional comparison:

PurposeNon‑Repainting Tools (Bands, Ehlers, Ranges)Mobius Pivots
Define trend environmentExcellentWeak
Define volatility regimeExcellentNone
Define expansion vs contractionExcellentNone
Identify actionable levelsExcellentWeak
Confirm swing highs/lowsGoodGood (after confirmation)
Provide forward‑looking guidanceStrongNone
StabilityHighMedium‑low

They won’t hurt you, but they won’t meaningfully elevate your macrostructure either.

@jrj4774
 
Last edited:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
891 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top