Repaints Dans Arrows aka HoHo Squeeze For ThinkOrSwim

Repaints

BBDPDC

Member
9UXnzEn.png

HoHo Squeeze Indicator For ThinkOrSwim

I grabbed this from the discord group. It allowed me to enter earlier on several trades however I discard all repainting indicators generally because ultimately the rose-tinted view will catch you out eventually!
Can we make it not repaint?

Code:
declare lower;

#input paintBars = {default Off, Fast, Slow};
input showLines = Yes;
input price = close;

## HOHO INPUTS
# hint nHoMA: nHoMA is mov. avg length. \n nHo1 is 1st osc. period. \n nHo2 is 2nd osc. period. \n nHoSm is smoothing length. \n Change mov. avg  types (hoType..) to speed up/ slow down oscillators.
input nHoMA = 8;#10
input nHo1 = 17;#20
input nHo2 = 34;#50
input nHoSm = 8;#5
input hoTypeMA = AverageType.Exponential;
input hoType1 = AverageType.EXPONENTIAL;
input hoType2 = AverageType.EXPONENTIAL;
input hoTypeSM = AverageType.EXPONENTIAL;


## SQUEEZE INPUTS
# hint bbKcLength: bbKcLength is mov. avg length for \n bollinger band (BB) and keltner channel (KC). \n bbDevUp is the number of deviations for BB. \n kcFactor is the coef. for KC ATR. \n bbKcAvgType is the mov. avg type for BB and KC mid.
input bbKcLength = 20;#20
input bbDevUp = 2.0;
input kcFactor = 1.5;#1.5
input bbKcAvgType = AverageType.SIMPLE;

DefineGlobalColor("U0", Color.LIGHT_GRAY);
DefineGlobalColor("D0", Color.DARK_GRAY);
DefineGlobalColor("U1", Color.ORANGE);
DefineGlobalColor("D1", Color.PINK);
DefineGlobalColor("U2", Color.Dark_GREEN);
DefineGlobalColor("D2", Color.Dark_RED);

def sDev = StDev(price, bbKcLength);
def MA = MovingAverage(bbKcAvgType, price, bbKcLength);
def bbUB = MA + bbDevUp * sDev;
def kcUB = MA + (kcFactor * Average(TrueRange(high,  close,  low),  bbKcLength));

def squeezed = bbUB < kcUB;

plot U1;
plot D1;

plot U2;
plot D2;

def P = ((nHoMA - 1)
        * MovingAverage(hoTypeMA, price, nHoMA)[1]
        + price) / nHoMA;

def pr1 = price[(-nHo1 / 2) + 1];
def pr2 = price[(-nHo2 / 2) + 1];

def rHo1 = compoundValue(3, if !IsNaN(pr1) then
    MovingAverage(hoType1, pr1, AbsValue(nHo1))
else rHo1[1] + (rHo1[1] - rHo1[2]), price);

def rHo2 = compoundValue(3, if !IsNaN(pr2) then
    MovingAverage(hoType2, pr2, AbsValue(nHo2))
else rHo2[1] + (rHo2[1] - rHo2[2]), price);

plot Osc1 = MovingAverage(hoTypeSM, rHo1 - P, nHoSm);
Osc1.SetLineWeight(3);
Osc1.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Osc1.SetDefaultColor(Color.GREEN);
Osc1.DefineColor("U2", Color.GREEN);
Osc1.DefineColor("D2", Color.RED);
Osc1.DefineColor("U4", Color.DARK_GREEN);
Osc1.DefineColor("D4", Color.DARK_RED);
Osc1.AssignValueColor(
    if Osc1 > 0 then
        if Osc1 > Osc1[1] then Osc1.Color("U2")
        else Osc1.Color("U4")
    else if Osc1 < Osc1[1] then Osc1.Color("D2")
    else Osc1.Color("D4")
);

plot Osc2 = MovingAverage(hoTypeSM, rHo2 - P, nHoSm);
Osc2.SetLineWeight(5);
Osc2.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Osc2.SetDefaultColor(Color.MAGENTA);
Osc2.DefineColor("U1", Color.CYAN);
Osc2.DefineColor("D1", Color.MAGENTA);
Osc2.DefineColor("U3", Color.BLUE);
Osc2.DefineColor("D3", Color.PINK);
Osc2.AssignValueColor(
    if Osc2 > 0 then
        if Osc2 > Osc2[1] then Osc2.Color("U3")
        else Osc2.Color("U1")
    else if Osc2 < Osc2[1] then Osc2.Color("D3")
    else Osc2.Color("D1")
);

plot Zero = if !IsNaN(price) then 0 else Double.NaN;
Zero.DefineColor("NotSqueezed", Color.Black);
Zero.DefineColor("Squeezed", Color.RED);
Zero.AssignValueColor(if squeezed then Zero.Color("Squeezed") else Zero.Color("NotSqueezed"));
Zero.SetPaintingStrategy(PaintingStrategy.POINTS);
Zero.SetLineWeight(2);

## Check if Osc1 is crossing zero.
def cr1 = if Osc1 crosses above 0 then 1
else if Osc1 crosses below 0 then -1
else 0;

## Signal up outside squeeze.
U1 = if Osc2 > 0 and cr1 > 0 and !squeezed then 0 else Double.NaN;
U1.SetDefaultColor(Color.CYAN);
U1.SetLineWeight(2);
U1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

## Signal down outside squeeze.
D1 = if Osc2 < 0 and cr1 < 0 and !squeezed then 0 else Double.NaN;
D1.SetDefaultColor(Color.MAGENTA);
D1.SetLineWeight(1);
D1.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

## Signal up in squeeze.
U2 = if Osc2 > 0 and cr1 > 0 and squeezed then 0 else Double.NaN;
U2.SetDefaultColor(Color.UPTICK);
U2.SetLineWeight(5);
U2.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

## Signal down in squeeze.
D2 = if Osc2 < 0 and cr1 < 0 and squeezed then 0 else Double.NaN;
D2.SetDefaultColor(Color.DOWNTICK);
D2.SetLineWeight(4);
D2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

#AssignPriceColor(if paintBars == paintBars.Off then Color.CURRENT
#else if paintBars == paintBars.Fast then
#    if Osc1 > 0 then
#        if Osc2 > 0 then GlobalColor("U2")
#        else GlobalColor("U1")
#    else if Osc1 < 0 then
#        if Osc2 < 0 then GlobalColor("D2")
#        else GlobalColor("D1")
#    else GlobalColor("U0")
#else if Osc1 > 0 then GlobalColor("U2")
#else if Osc1 < 0 then GlobalColor("D2")
#else GlobalColor("U0") );

#AddVerticalLine(showLines and IsNaN(pr1[-1]) and !IsNaN(pr1), "1", Color.PLUM, 1);

#AddVerticalLine(showLines and IsNaN(pr2[-1]) and !IsNaN(pr2), "2", Color.Dark_GREEN, 2);

## END STUDY
 
Last edited by a moderator:
This is a repainting indicator. The calculations and signals are not real-time. Which means you cannot scan, watchlist, alert, create strategies or interact in anyway with these plots.

This is a repainting indicator. It uses future bars. Meaning, it waits until the future happens and then goes back and paints the triggers that you see on your charts.

Scripts that repaint can NOT be used in Scans, Labels, Watchlists, Alerts, Conditional Orders or Backtesting Strategies.
a.
It will be painted on your chart but NOT show up in your Scans, Labels, Watchlists, Alerts, Conditional Orders or Backtesting Strategies. This is because it wasn't there in real time! It was painted on afterward.
You will think the script is broken.
b. Or the opposite.
It will falsely show up in your Scans, Labels, Watchlists, Alerts, Conditional Orders or Backtesting Strategies, but the signal will not be painted on your chart. You will think the script is broken.

No, it cannot be rewritten to not repaint.

@RedToGreen @tommylala @yvenky2000
@donbashk @KRHIlls @kvnknpp1
@FSUTommy @andriod_1011
 
I didn't load this up, just reading through the code... I worry about these two lines:
Code:
def pr1 = price[(-nHo1 / 2) + 1];
def pr2 = price[(-nHo2 / 2) + 1];
since nHo1 and nHo2 are defined to be positive numbers (17 and 34), it seems that they may be trying to pull future data, since the expression (-nHo1 / 2) + 1 would seem to be negative. Unless I haven't had enough coffee yet.

also this:
Code:
AddVerticalLine(showLines and IsNaN(pr1[-1]) and !IsNaN(pr1), "1", Color.PLUM, 1);
is referencing future data and may be problematic. I see it's commented out, but future data often causes repaints.

Maybe that helps.
-mashume
 
I'm mainly trying to reflect in the WL when the oscillators are greater than or less than the previous day and maybe perhaps when an up or down arrow is plotted
ex..
def OSC1UP = osc1 > osc1[1];
def OSC1DN = osc1 < osc1[1];

I haven't been successful in setting it up correctly so far..

If anyone can help, thank you
 
Last edited by a moderator:
Too bad. The whole indicator repaints, so if you watch during market open the histogram shifts in size and position based on price action. As usual with repainting indicators, its fantastic in hindsight but pretty dangerous to a novice like me!
 
Last edited by a moderator:
Hello Team, I am trying to build a scanner to only show me results at exactly when the ArrowUp and ArrowDown Signal occurs using the below script with no luck. Will appreciate the help and guide on this. Many thanks:
 
Last edited by a moderator:
Thanks barbaros for pointing that out. any idea how I can build a scanner matching this?
I strongly recommend you don't use this indicator. You mentioned that you look for confluence between this and other indicators. Due to the nature of repainting, even if you look for confluence, and all agree, a few bars later, this indicator may not line up with your other indicators. But, you would have taken the trade back a few bars any way. Looking at it after the fact makes this indicator the holly grail but it is not.
 
Last edited by a moderator:
What are the purple and green vertical lines in this code for? Last two lines of the code. Thx
The script states that they are to mark the delineation of oscillator cycles.
It should be noted that these are painted on much later. They are not real-time. Which means you cannot scan, watchlist, alert or interact in anyway with this plot.
 
Last edited:
Hi SleepyZ, is it possible to have tick instead of 5 minutes?
Scripts utilizing Intraday aggregations cannot be used on tick charts. The tick charts x and y-axis only use data related to price and volume lots. It has no comprehension of intraday time.
Therefore, it is NOT possible for this indicator to plot based on 3min, 5min and 15 min or any other intraday aggregation while your current chart is on Tick.
LrcTHKo.png

Read: Time&Tick: https://tlc.thinkpipes.com/center/charting/charts/Aggregation-Types/tickcharts.html
 
Last edited:
Any chance somebody could help with adding alerts when the arrows trigger? For some reason, it is not working...
 
Last edited by a moderator:
mod edit:


Squeeze and trend hunter

I've been working on combining parts of my favorite indicators into one. As much as I love a million lower studies taking up space, I thought this was better. The notes in the script mention where they come from for credit to the original people.

Arrows are from Dan's Arrows. Larger arrows are for direction during a squeeze and little ones are direction when out of a squeeze. The zero line arrows repaint btw, but hasnt been a big issue for me. The crossover lines and arrows work pretty solid. I put a scan idea below. I have Dans arrows on the lower for the screen shot, so It would make more sense visually. The moving orange line is a trend line for the red and green line. I sometimes run a 21 and 55 simple moving avg on the upper to change it up. Zero line has yellow dots for 'pre-squeeze', red for regular squeeze, and purple ones telling you its about to go nuclear. I usually run a ready aim fire where the dans arrows is, but wont post it up here.

For catching bottoms and tops, I like running a scan using (not exact code here, just the idea):
Bull (stock is beaten up and the green arrow triggers on green/red line crossover)
wt1 crosses above wt2 and wt1 < over_sold_2
close below 1 standard deviation
Bear (stock was ripping up and the red arrow triggers on red/green line crossover)
wt1 crosses below wt2 and wt1 > over_bought_2
close above 1 standard deviation

Squeeze scan, I have a few but its still a WIP.

Also, I've had good luck trading on spy and s&p100 stocks with 5m, 15m, 30m and 1hr charts up. Watch the 1hr and 30m for overall trend, watch 15m when Im panicking on what the 5m is doing. Find bottoms/tops (scan idea above or just scroll through the sp100 list) and ride the direction until 1hr or 30m have the red/green lines tightening up. Don't be the last to sell and catch the knife, secure profit along the way. Been doing this setup on 0dte fridays or when I need a little excitement/chaos in my day. Hasnt failed me yet, just green days.

script-share.png


Code:
######################
#Scipt contains portions from 'perfect leading indicator', 'Dans arrows', and #'zero line squeeze dots'

# # # # # # # # # # # # # # # # # # #
#WaveTrend Oscillator script for ThinkorSwim. Came from Came LazyBear over at TradingView version that was ported from TS/MT
# also known as "The Perfect Leading Indicator."
#ported by BenTen 6/18/19
#WT_LB Short Name TV
# # # # # # # # # # # # # # # # # # #

declare lower;
input price = close;
input showLines = Yes;
input Channel_Length = 10; #10
input Average_Length = 21; #10
input over_bought_1 = 60;
input over_bought_2 = 53;
input over_sold_1 = -60;
input over_sold_2 = -53;
input show_bubbles = yes;
input show_sec_bbls = no;
input show_alerts = yes;
def ap = hlc3;
def esa = ExpAverage(ap, Channel_Length);
def d = ExpAverage(AbsValue(ap - esa), Channel_Length);
def ci = (ap - esa) / (0.015 * d);
def tci = ExpAverage(ci, Average_Length);
def wt1 = tci;
def wt2 = SimpleMovingAvg(wt1, 4);
#def zero = 0;

plot obLevel1 = over_bought_1;
obLevel1.SetDefaultColor(Color.RED);
plot osLevel1 = over_sold_1;
osLevel1.SetDefaultColor(Color.GREEN);
plot  obLevel2 = over_bought_2;
obLevel2.SetDefaultColor(Color.RED);
obLevel2.SetStyle(Curve.SHORT_DASH);
plot  osLevel2 = over_sold_2;
osLevel2.SetDefaultColor(Color.GREEN);
osLevel2.SetStyle(Curve.SHORT_DASH);

plot wt1_1 = wt1;
wt1_1.SetDefaultColor(Color.GREEN);
plot wt2_1 = wt2;
wt2_1.SetDefaultColor(Color.RED);
wt2_1.SetStyle(Curve.POINTS);
def signal1 = wt1 crosses above wt2 and wt1 < over_sold_2;
plot Signal = if signal1  then (signal1 * over_sold_2) else Double.NaN;
Signal.SetDefaultColor(Color.GREEN);
Signal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
Signal.SetLineWeight(3);
Signal.HideTitle();
def signal2 = wt1 crosses below wt2 and wt1 > over_bought_2;
plot Signal2_ = if signal2  then (signal2 * over_bought_2) else Double.NaN;
Signal2_.SetDefaultColor(Color.RED);
Signal2_.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Signal2_.SetLineWeight(3);
Signal2_.HideTitle();


# # # # # # # # # # # # # # # # # # #
#Name:             DonchianChannel
#Programmed By:    Chris Ball ([email protected]) on 10/23/08
#Posted At:        http://chartingwithchris.blogspot.com
#Description:      This is a channel system that is used frequently for trend trading.  Google the term "turtle trader" for more information.
#Modified 2020-06-10 by rad14733 to utilize AddCloud()
# # # # # # # # # # # # # # # # # # #

input length_donchian = 34;

plot upperBand = Highest(wt1_1[1], length_donchian);
plot lowerBand = Lowest(wt1_1[1],  length_donchian);
plot middleBand = (upperBand + lowerBand) / 2;

upperBand.SetDefaultColor(Color.DARK_GRAY);
lowerBand.SetDefaultColor(Color.DARK_GRAY);
middleBand.SetDefaultColor(Color.ORANGE);

AddCloud(upperBand, lowerBand, Color.DARK_GRAY, Color.WHITE);


# # # # # # # # # # # # # # # # # # # # # # # # # # #
#  ,.-~*´¨¯¨`*·~-.¸-(_Zero line squeeze dot section_)-,.-~*´¨¯¨`*·~-.¸
# # # # # # # # # # # # # # # # # # # # # # # # # # #
# Momentum coding and "squeeze" concept made popular by John Carter.
#yellow dots are pre-squeeze, red is 'regular squeeze', and purple dots are hot saucy extra extra squeeze where it's about to go nuclear

input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.SIMPLE;
input displace = 0;
def sDev = StDev(data = price[-displace], length = length);
def MidLineBB = MovingAverage(averageType, data = price[-displace], length = length);
def LowerBandBB = MidLineBB + Num_Dev_Dn * sDev;
def UpperBandBB = MidLineBB + Num_Dev_up * sDev;
input factorhigh = 1.0;
input factormid = 1.5;
input factorlow = 2.0;
input trueRangeAverageType = AverageType.SIMPLE;
def shifthigh = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def shiftMid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def shiftlow = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def average = MovingAverage(averageType, price, length);

def Avg = average[-displace];

def UpperBandKCLow = average[-displace] + shiftlow[-displace];
def LowerBandKCLow = average[-displace] - shiftlow[-displace];

def UpperBandKCMid = average[-displace] + shiftMid[-displace];
def LowerBandKCMid = average[-displace] - shiftMid[-displace];

def UpperBandKCHigh = average[-displace] + shifthigh[-displace];
def LowerBandKCHigh = average[-displace] - shifthigh[-displace];

def K = (Highest(high, length) + Lowest(low, length)) /
2 + ExpAverage(close, length);
def momo = Inertia(price - K / 2, length);

def pos         = momo >= 0;
def neg         = momo < 0;
def up         = momo >= momo[1];
def dn         = momo < momo[1];

def presqueeze      = LowerBandBB > LowerBandKCLow and UpperBandBB < UpperBandKCLow;
def originalSqueeze     = LowerBandBB > LowerBandKCMid and UpperBandBB < UpperBandKCMid;
def ExtrSqueeze     = LowerBandBB > LowerBandKCHigh and UpperBandBB < UpperBandKCHigh;

def PosUp = pos and up;
def PosDn = pos and dn;
def NegDn = neg and dn;
def NegUp = neg and up;

# # # # # # # # # # # # # # # # # # # # # # # # # # #                
#change your squeeze dot colors here
# # # # # # # # # # # # # # # # # # # # # # # # # # #

plot squeezeline = 0;
squeezeline.SetPaintingStrategy(PaintingStrategy.POINTS);
squeezeline.AssignValueColor(if ExtrSqueeze then Color.MAGENTA else if originalSqueeze  then Color.RED else if presqueeze then Color.YELLOW else Color.GRAY);

plot momentum = momo;
momentum.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
momentum.AssignValueColor( if PosUp then Color.GREEN else if PosDn then Color.DARK_GREEN else if NegDn then Color.DARK_ORANGE else if NegUp then Color.YELLOW else Color.YELLOW);

# # # # # # # # # # # # # # # # # # # # # # # # # # #
#  ,.-~*´¨¯¨`*·~-.¸-(_Arrows portion_)-,.-~*´¨¯¨`*·~-.¸
# # # # # # # # # # # # # # # # # # # # # # # # # # #

## HOHO INPUTS
# hint nHoMA: nHoMA is mov. avg length. \n nHo1 is 1st osc. period. \n nHo2 is 2nd osc. period. \n nHoSm is smoothing length. \n Change mov. avg  types (hoType..) to speed up/ slow down oscillators.
input nHoMA = 8;#10
input nHo1 = 17;#20
input nHo2 = 34;#50
input nHoSm = 8;#5
input hoTypeMA = AverageType.EXPONENTIAL;
input hoType1 = AverageType.EXPONENTIAL;
input hoType2 = AverageType.EXPONENTIAL;
input hoTypeSM = AverageType.EXPONENTIAL;

# # # # # # # # # # # # # # # # # # # # # # # # # # #
## SQUEEZE INPUTS
# hint bbKcLength: bbKcLength is mov. avg length for \n bollinger band (BB) and #keltner channel (KC). \n bbDevUp is the number of deviations for BB. \n kcFactor #is the coef. for KC ATR. \n bbKcAvgType is the mov. avg type for BB and KC mid.
# # # # # # # # # # # # # # # # # # # # # # # # # # #

input bbKcLength = 20;#20
input bbDevUp = 2.0;
input kcFactor = 1.5;#1.5
input bbKcAvgType = AverageType.SIMPLE;

def stdDev = StDev(price, bbKcLength);
def MA = MovingAverage(bbKcAvgType, price, bbKcLength);
def bbUB = MA + bbDevUp * stdDev;
def kcUB = MA + (kcFactor * Average(TrueRange(high,  close,  low),  bbKcLength));

def squeezed = bbUB < kcUB;

def P = ((nHoMA - 1)
        * MovingAverage(hoTypeMA, price, nHoMA)[1]
        + price) / nHoMA;

def pr1 = price[(-nHo1 / 2) + 1];
def pr2 = price[(-nHo2 / 2) + 1];

def rHo1 = CompoundValue(3, if !IsNaN(pr1) then
    MovingAverage(hoType1, pr1, AbsValue(nHo1))
else rHo1[1] + (rHo1[1] - rHo1[2]), price);

def rHo2 = CompoundValue(3, if !IsNaN(pr2) then
    MovingAverage(hoType2, pr2, AbsValue(nHo2))
else rHo2[1] + (rHo2[1] - rHo2[2]), price);

def Osc1 = MovingAverage(hoTypeSM, rHo1 - P, nHoSm);
def Osc2 = MovingAverage(hoTypeSM, rHo2 - P, nHoSm);

## Check if Osc1 is crossing zero.
def cr1 = if Osc1 crosses above 0 then 1
else if Osc1 crosses below 0 then -1
else 0;

# # # # # # # # # # # # # # # # # # # # # # # # # # #
#u1 and d1 suggest a trend direction, comment this section out if you only want #to do squeeze trading.
# # # # # # # # # # # # # # # # # # # # # # # # # # #
plot U1;
plot D1;

## Signal up outside squeeze.
U1 = if Osc2 > 0 and cr1 > 0 and !squeezed then 0 else Double.NaN;
U1.SetDefaultColor(Color.CYAN);
U1.SetLineWeight(2);
U1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

## Signal down outside squeeze.
D1 = if Osc2 < 0 and cr1 < 0 and !squeezed then 0 else Double.NaN;
D1.SetDefaultColor(Color.MAGENTA);
D1.SetLineWeight(1);
D1.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

# # # # # # # # # # # # # # # # # # # # # # # # # # #
#u2 and d2 suggest a direction when in a squeeze
# # # # # # # # # # # # # # # # # # # # # # # # # # #
plot U2;
plot D2;

## Signal up in squeeze.
U2 = if Osc2 > 0 and cr1 > 0 and squeezed then 0 else Double.NaN;
U2.SetDefaultColor(Color.UPTICK);
U2.SetLineWeight(5);
U2.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

## Signal down in squeeze.
D2 = if Osc2 < 0 and cr1 < 0 and squeezed then 0 else Double.NaN;
D2.SetDefaultColor(Color.DOWNTICK);
D2.SetLineWeight(5);
D2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

## The End, roll credits
##################################
Lower
https://tos.mx/tdU4zEq

Whole setup of junk
https://tos.mx/iXNJB42

Made a watchlist for it. I may change some things about it after thinking about it for a bit. I did have it setup to catch the crossover from oversold and overbought, but was missing too many signals. Had a few other ways it was setup too, but this seems like a good start.
watchlist-bottom-and-tops.png

Code:
# # # # # # # # # # # # # # # # # # #
#WaveTrend Oscillator script for ThinkorSwim. Came from Came LazyBear over at TradingView version that was ported from TS/MT
# also known as "The Perfect Leading Indicator."
#ported by BenTen 6/18/19
#WT_LB Short Name TV
# # # # # # # # # # # # # # # # # # #

declare lower;
input price = close;
input showLines = Yes;
input Channel_Length = 10; #10
input Average_Length = 21; #10
input over_bought_1 = 60;
input over_bought_2 = 53;
input over_sold_1 = -60;
input over_sold_2 = -53;
input show_bubbles = yes;
input show_sec_bbls = no;
input show_alerts = yes;
def ap = hlc3;
def esa = ExpAverage(ap, Channel_Length);
def d = ExpAverage(AbsValue(ap - esa), Channel_Length);
def ci = (ap - esa) / (0.015 * d);
def tci = ExpAverage(ci, Average_Length);
def wt1 = tci;
def wt2 = SimpleMovingAvg(wt1, 4);

#plot wt1_1 = wt1;
#wt1_1.SetDefaultColor(Color.GREEN);
# # # # # #
#plot wt2_1 = wt2;
#wt2_1.SetDefaultColor(Color.RED);
def trendingup = wt1 > wt2;
Addlabel (trendingup, "up", color.BLUE);
def trendingdown = wt1 < wt2;
Addlabel (trendingdown, "down", color.VIOLET);
# # # # # # #
def signal1 = wt1 crosses above wt2 and wt1 < over_sold_2;
plot Signal = if signal1  then (signal1 * over_sold_2) else Double.NaN;
#  # ##
def signal2 = wt1 crosses below wt2 and wt1 > over_bought_2;
plot Signal2_ = if signal2  then (signal2 * over_bought_2) else Double.NaN;
# # # ## #
def oversold = wt1 < over_sold_2;
AddLabel (oversold, "Oversold", color.red);
#  # # # #
def overbought = wt1 > over_bought_2;
AddLabel (overbought, "Overbought", color.green);

## The End, roll credits
https://tos.mx/YcNqiDe
What are the 2 green line and purple 1 line for ?
 
Last edited by a moderator:
This is a repainting indicator. The calculations and signals are not real-time. Which means you cannot scan, watchlist, alert, create strategies or interact in anyway with these plots.

This is a repainting indicator. It uses future bars. Meaning, it waits until the future happens and then goes back and paints the triggers that you see on your charts.

Scripts that repaint can NOT be used in Scans, Labels, Watchlists, Alerts, Conditional Orders or Backtesting Strategies.
a.
It will be painted on your chart but NOT show up in your Scans, Labels, Watchlists, Alerts, Conditional Orders or Backtesting Strategies. This is because it wasn't there in real time! It was painted on afterward.
You will think the script is broken.
b. Or the opposite.
It will falsely show up in your Scans, Labels, Watchlists, Alerts, Conditional Orders or Backtesting Strategies, but the signal will not be painted on your chart. You will think the script is broken.

No, it cannot be rewritten to not repaint.

@RedToGreen @tommylala @yvenky2000
@donbashk @KRHIlls @kvnknpp1
@FSUTommy @andriod_1011
 
Last edited:

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
409 Online
Create Post

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