Repaints MTF Schaff Trend Indicator For ThinkOrSwim

Repaints
This is how I like my Schaff Trend Indicator, using the default setting (for comparison) as well as 3 different STCs with varying settings that if all raise together are a better indication of the strength of move than if just one was rising. I also use it with a different Overbought / Oversold level (5, 95) so change back if you need. The only real difference to the original indicator that I made aside from these tiny tweaks was to add whichever timeframe you like on each STC line. The commented headings for the different lines are just notes for me .. I don't know that any of the STCs are actually faster or slower than each other, but the one I color coded green usually lifts first, the yellow, next, and the red line is the one I use when for exits when it starts to move down from the top. I also have a version that's just for the auto aggregation so if anyone wants that just let me know.

Ruby:
##Schaff Trend Cycle MTF
#edited by agirlhasnoname42
 ## Default STC ##
declare lower;


input over_bought = 95;
input over_sold = 5;

input DefaultPeriod = AggregationPeriod.DAY;
input flength_d = 23;
input slength_d = 50;
input Kpd_d = 10;
input Dpd_d = 3;
input averageType_Default = AverageType.EXPONENTIAL;

def macd_d = MovingAverage(averageType_Default, close(Period = DefaultPeriod), flength_d) - MovingAverage(averageType_Default, close(Period = DefaultPeriod), slength_d);
def fastK_d = FastKCustom(macd_d, Kpd_d);
def fastD_d = MovingAverage(averageType_Default, fastK_d, Dpd_d);
def fastK2_d = FastKCustom(fastD_d, Kpd_d);
plot STC_d = MovingAverage(averageType_Default, fastK2_d, Dpd_d);
STC_d.SetDefaultColor(color.LIGHT_GRAY);


###################################################################################################
 ## Fast STC ##

input GreenPeriod = AggregationPeriod.DAY;
input flength_grn = 3;
input slength_grn = 90;
input Kpd_grn = 8;
input Dpd_grn = 2;

input averageType_Green = AverageType.EXPONENTIAL;

def macd_grn = MovingAverage(averageType_Green, close(Period = GreenPeriod), flength_grn) - MovingAverage(averageType_Green, close(Period = GreenPeriod), slength_grn);
def fastK_grn = FastKCustom(macd_grn, Kpd_grn);
def fastD_grn = MovingAverage(averageType_Green, fastK_grn, Dpd_grn);
def fastK2_grn = FastKCustom(fastD_grn, Kpd_grn);
plot STC_grn = MovingAverage(averageType_Green, fastK2_grn, Dpd_grn);

STC_grn.SetDefaultColor(color.Dark_GREEN);
STC_grn.SetLineWeight(2);

##################################################################################################
 ## Medium STC ##

input YellowPeriod = AggregationPeriod.DAY;
input flength_ylw = 7;
input slength_ylw = 40;
input Kpd_ylw = 6;
input Dpd_ylw = 2;

input averageType_Yellow = AverageType.EXPONENTIAL;

def macd_ylw = MovingAverage(averageType_Yellow, close(Period = YellowPeriod), flength_ylw) - MovingAverage(averageType_Yellow, close(Period = YellowPeriod), slength_ylw);
def fastK_ylw = FastKCustom(macd_ylw, Kpd_ylw);
def fastD_ylw = MovingAverage(averageType_Yellow, fastK_ylw, Dpd_ylw);
def fastK2_ylw = FastKCustom(fastD_ylw, Kpd_ylw);
plot STC_ylw = MovingAverage(averageType_Yellow, fastK2_ylw, Dpd_ylw);

STC_ylw.SetDefaultColor(color.Dark_ORANGE);
STC_ylw.SetStyle(Curve.Medium_Dash);
STC_ylw.SetLineWeight(2);

##################################################################################################
 ## Slow STC ##

input RedPeriod = AggregationPeriod.DAY;
input flength_red = 10;
input slength_red = 20;
input Kpd_red = 6;
input Dpd_red = 2;

input averageType_Red = AverageType.EXPONENTIAL;

def macd_red = MovingAverage(averageType_Red, close(Period = RedPeriod), flength_red) - MovingAverage(averageType_Red, close(Period = RedPeriod), slength_red);
def fastK_red = FastKCustom(macd_red, Kpd_red);
def fastD_red = MovingAverage(averageType_Red, fastK_red, Dpd_red);
def fastK2_red = FastKCustom(fastD_red, Kpd_red);
plot STC_red = MovingAverage(averageType_Red, fastK2_red, Dpd_red);

STC_red.SetDefaultColor(color.DARK_RED);
STC_red.SetLineWeight(2);

plot OverBought = over_bought;
plot OverSold = over_sold;

OverBought.SetDefaultColor(GetColor(7));
OverSold.SetDefaultColor(GetColor(7));
 

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

I like your indicator. Would it be possible to add a white 50 line? If yes, how can I do that? Thanks in advance.
 
here ya go
Ruby:
##Schaff Trend Cycle MTF
#edited by agirlhasnoname42
 ## Default STC ##
declare lower;


input over_bought = 95;
input over_sold = 5;

input DefaultPeriod = AggregationPeriod.DAY;
input flength_d = 23;
input slength_d = 50;
input Kpd_d = 10;
input Dpd_d = 3;
input averageType_Default = AverageType.EXPONENTIAL;

def macd_d = MovingAverage(averageType_Default, close(Period = DefaultPeriod), flength_d) - MovingAverage(averageType_Default, close(Period = DefaultPeriod), slength_d);
def fastK_d = FastKCustom(macd_d, Kpd_d);
def fastD_d = MovingAverage(averageType_Default, fastK_d, Dpd_d);
def fastK2_d = FastKCustom(fastD_d, Kpd_d);
plot STC_d = MovingAverage(averageType_Default, fastK2_d, Dpd_d);
STC_d.SetDefaultColor(color.LIGHT_GRAY);
STC_d.SetLineWeight(3);


###################################################################################################
 ## Fast STC ##

input GreenPeriod = AggregationPeriod.DAY;
input flength_grn = 3;
input slength_grn = 90;
input Kpd_grn = 8;
input Dpd_grn = 2;

input averageType_Green = AverageType.EXPONENTIAL;

def macd_grn = MovingAverage(averageType_Green, close(Period = GreenPeriod), flength_grn) - MovingAverage(averageType_Green, close(Period = GreenPeriod), slength_grn);
def fastK_grn = FastKCustom(macd_grn, Kpd_grn);
def fastD_grn = MovingAverage(averageType_Green, fastK_grn, Dpd_grn);
def fastK2_grn = FastKCustom(fastD_grn, Kpd_grn);
plot STC_grn = MovingAverage(averageType_Green, fastK2_grn, Dpd_grn);

STC_grn.SetDefaultColor(color.Dark_GREEN);
STC_grn.SetLineWeight(3);

##################################################################################################
 ## Medium STC ##

input YellowPeriod = AggregationPeriod.DAY;
input flength_ylw = 7;
input slength_ylw = 40;
input Kpd_ylw = 6;
input Dpd_ylw = 2;

input averageType_Yellow = AverageType.EXPONENTIAL;

def macd_ylw = MovingAverage(averageType_Yellow, close(Period = YellowPeriod), flength_ylw) - MovingAverage(averageType_Yellow, close(Period = YellowPeriod), slength_ylw);
def fastK_ylw = FastKCustom(macd_ylw, Kpd_ylw);
def fastD_ylw = MovingAverage(averageType_Yellow, fastK_ylw, Dpd_ylw);
def fastK2_ylw = FastKCustom(fastD_ylw, Kpd_ylw);
plot STC_ylw = MovingAverage(averageType_Yellow, fastK2_ylw, Dpd_ylw);

STC_ylw.SetDefaultColor(color.Dark_ORANGE);
STC_ylw.SetStyle(Curve.Medium_Dash);
STC_ylw.SetLineWeight(3);

##################################################################################################
 ## Slow STC ##

input RedPeriod = AggregationPeriod.DAY;
input flength_red = 10;
input slength_red = 20;
input Kpd_red = 6;
input Dpd_red = 2;

input averageType_Red = AverageType.EXPONENTIAL;

def macd_red = MovingAverage(averageType_Red, close(Period = RedPeriod), flength_red) - MovingAverage(averageType_Red, close(Period = RedPeriod), slength_red);
def fastK_red = FastKCustom(macd_red, Kpd_red);
def fastD_red = MovingAverage(averageType_Red, fastK_red, Dpd_red);
def fastK2_red = FastKCustom(fastD_red, Kpd_red);
plot STC_red = MovingAverage(averageType_Red, fastK2_red, Dpd_red);

STC_red.SetDefaultColor(color.DARK_RED);
STC_red.SetLineWeight(3);

plot OverBought = over_bought;
plot OverSold = over_sold;
plot MidLine = 50;
MidLine.SetStyle(curve.points);
MidLine.setDefaultColor(color.blue);

OverBought.SetDefaultColor(GetColor(7));
OverSold.SetDefaultColor(GetColor(7));
 
Hi Guys, this is my first post. Not that advance at coding thinkscript.

I'm looking to remove the time period aggregations that this code has and let it use the time period set by the timeframe on the chart it's applied.

Any help would be amazing...

@airlhasnoname42 Do you happen to have the "auto aggregation time period" version of this code?

Great work on this.

This is how I like my Schaff Trend Indicator, using the default setting (for comparison) as well as 3 different STCs with varying settings that if all raise together are a better indication of the strength of move than if just one was rising. I also use it with a different Overbought / Oversold level (5, 95) so change back if you need. The only real difference to the original indicator that I made aside from these tiny tweaks was to add whichever timeframe you like on each STC line. The commented headings for the different lines are just notes for me .. I don't know that any of the STCs are actually faster or slower than each other, but the one I color coded green usually lifts first, the yellow, next, and the red line is the one I use when for exits when it starts to move down from the top. I also have a version that's just for the auto aggregation so if anyone wants that just let me know.

Ruby:
##Schaff Trend Cycle MTF
#edited by agirlhasnoname42
 ## Default STC ##
declare lower;


input over_bought = 95;
input over_sold = 5;

input DefaultPeriod = AggregationPeriod.DAY;
input flength_d = 23;
input slength_d = 50;
input Kpd_d = 10;
input Dpd_d = 3;
input averageType_Default = AverageType.EXPONENTIAL;

def macd_d = MovingAverage(averageType_Default, close(Period = DefaultPeriod), flength_d) - MovingAverage(averageType_Default, close(Period = DefaultPeriod), slength_d);
def fastK_d = FastKCustom(macd_d, Kpd_d);
def fastD_d = MovingAverage(averageType_Default, fastK_d, Dpd_d);
def fastK2_d = FastKCustom(fastD_d, Kpd_d);
plot STC_d = MovingAverage(averageType_Default, fastK2_d, Dpd_d);
STC_d.SetDefaultColor(color.LIGHT_GRAY);


###################################################################################################
 ## Fast STC ##

input GreenPeriod = AggregationPeriod.DAY;
input flength_grn = 3;
input slength_grn = 90;
input Kpd_grn = 8;
input Dpd_grn = 2;

input averageType_Green = AverageType.EXPONENTIAL;

def macd_grn = MovingAverage(averageType_Green, close(Period = GreenPeriod), flength_grn) - MovingAverage(averageType_Green, close(Period = GreenPeriod), slength_grn);
def fastK_grn = FastKCustom(macd_grn, Kpd_grn);
def fastD_grn = MovingAverage(averageType_Green, fastK_grn, Dpd_grn);
def fastK2_grn = FastKCustom(fastD_grn, Kpd_grn);
plot STC_grn = MovingAverage(averageType_Green, fastK2_grn, Dpd_grn);

STC_grn.SetDefaultColor(color.Dark_GREEN);
STC_grn.SetLineWeight(2);

##################################################################################################
 ## Medium STC ##

input YellowPeriod = AggregationPeriod.DAY;
input flength_ylw = 7;
input slength_ylw = 40;
input Kpd_ylw = 6;
input Dpd_ylw = 2;

input averageType_Yellow = AverageType.EXPONENTIAL;

def macd_ylw = MovingAverage(averageType_Yellow, close(Period = YellowPeriod), flength_ylw) - MovingAverage(averageType_Yellow, close(Period = YellowPeriod), slength_ylw);
def fastK_ylw = FastKCustom(macd_ylw, Kpd_ylw);
def fastD_ylw = MovingAverage(averageType_Yellow, fastK_ylw, Dpd_ylw);
def fastK2_ylw = FastKCustom(fastD_ylw, Kpd_ylw);
plot STC_ylw = MovingAverage(averageType_Yellow, fastK2_ylw, Dpd_ylw);

STC_ylw.SetDefaultColor(color.Dark_ORANGE);
STC_ylw.SetStyle(Curve.Medium_Dash);
STC_ylw.SetLineWeight(2);

##################################################################################################
 ## Slow STC ##

input RedPeriod = AggregationPeriod.DAY;
input flength_red = 10;
input slength_red = 20;
input Kpd_red = 6;
input Dpd_red = 2;

input averageType_Red = AverageType.EXPONENTIAL;

def macd_red = MovingAverage(averageType_Red, close(Period = RedPeriod), flength_red) - MovingAverage(averageType_Red, close(Period = RedPeriod), slength_red);
def fastK_red = FastKCustom(macd_red, Kpd_red);
def fastD_red = MovingAverage(averageType_Red, fastK_red, Dpd_red);
def fastK2_red = FastKCustom(fastD_red, Kpd_red);
plot STC_red = MovingAverage(averageType_Red, fastK2_red, Dpd_red);

STC_red.SetDefaultColor(color.DARK_RED);
STC_red.SetLineWeight(2);

plot OverBought = over_bought;
plot OverSold = over_sold;

OverBought.SetDefaultColor(GetColor(7));
OverSold.SetDefaultColor(GetColor(7));
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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