#### vvcv

##### Member

My first post folks and I'd like to say hey and share two of my first modified indicators. I've taken quite an interest in making/modding indicators and would like to offer the community some tools they may find helpful for education or actual trades.

As for these first two that I would like to share, one is just the MACD with color and Bollinger Bands. The second is a modified Schaff Trend Cycle indicator, which MACD users may find useful. It has two lines and a StocRsi. Full Disclosure, I do not know if I am allowed to post modified indicators that come with THinkorSwim. Please remove if this is the case.

For those not familiar with the Schaff indicator, it's basically an amalgam of the MACD and RSI that can be looked at several different ways. I've found it to be an absolute tool for my trading and has not left my charts. I won't get into my trading thesis, but here are a couple of ways i've found my modified Schaff can be utilized...i'm sure there are others. A few are as follows:

1. An added tool to the MACD where you can find new entry points within a MACD trend.

2. Used alone, you can use two Schaff lines (which my modification has) as a way to set one line up for the trend and one for the pullbacks in that trend.

3. As a confirmation tool to support/resistance trading.

4. There is also a StochRSI line to help confirm what the Schaff wave line is indicating.

5. I use it as a confirmation to very basic Elliot wave trading. The wave line helps me a great deal to see the continuation of a trend, especially when the retrace is bouncing off a Fib 50% line.

You will find a "Trend" setting where you can use longer length periods to give you the trend. At the default settings, the trend line is like and very closely follows the 'Avg' line on the MACD. You will also find a "wave" line which you can set at faster settings to give you entry points that are moving in the direction of the trend line. For example, if the trend line is on top, you will find the wave line may fall to the oversold area showing a pullback. The default settings are 12/26/9. Yes, MACD settings and will closely follow the MACD Value line. The included StochRSI can help verify the wave movement.

I would like to point out that I modified the Schaff Trend indicator to help with my trading thesis, which I know well, so for me, it's just a tool. I'd be more than happy to answer question to those that may see some use to it.

Also, the MACD indicatior I'm sharing has clouds for the Bollinger Bands. I'm not very good with the code yet, and i'm not even sure if there is a way to set up an on/off cloud setting, but just add a '#' sign in front of the two cloud lines in the source code.

Well, thanks for looking, and looking forward to seeing some of your trading methods.

If I goof this posting, please advise as to how to correctly post code. Also, if you see that my very beginner code can be optimized, i welcome suggestions.

Robert

Code:

```
#MACDColorandBB
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);
plot Diff = Value - Avg;
plot ZeroLine = 0;
Value.DefineColor("up", GetColor(1));
Value.DefineColor("down", GetColor(0));
Value.AssignValueColor(if Value > Value[1] then Value.color("Up") else Value.color("Down"));
Avg.DefineColor("Down", GetColor(1));
Avg.DefineColor("Up", GetColor(0));
Avg.AssignValueColor(if Avg > Avg[1] then Avg.color("Up") else Avg.color("Down"));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
input displace = 0;
input length = 20;
input Num_Dev_Dn = -0.8;
input Num_Dev_up = 0.8;
input Num_Dev_Dn1 = -2.0;
input Num_Dev_up1 = 2.0;
input averageTypeBB = AverageType.Simple;
def sDev = stdev(data = Value[-displace], length = length);
plot MidLine = MovingAverage(averageTypebb, data = Value[-displace], length = length);
plot LowerBand = MidLine + num_Dev_Dn * sDev;
plot UpperBand = MidLine + num_Dev_Up * sDev;
plot LowerBand1 = MidLine + num_Dev_Dn1 * sDev;
plot UpperBand1 = MidLine + num_Dev_Up1 * sDev;
LowerBand.SetDefaultColor(GetColor(0));
MidLine.SetDefaultColor(GetColor(1));
UpperBand.SetDefaultColor(GetColor(5));
LowerBand1.SetDefaultColor(GetColor(0));
UpperBand1.SetDefaultColor(GetColor(5));
AddCloud(UpperBand1, UpperBand, CreateColor(102, 153, 255));
AddCloud(LowerBand, LowerBand1, CreateColor(255, 102, 102));
```

Code:

```
#aSchaffTrendCyclesWStochRSI
declare lower;
input fastLengthTrend = 23;
input slowLengthTrend = 50;
input KPeriodTrend = 10;
input DPeriodTrend = 3;
input averageTypeTrend = AverageType.EXPONENTIAL;
input fastLengthWave = 12;
input slowLengthWave = 26;
input KPeriodWave = 9;
input DPeriodWave = 2;
input over_bought = 75;
input over_sold = 25;
input averageTypeWave = AverageType.EXPONENTIAL;
input RSI_length = 14;
input RSI_average_type = AverageType.WILDERS;
input RSI_price = close;
input KPeriod = 14;
input DPeriod = 3;
input slowing_period = 1;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On FullK", "On FullD", "On FullK & FullD"};
def macdTrend = MovingAverage(averageTypeTrend, close, fastLengthTrend) - MovingAverage(averageTypeTrend, close, slowLengthTrend);
def fastK1Trend = FastKCustom(macdTrend, KPeriodTrend);
def fastD1Trend = MovingAverage(averageTypeTrend, fastK1Trend, DPeriodTrend);
def fastK2Trend = FastKCustom(fastD1Trend, KPeriodTrend);
def macdWave = MovingAverage(averageTypeWave, close, fastLengthWave) - MovingAverage(averageTypeWave, close, slowLengthWave);
def fastK1Wave = FastKCustom(macdWave, KPeriodWave);
def fastD1Wave = MovingAverage(averageTypeWave, fastK1Wave, DPeriodWave);
def fastK2Wave = FastKCustom(fastD1Wave, KPeriodWave);
plot STCTrend = MovingAverage(averageTypeTrend, fastK2Trend, DPeriodTrend);
plot STCWave = MovingAverage(averageTypeWave, fastK2Wave, DPeriodWave);
plot OverBought = over_bought;
plot OverSold = over_sold;
def RSI = RSI(price = RSI_price, length = RSI_length, averageType = RSI_average_type);
plot FullK = StochasticFull(over_bought, over_sold, KPeriod, DPeriod, RSI, RSI, RSI, slowing_period, averageType).FullK;
plot FullD = StochasticFull(over_bought, over_sold, KPeriod, DPeriod, RSI, RSI, RSI, slowing_period, averageType).FullD;
def upK = FullK crosses above OverSold;
def upD = FullD crosses above OverSold;
def downK = FullK crosses below OverBought;
def downD = FullD crosses below OverBought;
plot UpSignal;
plot DownSignal;
switch (showBreakoutSignals) {
case "No":
UpSignal = Double.NaN;
DownSignal = Double.NaN;
case "On FullK":
UpSignal = if upK then OverSold else Double.NaN;
DownSignal = if downK then OverBought else Double.NaN;
case "On FullD":
UpSignal = if upD then OverSold else Double.NaN;
DownSignal = if downD then OverBought else Double.NaN;
case "On FullK & FullD":
UpSignal = if upK or upD then OverSold else Double.NaN;
DownSignal = if downK or downD then OverBought else Double.NaN;
}
UpSignal.setHiding(showBreakoutSignals == showBreakoutSignals."No");
DownSignal.setHiding(showBreakoutSignals == showBreakoutSignals."No");
STCTrend.SetDefaultColor(GetColor(8));
STCWave.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(7));
OverSold.SetDefaultColor(GetColor(7));
STCTrend.DefineColor("Up", GetColor(1));
STCTrend.DefineColor("Down", GetColor(0));
STCTrend.AssignValueColor(if STCTrend > STCTrend[1] then STCTrend.Color("Up") else STCTrend.Color("Down"));
STCWave.DefineColor("Up", GetColor(1));
STCWave.DefineColor("Down", GetColor(0));
STCWave.AssignValueColor(if STCWave > STCWave[1] then STCWave.Color("Up") else STCWave.Color("Down"));
FullK.SetDefaultColor(GetColor(5));
FullD.SetDefaultColor(GetColor(0));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
input lengthWave = 3;
plot AvgExpWave = ExpAverage(STCWave, lengthWave);
AvgExpWave.SetDefaultColor(GetColor(1));
input lengthFullK = 3;
plot AvgExpFullK = ExpAverage(FullK, lengthWave);
AvgExpFullK.SetDefaultColor(GetColor(1));
```