agirlhasnoname42
Member
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));