Repaints Bill Murray Indicator: Intraday for ThinkOrSwim

Repaints

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

Code:
declare lower;

def data = if close > close[1] then close - Min(close[1], low) else if close < close[1] then close - Max(close[1], high) else 0;

plot AccDist = TotalSum(data);
AccDist.SetDefaultColor(GetColor(1));
 
def price = accdist;

input deviations = 1.68;
input fullRange = Yes;
input length = 20;

input widthOfChannel = 80.0;

plot MiddleLR;
if (fullRange)
then {
    MiddleLR = InertiaAll(price);
} else {
    MiddleLR = InertiaAll(price, length);
}

def dist = HighestAll(AbsValue(MiddleLR - price)) * (widthOfChannel / 100.0);

plot UpperLR = MiddleLR + dist;
plot LowerLR = MiddleLR - dist;
may i ask to see how we can get assignbackgroundcolor when the accdist is greater then upperlr or below lowerlr thanks
 
may i ask to see how we can get assignbackgroundcolor when the accdist is greater then upperlr or below lowerlr thanks

Ruby:
declare lower;

def data = if close > close[1] then close - Min(close[1], low) else if close < close[1] then close - Max(close[1], high) else 0;

plot AccDist = TotalSum(data);
AccDist.SetDefaultColor(GetColor(1));
 
def price = accdist;

input deviations = 1.68;
input fullRange = Yes;
input length = 20;

input widthOfChannel = 80.0;

plot MiddleLR;
if (fullRange)
then {
    MiddleLR = InertiaAll(price);
} else {
    MiddleLR = InertiaAll(price, length);
}

def dist = HighestAll(AbsValue(MiddleLR - price)) * (widthOfChannel / 100.0);

plot UpperLR = MiddleLR + dist;
plot LowerLR = MiddleLR - dist;

DefineGlobalColor("Bottom", CreateColor(0, 75, 100));
DefineGlobalColor("Top", CreateColor(80, 50, 0));
input paintBackground = yes;
AssignBackgroundColor(if paintBackground and accdist > upperlr then GlobalColor("Top") else
if paintBackground and accdist < lowerlr then GlobalColor("Bottom") else color.current );
 
Last edited:
Not to take anything away from what @horserider put together, but here's an alternative. It WILL keep itself pegged if higher highs continue to be made. It will drop from 1 when the price is no longer making a higher high. Same goes for Lower Lows. This is because I chose to normalize the data over the range of 0 to 1. If you make a higher high, it's still 1 and everything before gets compressed.

I did not take time to put inputs on this. everything is hard coded. Feel free to adapt as you see fit.

Of course, I'm not party to the VIP chat, but just combining two indicators can be done this way.

Code:
declare lower;

def data = if close > close[1] then close - Min(close[1], low) else if close < close[1] then close - Max(close[1], high) else 0;

def AD = TotalSum(data);
plot AccDist = (AD - lowestall(AD)) /(highestall(AD) - lowestall(AD));
AccDist.SetDefaultColor(GetColor(1));

def stoch = StochasticSlow("over bought" = 100, "over sold" = 0, "k period" = 14, "d period" = 1).SlowD;

plot SlowD =  (stoch - lowestall(stoch)) /(highestall(stoch) - lowestall(stoch));

plot one = 1;
plot zero = 0;

Happy Trading
-mashume
Any way to use candles on this rather then the accdist?
 
depending on how you want to go about it change either this:
Code:
def AD = CLOSE;
plot AccDist = (AD - lowestall(AD)) /(highestall(AD) - lowestall(AD));
or this:
Code:
def AD = TotalSum(data);
plot AccDist = (OPEN - lowestall(CLOSE)) /(highestall(HIGH) - lowestall(LOW));
or some other change that makes us not use the TotalSum(data) as the main thing going forward.

-mashume
 
Hello all! I have come across a script
https://usethinkscript.com/threads/...nting-signal-for-thinkorswim.1981/#post-18808
that works well for me and my trading style. I only think this script could be improved by adding an uparrow when both the "AccDist" and the "SlowD" lines are equal to zero at the same time. I am by no means a coder and have not got the slightest clue on where to start to input an uparrow. Is there anyone who can help with this? Thank you all so much in advance. Below is the script:

Code:
declare lower;



def data = if close > close[1] then close - Min(close[1], low) else if close < close[1] then close - Max(close[1], high) else 0;



def AD = TotalSum(data);

plot AccDist = (AD - lowestall(AD)) /(highestall(AD) - lowestall(AD));

AccDist.SetDefaultColor(GetColor(1));



def stoch = StochasticSlow("over bought" = 100, "over sold" = 0, "k period" = 14, "d period" = 1).SlowD;



plot SlowD =  (stoch - lowestall(stoch)) /(highestall(stoch) - lowestall(stoch));



plot one = 1;

plot zero = 0;
 
Last edited by a moderator:
@Freddie_CM

Had to also round down your plots to 2 decimal places as you rarely get absolute zero.


Ruby:
declare lower;

def data = if close > close[1] then close - Min(close[1], low) else if close < close[1] then close - Max(close[1], high) else 0;

def AD = TotalSum(data);
def stoch = StochasticSlow("over bought" = 100, "over sold" = 0, "k period" = 14, "d period" = 1).SlowD;

plot AccDist = RoundDown((AD - lowestall(AD)) /(highestall(AD) - lowestall(AD)),2);
AccDist.SetDefaultColor(GetColor(1));

plot SlowD =  RoundDown((stoch - lowestall(stoch)) /(highestall(stoch) - lowestall(stoch)),2);;

plot one = 1;
plot zero = 0;

plot BothZero = if !AccDist and !SlowD then 0 else double.nan;
BothZero.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
 
Code:
declare lower;

def data = if close > close[1] then close - Min(close[1], low) else if close < close[1] then close - Max(close[1], high) else 0;

plot AccDist = TotalSum(data);
AccDist.SetDefaultColor(GetColor(1));
 
def price = accdist;

input deviations = 1.68;
input fullRange = Yes;
input length = 20;

input widthOfChannel = 80.0;

plot MiddleLR;
if (fullRange)
then {
    MiddleLR = InertiaAll(price);
} else {
    MiddleLR = InertiaAll(price, length);
}

def dist = HighestAll(AbsValue(MiddleLR - price)) * (widthOfChannel / 100.0);

plot UpperLR = MiddleLR + dist;
plot LowerLR = MiddleLR - dist;
Is there any way possible to add a couple other deviation lines to this or mtf this indicator i know it repaints ; however if another deviation may be an area to add too @samer800 . Also knowing it repaints is there any human possibility not to make it repaint? i was in deafdaytrader's discord room and this guy . may he rest in peace now . made a living doing SPX puts and calls from this setup . Thank you in advance
 
Is there any way possible to add a couple other deviation lines to this or mtf this indicator i know it repaints ; however if another deviation may be an area to add too @samer800 . Also knowing it repaints is there any human possibility not to make it repaint? i was in deafdaytrader's discord room and this guy . may he rest in peace now . made a living doing SPX puts and calls from this setup . Thank you in advance
check the below for MTF

CSS:
declare lower;

input useChartTimeframe = {default "Yes", "No"};
input ManualTimeframe   = AggregationPeriod.FIFTEEN_MIN;   # "Resolution"
input smoothing = yes;
input source = FundamentalType.CLOSE;
input deviations1 = 0.236;
input deviations2 = 0.500;
input fullRange = Yes;
input length = 200;
input widthOfChannel = 80.0;

def tfSrc = Fundamental(FundamentalType = source);
def tfH  = high;
def tfL  = low;
def mtfSrc = Fundamental(FundamentalType = source, Period = ManualTimeframe);
def mtfH = high(Period = ManualTimeframe);
def mtfL = low(Period = ManualTimeframe);

def c;
def h;
def l;
switch (useChartTimeframe) {
case "No":
    c = mtfSrc;
    h = mtfH;
    l = mtfL;
Default :
    c = tfSrc;
    h = tfH;
    l = tfL;
}
def data = if c > c[1] then c - Min(c[1], l) else
           if c < c[1] then c - Max(c[1], h) else 0;
def src = data;
def smoothPrice = EhlersSuperSmootherFilter(src);
def price = if smoothing then smoothPrice else src;
 
plot AccDist;

plot MiddleLR;
if (fullRange)
then {
    AccDist  = TotalSum(price);
    MiddleLR = InertiaAll(AccDist);
} else {
    AccDist  = sum(price, length);
    MiddleLR = InertiaAll(AccDist);#, length);
}

def dist = HighestAll(AbsValue(MiddleLR - AccDist)) * (widthOfChannel / 100.0);


plot UpperLR1 = MiddleLR + dist;
plot LowerLR1 = MiddleLR - dist;

plot UpperLR2 = MiddleLR + dist * deviations1;
plot LowerLR2 = MiddleLR - dist * deviations1;

plot UpperLR3 = MiddleLR + dist * deviations2;
plot LowerLR3 = MiddleLR - dist * deviations2;

AccDist.SetLineWeight(2);
AccDist.SetDefaultColor(GetColor(1));

MiddleLR.SetStyle(Curve.SHORT_DASH);
MiddleLR.SetDefaultColor(Color.GRAY);

UpperLR1.SetDefaultColor(Color.GREEN);
LowerLR1.SetDefaultColor(Color.RED);

UpperLR2.SetDefaultColor(Color.DARK_GREEN);
LowerLR2.SetDefaultColor(Color.DARK_RED);

UpperLR3.SetDefaultColor(Color.DARK_GREEN);
LowerLR3.SetDefaultColor(Color.DARK_RED);

#-- END of CODE
 
Also knowing it repaints is there any human possibility not to make it repaint?
This is a prolific repainting indicator. The logic in this study is written to continuously trigger false signals until it goes back and finally repaints the one good signal.
Because the code is dependent on the repainting, the answer is no. It can't be written to not repaint.
read more: https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/

Also, it should be noted that using the default of fullRange = yes (chosen in the input settings), the results will be wildly discrepant depending on the total number of bars on your chart.

But even if you turn off fullRange, the results will vary based on your chart length; as it is still dependent on the logic that looks for the HighestAll bar; which is based on viewable bars.

Finally, it's important to note that the study no longer updates in real time.
The functions within this script significantly consume system resources. To conserve resources and optimize performance, Schwab has decided to limit these functions update frequency to once per bar.
Read more: https://usethinkscript.com/threads/...in-real-time-in-thinkorswim.8794/#post-116082
 
Last edited:
check the below for MTF

CSS:
declare lower;

input useChartTimeframe = {default "Yes", "No"};
input ManualTimeframe   = AggregationPeriod.FIFTEEN_MIN;   # "Resolution"
input smoothing = yes;
input source = FundamentalType.CLOSE;
input deviations1 = 0.236;
input deviations2 = 0.500;
input fullRange = Yes;
input length = 200;
input widthOfChannel = 80.0;

def tfSrc = Fundamental(FundamentalType = source);
def tfH  = high;
def tfL  = low;
def mtfSrc = Fundamental(FundamentalType = source, Period = ManualTimeframe);
def mtfH = high(Period = ManualTimeframe);
def mtfL = low(Period = ManualTimeframe);

def c;
def h;
def l;
switch (useChartTimeframe) {
case "No":
    c = mtfSrc;
    h = mtfH;
    l = mtfL;
Default :
    c = tfSrc;
    h = tfH;
    l = tfL;
}
def data = if c > c[1] then c - Min(c[1], l) else
           if c < c[1] then c - Max(c[1], h) else 0;
def src = data;
def smoothPrice = EhlersSuperSmootherFilter(src);
def price = if smoothing then smoothPrice else src;
 
plot AccDist;

plot MiddleLR;
if (fullRange)
then {
    AccDist  = TotalSum(price);
    MiddleLR = InertiaAll(AccDist);
} else {
    AccDist  = sum(price, length);
    MiddleLR = InertiaAll(AccDist);#, length);
}

def dist = HighestAll(AbsValue(MiddleLR - AccDist)) * (widthOfChannel / 100.0);


plot UpperLR1 = MiddleLR + dist;
plot LowerLR1 = MiddleLR - dist;

plot UpperLR2 = MiddleLR + dist * deviations1;
plot LowerLR2 = MiddleLR - dist * deviations1;

plot UpperLR3 = MiddleLR + dist * deviations2;
plot LowerLR3 = MiddleLR - dist * deviations2;

AccDist.SetLineWeight(2);
AccDist.SetDefaultColor(GetColor(1));

MiddleLR.SetStyle(Curve.SHORT_DASH);
MiddleLR.SetDefaultColor(Color.GRAY);

UpperLR1.SetDefaultColor(Color.GREEN);
LowerLR1.SetDefaultColor(Color.RED);

UpperLR2.SetDefaultColor(Color.DARK_GREEN);
LowerLR2.SetDefaultColor(Color.DARK_RED);

UpperLR3.SetDefaultColor(Color.DARK_GREEN);
LowerLR3.SetDefaultColor(Color.DARK_RED);

#-- END of CODE
Thank you @samer800
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
378 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