This is a Trend Quality Indicator for ThinkorSwim shared by Anupam Bagchi who is a data scientist. This indicator is useful for showing buying, selling, and sideways action.
When the TQI is greater than 3, it indicates a robust green bull trend. It is similar to seeing a car climbing steadily up the mountain.
Conversely, a yellow plot, with values between 3 and -3, signifies a weaker or less reliable trend. It's like driving on a winding road with some obstacles ahead – indicating a weaker trend that might not be as dependable.
Values below -3, strong red bear trend. The car is making a bee-line down the mountain.
Trend Quality Indicator:
Modified: https://tos.mx/wbZ5TC
- Green = buying pressure
- Red = selling pressure
- Yellow = sideways
When the TQI is greater than 3, it indicates a robust green bull trend. It is similar to seeing a car climbing steadily up the mountain.
Conversely, a yellow plot, with values between 3 and -3, signifies a weaker or less reliable trend. It's like driving on a winding road with some obstacles ahead – indicating a weaker trend that might not be as dependable.
Values below -3, strong red bear trend. The car is making a bee-line down the mountain.
Trend Quality Indicator:
- measures established TRENDs
- can be used on timeframes of 5min and higher.
- works best on timeframes of 30min or higher.
- The threshold of 3 should be appropriate for most instruments. It can be modified in chart settings to adapt to your strategy.
thinkScript Code
Rich (BB code):
declare lower;
input fastLength = 7;
input slowLength = 15;
input trendLength = 4;
input noiseType = {default linear, squared};
input noiseLength = 250;
input correctionFactor = 2;
input ThresholdValue = 3;
input AlertEnabled = {true, default false};
def smf = 2 / (1 + trendLength);
def reversal = TrendPeriods(fastLength, slowLength);
rec cpc = if isNaN(reversal[1]) then 0 else if reversal[1] != reversal then 0 else cpc[1] + close - close[1];
rec trend = if isNaN(reversal[1]) then 0 else if reversal[1] != reversal then 0 else trend[1] * (1 - smf) + cpc * smf;
def noise;
def diff = AbsValue(cpc - trend);
switch(noiseType) {
case linear:
noise = correctionFactor * Average(diff, noiseLength);
case squared:
noise = correctionFactor * Sqrt(Average(diff*diff, noiseLength));
}
plot TQ = if noise == 0 then 0 else trend / noise;
plot ZeroLine = 0;
TQ.SetPaintingStrategy(PaintingStrategy.Histogram);
TQ.SetLineWeight(3);
TQ.DefineColor("Positive", Color.UPTICK);
TQ.DefineColor("Negative", Color.DOWNTICK);
TQ.DefineColor("Neutral", Color.YELLOW);
TQ.AssignValueColor(if TQ > ThresholdValue then TQ.color("Positive") else if TQ < -ThresholdValue then TQ.color("Negative") else TQ.color("Neutral"));
ZeroLine.SetDefaultColor(GetColor(5));
def crossthresholdup = TQ > ThresholdValue && TQ[1] <= ThresholdValue && AlertEnabled;
def crossthresholddown = TQ < -ThresholdValue && TQ[1] >= -ThresholdValue && AlertEnabled;
alert(crossthresholdup, "Trend Quality just crossed above threshold", Alert.BAR, Sound.DING);
alert(crossthresholddown, "Trend Quality just crossed below threshold", Alert.BAR, Sound.DING);
Shareable Link
Original: https://tos.mx/Drcgp5Modified: https://tos.mx/wbZ5TC
Last edited by a moderator: