This dashboard consists of 3 different Trend Meters and a Trend Bar which are used to confirm trend
Use as a supplementary Indicator to confirm your entries, but it is as good on it's own.
#// As a bonus Wave Trend Signals are marked as well, these are very powerful however please use with caution
#// How to Use
The more Trend meters are lit up the better
#// Look for Support or Resistance Levels for price to be attracted to
#// Find confluence with other indicators
#// Enter Long above the Setup Bar
#// Enter Short Below the Setup Bar
Moreover, I added signal based on the provided YouTube. Enjoy
You can read more and find the video here:
https://usethinkscript.com/threads/converted-tradingview-trend-meter.11113/
and here:
https://www.tradingview.com/script/Ciurp4Qn-Trend-Meter/
Per member request: https://usethinkscript.com/threads/converted-tradingview-trend-meter.11113/
converted the code below.
Add Price color option
Use as a supplementary Indicator to confirm your entries, but it is as good on it's own.
#// As a bonus Wave Trend Signals are marked as well, these are very powerful however please use with caution
#// How to Use
The more Trend meters are lit up the better
#// Look for Support or Resistance Levels for price to be attracted to
#// Find confluence with other indicators
#// Enter Long above the Setup Bar
#// Enter Short Below the Setup Bar
Moreover, I added signal based on the provided YouTube. Enjoy
You can read more and find the video here:
https://usethinkscript.com/threads/converted-tradingview-trend-meter.11113/
and here:
https://www.tradingview.com/script/Ciurp4Qn-Trend-Meter/
Per member request: https://usethinkscript.com/threads/converted-tradingview-trend-meter.11113/
converted the code below.
CSS:
#// Created By Lij_MC
#// Use as a supplementary Indicator to confirm your entries, but it is as good on it's own.
#// The indicator consists of 3 different Trend Meters and a Trend Bar which are used to confirm trend
#// As a bonus Wave Trend Signals are marked as well, these are very powerful however please use with caution
#// How to Use
#// Look for Support or Resistance Levels for price to be attracted to
#// Find confluence with other indicators
#// Enter Long above the Setup Bar
#// Enter Short Below the Setup Bar
#study(title="Trend Meter")
# Converted and mod by Sam4Cok@Samer800 - 10/2022
declare lower;
#// Inputs / Menus
#// Trend Bar / Meter - Inputs / Menus
input VolatilityLength = 100;
input SignalMALength1 = 50;
input SignalMALength2 = 200;
input ShowTrendBar = yes;
input UseChartTimeFrame = yes;
input Aggregation = AggregationPeriod.DAY;
#// MA Inputs
input ma1_Length = 5; # 'Fast MA'
input ma1_Type = {default "EMA", "SMA"}; # "TB1 Fast"
input ma2_Length = 11; # 'Slow MA'
input ma2_Type = {default "EMA", "SMA"}; # "TB1 Slow"
input ma3_Length = 13; # 'Fast MA'
input ma3_Type = { default "EMA", "SMA"}; # "TB2 Fast"
input ma4_Length = 36; # 'Slow MA'
input ma4_Type = {"EMA", default "SMA"}; # "TB2 Slow"
#--Trend inputs
input WaveTrendSignalLine = no; # "Wave Trend Filtered by Trend"
input TrendMeterLine = yes; # "All 3 Trend Meters Now Align"
input Filter1 = {"N/A", default "Trend Filter", "Filter X", "Filter X + Trend Filter"};#WT Signals
input Filter2 = {"N/A", default "Trend Filter", "Filter X", "Filter X + Trend Filter"};#WT Signals
input TrendMeter1 = {"MACD Crossover - 12, 26, 9", default "MACD Crossover - Fast - 8, 21, 5", "Mom Dad Cross (Top Dog Trading)", "RSI Signal Line Cross - RSI 13, Sig 21", "RSI 13: > or < 50", "RSI 5: > or < 50", "Trend Candles", "DAD Direction (Top Dog Trading)", "MA Crossover", "N/A"};#"Trend Meter1"
input TrendMeter2 = {"MACD Crossover - 12, 26, 9", "MACD Crossover - Fast - 8, 21, 5", "Mom Dad Cross (Top Dog Trading)", "RSI Signal Line Cross - RSI 13, Sig 21", default "RSI 13: > or < 50", "RSI 5: > or < 50", "Trend Candles", "DAD Direction (Top Dog Trading)", "MA Crossover", "N/A"};#"Trend Meter 2"
input TrendMeter3 = {"MACD Crossover - 12, 26, 9", "MACD Crossover - Fast - 8, 21, 5", "Mom Dad Cross (Top Dog Trading)", "RSI Signal Line Cross - RSI 13, Sig 21", "RSI 13: > or < 50", default "RSI 5: > or < 50", "Trend Candles", "DAD Direction (Top Dog Trading)", "MA Crossover", "N/A"};#"Trend Meter 3"
input TrendBar1 = {default "MA Crossover", "MA Direction - Fast MA - TB1", "MA Direction - Slow MA - TB1", "DAD Direction (Top Dog Trading)", "MACD Crossover", "N/A"};#"Trend Bar 1"
input TrendBar2 = {default "MA Crossover", "MA Direction - Fast MA - TB2", "MA Direction - Slow MA - TB2", "DAD Direction (Top Dog Trading)", "MACD Crossover", "N/A"};#"Trend Bar 2"
def na = Double.NaN;
#def mClose = if UseChartTimeFrame then Close(period=GetAggregationPeriod()) else close(period=AggregationPeriod);
def agg = GetAggregationPeriod();
def c = if UseChartTimeFrame then close else close(Period = Aggregation);
def o = if UseChartTimeFrame then open else open(Period = Aggregation);
;
#---Color
DefineGlobalColor("green" , CreateColor(40, 138, 117));
DefineGlobalColor("Red" , CreateColor(255, 82, 82));
#// Wave Trend - RSI
def RSIMC = RSI(price = c, Length = 14);
#// Wave Trend
def ap = if UseChartTimeFrame then hlc3 else hlc3(Period = Aggregation) ; # "Wave Trend - Source"
def n1 = 9; # "Wave Trend - WT Channel Length"
def n2 = 12; # "Wave Trend - WT Average Length"
def esa = ExpAverage(ap, n1);
def de = ExpAverage(AbsValue(ap - esa), n1);
def ci = (ap - esa) / (0.015 * de);
def tci = ExpAverage(ci, n2);
def wt1 = tci;
def wt2 = SimpleMovingAvg(wt1, 3);
#// Wave Trend - Overbought & Oversold lines
def obLevel2 = 60; # "Wave Trend - WT Very Overbought")
def obLevel = 50; # "Wave Trend - WT Overbought")
def osLevel = -50; # "Wave Trend - WT Oversold")
def osLevel2 = -60; # "Wave Trend - WT Very Oversold")
#// Wave Trend - Conditions
def WTCross = Crosses(wt1, wt2);
def WTCrossUp = wt2 - wt1 <= 0;
def WTCrossDown = wt2 - wt1 >= 0;
def WTOverSold = wt2 <= osLevel2;
def WTOverBought = wt2 >= obLevel2;
#// MA Calculations
def MA1 = if ma1_Type == ma1_Type."SMA" then
SimpleMovingAvg(c, ma1_Length) else ExpAverage(c, ma1_Length);
def MA2 = if ma2_Type == ma2_Type."SMA" then
SimpleMovingAvg(c, ma2_Length) else ExpAverage(c, ma2_Length);
def MA3 = if ma3_Type == ma3_Type."SMA" then
SimpleMovingAvg(c, ma3_Length) else ExpAverage(c, ma3_Length);
def MA4 = if ma4_Type == ma4_Type."SMA" then
SimpleMovingAvg(c, ma4_Length) else ExpAverage(c, ma4_Length);
#// MA Crossover Condition
def MACrossover1 = if MA1 > MA2 then 1 else 0;
def MACrossover2 = if MA3 > MA4 then 1 else 0;
#// MA Direction Condition
def MA1Direction = if MA1 > MA1[1] then 1 else 0;
def MA2Direction = if MA2 > MA2[1] then 1 else 0;
def MA3Direction = if MA3 > MA3[1] then 1 else 0;
def MA4Direction = if MA4 > MA4[1] then 1 else 0;
#// MA Direction Change Condition
def MA1PositiveDirectionChange = if MA1Direction and !MA1Direction[1] then 1 else 0;
def MA2PositiveDirectionChange = if MA2Direction and !MA2Direction[1] then 1 else 0;
def MA3PositiveDirectionChange = if MA3Direction and !MA3Direction[1] then 1 else 0;
def MA4PositiveDirectionChange = if MA4Direction and !MA4Direction[1] then 1 else 0;
def MA1NegativeDirectionChange = if !MA1Direction and MA1Direction[1] then 1 else 0;
def MA2NegativeDirectionChange = if !MA2Direction and MA2Direction[1] then 1 else 0;
def MA3NegativeDirectionChange = if !MA3Direction and MA3Direction[1] then 1 else 0;
def MA4NegativeDirectionChange = if !MA4Direction and MA4Direction[1] then 1 else 0;
#// MACD and MOM & DAD - Top Dog Trading
#// Standard MACD Calculations
def MACDfastMA = 12;
def MACDslowMA = 26;
def MACDsignalSmooth = 9;
def MACDLine = ExpAverage(c, MACDfastMA) - ExpAverage(c, MACDslowMA);
def SignalLine = ExpAverage(MACDLine, MACDsignalSmooth);
def MACDHistogram = MACDLine - SignalLine;
#// MACD- Background Color Change Condition
def MACDHistogramCross = if MACDHistogram > 0 then 1 else 0;
def MACDLineOverZero = if MACDLine > 0 then 1 else 0;
def MACDLineOverZeroandHistogramCross = if MACDHistogramCross and MACDLineOverZero then 1 else 0;
def MACDLineUnderZeroandHistogramCross = if !MACDHistogramCross and !MACDLineOverZero then 1 else 0;
#// Fast MACD Calculations
def FastMACDfastMA = 8;
def FastMACDslowMA = 21;
def FastMACDsignalSmooth = 5;
def FastMACDLine = ExpAverage(c, FastMACDfastMA) - ExpAverage(c, FastMACDslowMA);
def FastSignalLine = ExpAverage(FastMACDLine, FastMACDsignalSmooth);
def FastMACDHistogram = FastMACDLine - FastSignalLine;
#// Fast MACD- Background Color Change Condition
def FastMACDHistogramCross = if FastMACDHistogram > 0 then 1 else 0;
def FastMACDLineOverZero = if FastMACDLine > 0 then 1 else 0;
def FastMACDLineOverZeroandHistogramCross = if FastMACDHistogramCross and FastMACDLineOverZero then 1 else 0;
def FastMACDLineUnderZeroandHistogramCross = if !FastMACDHistogramCross and !FastMACDLineOverZero then 1 else 0;
#// Top Dog Trading - Mom Dad Calculations
def TopDog_Fast_MA = 5;
def TopDog_Slow_MA = 20;
def TopDog_Sig = 30;
def TopDogMom = ExpAverage(c, TopDog_Fast_MA) - ExpAverage(c, TopDog_Slow_MA);
def TopDogDad = ExpAverage(TopDogMom, TopDog_Sig);
#// Top Dog Dad - Background Color Change Condition
def TopDogDadDirection = If(TopDogDad > TopDogDad[1], 1, 0);
def TopDogMomOverDad = If(TopDogMom > TopDogDad, 1, 0);
def TopDogMomOverZero = If(TopDogMom > 0, 1, 0);
def TopDogDadDirectandMomOverZero = If(TopDogDadDirection and TopDogMomOverZero, 1, 0);
def TopDogDadDirectandMomUnderZero = If(!TopDogDadDirection and !TopDogMomOverZero, 1, 0);
#////// Trend Barmeter Calculations //////
#// UCS_Trend / Trend Candles Trend Barmeter Calculations
#//UCS_Trend by ucsgears copy Trend Candles
#//Interpretation of TTM Trend bars. It is really close to the actual.
def haclose = if UseChartTimeFrame then ohlc4 else ohlc4(Period = Aggregation);
def haopen = if IsNaN(haopen[1]) then (o + c) / 2 else (haopen[1] + haclose[1]) / 2;
def ccolor = If(haclose - haopen > 0, 1, 0);
def inside6 = If(haopen <= Max(haopen[6], haclose[6]) and haopen >= Min(haopen[6], haclose[6]) and
haclose <= Max(haopen[6], haclose[6]) and haclose >= Min(haopen[6], haclose[6]), 1, 0);
def inside5 = If(haopen <= Max(haopen[5], haclose[5]) and haopen >= Min(haopen[5], haclose[5]) and
haclose <= Max(haopen[5], haclose[5]) and haclose >= Min(haopen[5], haclose[5]), 1, 0);
def inside4 = If(haopen <= Max(haopen[4], haclose[4]) and haopen >= Min(haopen[4], haclose[4]) and
haclose <= Max(haopen[4], haclose[4]) and haclose >= Min(haopen[4], haclose[4]), 1, 0);
def inside3 = If(haopen <= Max(haopen[3], haclose[3]) and haopen >= Min(haopen[3], haclose[3]) and
haclose <= Max(haopen[3], haclose[3]) and haclose >= Min(haopen[3], haclose[3]), 1, 0);
def inside2 = If(haopen <= Max(haopen[2], haclose[2]) and haopen >= Min(haopen[2], haclose[2]) and
haclose <= Max(haopen[2], haclose[2]) and haclose >= Min(haopen[2], haclose[2]), 1, 0);
def inside1 = If(haopen <= Max(haopen[1], haclose[1]) and haopen >= Min(haopen[1], haclose[1]) and
haclose <= Max(haopen[1], haclose[1]) and haclose >= Min(haopen[1], haclose[1]), 1, 0);
def colorvalue = if inside6 then ccolor[6] else if inside5 then ccolor[5] else if inside4 then ccolor[4] else if inside3 then ccolor[3] else if inside2 then ccolor[2] else if inside1 then ccolor[1] else ccolor;
def TrendBarTrend_Candle = if colorvalue then 1 else 0;
#// RSI 5 Trend Barmeter Calculations
def RSI5 = RSI(Price = c, Length = 5);
def RSI5Above50 = if RSI5 > 50 then 1 else 0;
def RSI5Color = if RSI5Above50 then 1 else 0;# ? #288a75 : color.red
#// RSI 5 Trend Barmeter Calculations
def RSI13 = RSI(Price = c, Length = 13);
#// Linear Regression Calculation For RSI Signal Line
def SignalLineLength1 = 21;
def x = BarNumber();
def y = RSI13;
def x_ = SimpleMovingAvg(x, SignalLineLength1);
def y_ = SimpleMovingAvg(y, SignalLineLength1);
def mx = StDev(x, SignalLineLength1);
def my = StDev(y, SignalLineLength1);
def corr = Correlation(x, y, SignalLineLength1);
def slope = corr * (my / mx);
def inter = y_ - slope * x_;
def LinReg1 = x * slope + inter;
def RSISigDirection = If(LinReg1 > LinReg1[1], 1, 0);
def RSISigCross = If(RSI13 > LinReg1, 1, 0);
def RSI13Above50 = If(RSI13 > 50, 1, 0);
#// Trend Barmeter Color Calculation
#RSI13Color = RSI13Above50 ? #288a75 : color.red
def TrendBarRSI13Color = If(RSI13Above50, 1, 0);
def TrendBarRSISigCrossColor = If(RSISigCross, 1, 0);
def TrendBarMACDColor = If(MACDHistogramCross, 1, 0);
def TrendBarFastMACDColor = If(FastMACDHistogramCross, 1, 0);
def TrendBarMACrossColor = If(MACrossover1, 1, 0);
def TrendBarMomOverDadColor = If(TopDogMomOverDad, 1, 0);
def TrendBarDadDirectionColor = If(TopDogDadDirection, 1, 0);
def TrendBar1Result = if TrendMeter1 == TrendMeter1."MA Crossover" then MACrossover1 else if
TrendMeter1 == TrendMeter1."MACD Crossover - 12, 26, 9" then MACDHistogramCross else if
TrendMeter1 == TrendMeter1."MACD Crossover - Fast - 8, 21, 5" then FastMACDHistogramCross else if
TrendMeter1 == TrendMeter1."Mom Dad Cross (Top Dog Trading)" then TopDogMomOverDad else if
TrendMeter1 == TrendMeter1."DAD Direction (Top Dog Trading)" then TopDogDadDirection else if
TrendMeter1 == TrendMeter1."RSI Signal Line Cross - RSI 13, Sig 21" then RSISigCross else if
TrendMeter1 == TrendMeter1."RSI 5: > or < 50" then RSI5Above50 else if
TrendMeter1 == TrendMeter1."RSI 13: > or < 50" then RSI13Above50 else if
TrendMeter1 == TrendMeter1."Trend Candles" then TrendBarTrend_Candle else na;
def TrendBar2Result = if TrendMeter2 == TrendMeter2."MA Crossover" then MACrossover1 else if
TrendMeter2 == TrendMeter2."MACD Crossover - 12, 26, 9" then MACDHistogramCross else if
TrendMeter2 == TrendMeter2."MACD Crossover - Fast - 8, 21, 5" then FastMACDHistogramCross else if
TrendMeter2 == TrendMeter2."Mom Dad Cross (Top Dog Trading)" then TopDogMomOverDad else if
TrendMeter2 == TrendMeter2."DAD Direction (Top Dog Trading)" then TopDogDadDirection else if
TrendMeter2 == TrendMeter2."RSI Signal Line Cross - RSI 13, Sig 21" then RSISigCross else if
TrendMeter2 == TrendMeter2."RSI 5: > or < 50" then RSI5Above50 else if
TrendMeter2 == TrendMeter2."RSI 13: > or < 50" then RSI13Above50 else if
TrendMeter2 == TrendMeter2."Trend Candles" then TrendBarTrend_Candle else na;
def TrendBar3Result = if TrendMeter3 == TrendMeter3."MA Crossover" then MACrossover1 else if
TrendMeter3 == TrendMeter3."MACD Crossover - 12, 26, 9" then MACDHistogramCross else if
TrendMeter3 == TrendMeter3."MACD Crossover - Fast - 8, 21, 5" then FastMACDHistogramCross else if
TrendMeter3 == TrendMeter3."Mom Dad Cross (Top Dog Trading)" then TopDogMomOverDad else if
TrendMeter3 == TrendMeter3."DAD Direction (Top Dog Trading)" then TopDogDadDirection else if
TrendMeter3 == TrendMeter3."RSI Signal Line Cross - RSI 13, Sig 21" then RSISigCross else if
TrendMeter3 == TrendMeter3."RSI 5: > or < 50" then RSI5Above50 else if
TrendMeter3 == TrendMeter3."RSI 13: > or < 50" then RSI13Above50 else if
TrendMeter3 == TrendMeter3."Trend Candles" then TrendBarTrend_Candle else na;
def TrendBars2Positive = If(TrendBar1Result and TrendBar2Result or TrendBar1Result and
TrendBar3Result or TrendBar2Result and TrendBar3Result, 1, 0);
def TrendBars2Negative = If(!TrendBar1Result and !TrendBar2Result or !TrendBar1Result and
!TrendBar3Result or !TrendBar2Result and !TrendBar3Result, 1, 0);
def TrendBars3Positive = If(TrendBar1Result and TrendBar2Result and TrendBar3Result, 1, 0);
def TrendBars3Negative = If(!TrendBar1Result and !TrendBar2Result and !TrendBar3Result, 1, 0);
#// Signal Filters
def FilterXUp = FastMACDHistogramCross and ExpAverage(c, 15) > ExpAverage(c, 15)[1];
def FilterXDown = !FastMACDHistogramCross and ExpAverage(c, 15) < ExpAverage(c, 15)[1];
def TrendFilterPlus = If(ExpAverage(c, 15) > ExpAverage(c, 20) and ExpAverage(c, 20) > ExpAverage(c, 30) and ExpAverage(c, 30) > ExpAverage(c, 40) and ExpAverage(c, 40) > ExpAverage(c, 50), 1, 0);
def TrendFilterMinus = If(ExpAverage(c, 15) < ExpAverage(c, 20) and ExpAverage(c, 20) < ExpAverage(c, 30) and ExpAverage(c, 30) < ExpAverage(c, 40) and ExpAverage(c, 40) < ExpAverage(c, 50), 1, 0);
#// // Wave Trend - Conditions
def MSBar1PositiveWaveTrendSignal =
if Filter1 == Filter1."Filter X" then FilterXUp and WTCross and WTCrossUp else if
Filter1 == Filter1."Trend Filter" then TrendFilterPlus and WTCross and WTCrossUp else if
Filter1 == Filter1."Filter X + Trend Filter" then
FilterXUp and TrendFilterPlus and WTCross and WTCrossUp else WTCross and WTCrossUp;
def MSBar1NegativeWaveTrendSignal =
if Filter1 == Filter1."Filter X" then FilterXDown and WTCross and WTCrossDown else if
Filter1 == Filter1."Trend Filter" then TrendFilterMinus and WTCross and WTCrossDown else if
Filter1 == Filter1."Filter X + Trend Filter" then
FilterXDown and TrendFilterMinus and WTCross and WTCrossDown else
WTCross and WTCrossDown;
def MSBar2PositiveWaveTrendSignal =
if Filter2 == Filter2."Filter X" then FilterXUp and WTCross and WTCrossUp else if
Filter2 == Filter2."Trend Filter" then TrendFilterPlus and WTCross and WTCrossUp else if
Filter2 == Filter2."Filter X + Trend Filter" then
FilterXUp and TrendFilterPlus and WTCross and WTCrossUp else WTCross and WTCrossUp;
def MSBar2NegativeWaveTrendSignal =
if Filter2 == Filter2."Filter X" then FilterXDown and WTCross and WTCrossDown else if
Filter2 == Filter2."Trend Filter" then TrendFilterMinus and WTCross and WTCrossDown else if
Filter2 == Filter2."Filter X + Trend Filter" then
FilterXDown and TrendFilterMinus and WTCross and WTCrossDown else WTCross and WTCrossDown;
#////////////////////////
def BackgroundColorChangePositive = TrendBars3Positive and !TrendBars3Positive[1];
def BackgroundColorChangeNegative = TrendBars3Negative and !TrendBars3Negative[1];
#// Signals Color Calculations
def MSBar1Color = if MSBar1PositiveWaveTrendSignal then 1 else
if MSBar1NegativeWaveTrendSignal then -1 else na;#
def MSBar2Color = if BackgroundColorChangePositive then 1 else
if BackgroundColorChangeNegative then -1 else na;
#// Trend Barmeter Color Assignments
def TrendBar1Color =
if TrendMeter1 == TrendMeter1."N/A" then na else if
TrendMeter1 == TrendMeter1."MACD Crossover - 12, 26, 9" then TrendBarMACDColor else if
TrendMeter1 == TrendMeter1."MACD Crossover - Fast - 8, 21, 5" then TrendBarFastMACDColor else if
TrendMeter1 == TrendMeter1."Mom Dad Cross (Top Dog Trading)" then TrendBarMomOverDadColor else if
TrendMeter1 == TrendMeter1."DAD Direction (Top Dog Trading)" then TrendBarDadDirectionColor else if
TrendMeter1 == TrendMeter1."RSI Signal Line Cross - RSI 13, Sig 21" then TrendBarRSISigCrossColor else if
TrendMeter1 == TrendMeter1."RSI 5: > or < 50" then RSI5Color else if
TrendMeter1 == TrendMeter1."RSI 13: > or < 50" then TrendBarRSI13Color else if
TrendMeter1 == TrendMeter1."Trend Candles" then TrendBarTrend_Candle else if
TrendMeter1 == TrendMeter1."MA Crossover" then TrendBarMACrossColor else na;
def TrendBar2Color =
if TrendMeter2 == TrendMeter2."N/A" then na else if
TrendMeter2 == TrendMeter2."MACD Crossover - 12, 26, 9" then TrendBarMACDColor else if
TrendMeter2 == TrendMeter2."MACD Crossover - Fast - 8, 21, 5" then TrendBarFastMACDColor else if
TrendMeter2 == TrendMeter2."Mom Dad Cross (Top Dog Trading)" then TrendBarMomOverDadColor else if
TrendMeter2 == TrendMeter2."DAD Direction (Top Dog Trading)" then TrendBarDadDirectionColor else if
TrendMeter2 == TrendMeter2."RSI Signal Line Cross - RSI 13, Sig 21" then TrendBarRSISigCrossColor else if
TrendMeter2 == TrendMeter2."RSI 5: > or < 50" then RSI5Color else if
TrendMeter2 == TrendMeter2."RSI 13: > or < 50" then TrendBarRSI13Color else if
TrendMeter2 == TrendMeter2."Trend Candles" then TrendBarTrend_Candle else if
TrendMeter2 == TrendMeter2."MA Crossover" then TrendBarMACrossColor else na;
def TrendBar3Color =
if TrendMeter3 == TrendMeter3."N/A" then na else if
TrendMeter3 == TrendMeter3."MACD Crossover - 12, 26, 9" then TrendBarMACDColor else if
TrendMeter3 == TrendMeter3."MACD Crossover - Fast - 8, 21, 5" then TrendBarFastMACDColor else if
TrendMeter3 == TrendMeter3."Mom Dad Cross (Top Dog Trading)" then TrendBarMomOverDadColor else if
TrendMeter3 == TrendMeter3."DAD Direction (Top Dog Trading)" then TrendBarDadDirectionColor else if
TrendMeter3 == TrendMeter3."RSI Signal Line Cross - RSI 13, Sig 21" then TrendBarRSISigCrossColor else if
TrendMeter3 == TrendMeter3."RSI 5: > or < 50" then RSI5Color else if
TrendMeter3 == TrendMeter3."RSI 13: > or < 50" then TrendBarRSI13Color else if
TrendMeter3 == TrendMeter3."Trend Candles" then TrendBarTrend_Candle else if
TrendMeter3 == TrendMeter3."MA Crossover" then TrendBarMACrossColor else na;
def CrossoverType2 =
if TrendBar1 == TrendBar1."DAD Direction (Top Dog Trading)" then TopDogDadDirection else if
TrendBar1 == TrendBar1."MACD Crossover" then MACDHistogramCross else if
TrendBar1 == TrendBar1."MA Direction - Fast MA - TB1" then MA1Direction else if
TrendBar1 == TrendBar1."MA Direction - Slow MA - TB1" then MA2Direction else MACrossover1;
def TrendBar4Color1 = if TrendBar1 == TrendBar1."N/A" then na else
if CrossoverType2 then 1 else 0;
def CrossoverType3 =
if TrendBar2 == TrendBar2."DAD Direction (Top Dog Trading)" then TopDogDadDirection else if
TrendBar2 == TrendBar2."MACD Crossover" then MACDHistogramCross else if
TrendBar2 == TrendBar2."MA Direction - Fast MA - TB2" then MA3Direction else if
TrendBar2 == TrendBar2."MA Direction - Slow MA - TB2" then MA4Direction else MACrossover2;
def TrendBar5Color1 = if TrendBar2 == TrendBar2."N/A" then na else
if CrossoverType3 then 1 else 0;
#// Momentum Setup Plots
plot Signals1 = If(IsNaN(c) or IsNaN(MSBar1Color), na, If(ShowTrendBar and WaveTrendSignalLine, 129, na)); # "Signals 1 - Wave Trend Signals"
Signals1.SetPaintingStrategy(PaintingStrategy.SQUARES);
Signals1.AssignValueColor(if MSBar1Color > 0 then GlobalColor("green") else GlobalColor("RED"));
plot Signals2 = If(IsNaN(c) or IsNaN(MSBar2Color), na, If(ShowTrendBar and TrendMeterLine, 126, na)); # "Signals 2 - All 3 Trend Meters Now Align"
Signals2.SetPaintingStrategy(PaintingStrategy.POINTS);
Signals2.AssignValueColor(if MSBar2Color > 0 then GlobalColor("green") else GlobalColor("RED"));
#// Trend Barmeter Plots
plot TM1 = If(IsNaN(c), na, If(ShowTrendBar, 123, na)); # "Trend Meter 1"
TM1.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
TM1.AssignValueColor(if TrendBar1Color then GlobalColor("green") else GlobalColor("RED"));
plot TM2 = If(IsNaN(c), na, If(ShowTrendBar, 120.5, na));# "Trend Meter 2"
TM2.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
TM2.AssignValueColor(if TrendBar2Color then GlobalColor("green") else GlobalColor("RED"));
plot TM3 = If(IsNaN(c), na, If(ShowTrendBar, 118, na));# "Trend Meter 3"
TM3.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
TM3.AssignValueColor(if TrendBar3Color then GlobalColor("green") else GlobalColor("RED"));
plot ThinLine = If(IsNaN(c), na, If(ShowTrendBar and !(TrendBar2 == TrendBar2."N/A"), 115, na));
ThinLine.AssignValueColor(if TrendBar4Color1 then Color.GREEN else Color.RED);
ThinLine.SetLineWeight(2);
plot ThikLine = If(IsNaN(c), na, If(ShowTrendBar and TrendBar2 == TrendBar2."N/A" and !(TrendBar1 == TrendBar1."N/A"), 107.25, na));
ThikLine.AssignValueColor(if TrendBar4Color1 then Color.GREEN else Color.RED);
ThikLine.SetLineWeight(5);
plot ThinLine2 = If(IsNaN(c), na, If(ShowTrendBar and !(TrendBar1 == TrendBar1."N/A"), 112.5, na));
ThinLine2.AssignValueColor(if TrendBar5Color1 then Color.GREEN else Color.RED);
ThinLine2.SetLineWeight(2);
plot ThikLine2 = If(IsNaN(c), na, If(ShowTrendBar and TrendBar1 == TrendBar1."N/A" and !(TrendBar2 == TrendBar2."N/A"), 107.25, na));
ThikLine2.AssignValueColor(if TrendBar5Color1 then Color.GREEN else Color.RED);
ThikLine2.SetLineWeight(5);
#--- Stratgy Line
def EMA1 = ExpAverage(c,SignalMALength1);
def EMA2 = ExpAverage(c,SignalMALength2);
def diff = c - o;
def UpperBand = StDev(diff, VolatilityLength);
def LowerBand = StDev(diff, VolatilityLength) * -1;
def Long = Signals2 and MSBar2Color>0 and ThinLine and ThinLine2 and TrendBar4Color1 and TrendBar5Color1 and diff>=UpperBand and EMA1>EMA2;
def short = Signals2 and MSBar2Color<0 and ThinLine and ThinLine2 and !TrendBar4Color1 and !TrendBar5Color1 and diff<=LowerBand and EMA1<EMA2;
plot LongSignal = if Long then 126 else na;
plot ShortSignal = if short then 126 else na;
LongSignal.SetPaintingStrategy(PaintingStrategy.POINTS);
LongSignal.SetDefaultColor(Color.GREEN);
LongSignal.SetLineWeight(5);
ShortSignal.SetPaintingStrategy(PaintingStrategy.POINTS);
ShortSignal.SetDefaultColor(Color.RED);
ShortSignal.SetLineWeight(5);
#// Background Highlights
AddCloud(if TrendBars3Positive then Double.NEGATIVE_INFINITY else if TrendBars3Negative then Double.POSITIVE_INFINITY else na, if TrendBars3Positive then Double.POSITIVE_INFINITY else if TrendBars3Negative then Double.NEGATIVE_INFINITY else na, Color.DARK_RED, Color.DARK_GREEN);
#---END Code
Add Price color option
CSS:
#// Created By Lij_MC
#// Use as a supplementary Indicator to confirm your entries, but it is as good on it's own.
#// The indicator consists of 3 different Trend Meters and a Trend Bar which are used to confirm trend
#// As a bonus Wave Trend Signals are marked as well, these are very powerful however please use with caution
#// How to Use
#// Look for Support or Resistance Levels for price to be attracted to
#// Find confluence with other indicators
#// Enter Long above the Setup Bar
#// Enter Short Below the Setup Bar
#study(title="Trend Meter")
# Converted and mod by Sam4Cok@Samer800 - 10/2022
# Added Price Color option by Sam4Cok@Samer800 - 11/2022 as requested from useThinkScript.com member
declare lower;
#// Inputs / Menus
#// Trend Bar / Meter - Inputs / Menus
input ColorBars = no;
input VolatilityLength = 100;
input SignalMALength1 = 20;
input SignalMALength2 = 50;
input ShowTrendBar = yes;
input UseChartTimeFrame = yes;
input Aggregation = AggregationPeriod.DAY;
#// MA Inputs
input ma1_Length = 5; # 'Fast MA'
input ma1_Type = {default "EMA", "SMA"}; # "TB1 Fast"
input ma2_Length = 11; # 'Slow MA'
input ma2_Type = {default "EMA", "SMA"}; # "TB1 Slow"
input ma3_Length = 13; # 'Fast MA'
input ma3_Type = { default "EMA", "SMA"}; # "TB2 Fast"
input ma4_Length = 29; # 'Slow MA'
input ma4_Type = {"EMA", default "SMA"}; # "TB2 Slow"
#--Trend inputs
input WaveTrendSignalLine = no; # "Wave Trend Filtered by Trend"
input TrendMeterLine = yes; # "All 3 Trend Meters Now Align"
input Filter1 = {"N/A", default "Trend Filter", "Filter X", "Filter X + Trend Filter"};#WT Signals
input Filter2 = {"N/A", default "Trend Filter", "Filter X", "Filter X + Trend Filter"};#WT Signals
input TrendMeter1 = {"MACD Crossover - 12, 26, 9", default "MACD Crossover - Fast - 8, 21, 5", "Mom Dad Cross (Top Dog Trading)", "RSI Signal Line Cross - RSI 13, Sig 21", "RSI 13: > or < 50", "RSI 5: > or < 50", "Trend Candles", "DAD Direction (Top Dog Trading)", "MA Crossover", "N/A"};#"Trend Meter1"
input TrendMeter2 = {"MACD Crossover - 12, 26, 9", "MACD Crossover - Fast - 8, 21, 5", "Mom Dad Cross (Top Dog Trading)", "RSI Signal Line Cross - RSI 13, Sig 21", default "RSI 13: > or < 50", "RSI 5: > or < 50", "Trend Candles", "DAD Direction (Top Dog Trading)", "MA Crossover", "N/A"};#"Trend Meter 2"
input TrendMeter3 = {"MACD Crossover - 12, 26, 9", "MACD Crossover - Fast - 8, 21, 5", "Mom Dad Cross (Top Dog Trading)", "RSI Signal Line Cross - RSI 13, Sig 21", "RSI 13: > or < 50", default "RSI 5: > or < 50", "Trend Candles", "DAD Direction (Top Dog Trading)", "MA Crossover", "N/A"};#"Trend Meter 3"
input TrendBar1 = {default "MA Crossover", "MA Direction - Fast MA - TB1", "MA Direction - Slow MA - TB1", "DAD Direction (Top Dog Trading)", "MACD Crossover", "N/A"};#"Trend Bar 1"
input TrendBar2 = {default "MA Crossover", "MA Direction - Fast MA - TB2", "MA Direction - Slow MA - TB2", "DAD Direction (Top Dog Trading)", "MACD Crossover", "N/A"};#"Trend Bar 2"
def na = Double.NaN;
def agg = GetAggregationPeriod();
def c = if UseChartTimeFrame then close else close(Period = Aggregation);
def o = if UseChartTimeFrame then open else open(Period = Aggregation);
;
#---Color
DefineGlobalColor("green" , CreateColor(40, 138, 117));
DefineGlobalColor("Red" , CreateColor(255, 82, 82));
#// Wave Trend - RSI
def RSIMC = RSI(price = c, Length = 14);
#// Wave Trend
def ap = if UseChartTimeFrame then hlc3 else hlc3(Period = Aggregation) ; # "Wave Trend - Source"
def n1 = 9; # "Wave Trend - WT Channel Length"
def n2 = 12; # "Wave Trend - WT Average Length"
def esa = ExpAverage(ap, n1);
def de = ExpAverage(AbsValue(ap - esa), n1);
def ci = (ap - esa) / (0.015 * de);
def tci = ExpAverage(ci, n2);
def wt1 = tci;
def wt2 = SimpleMovingAvg(wt1, 3);
#// Wave Trend - Overbought & Oversold lines
def obLevel2 = 60; # "Wave Trend - WT Very Overbought")
def obLevel = 50; # "Wave Trend - WT Overbought")
def osLevel = -50; # "Wave Trend - WT Oversold")
def osLevel2 = -60; # "Wave Trend - WT Very Oversold")
#// Wave Trend - Conditions
def WTCross = Crosses(wt1, wt2);
def WTCrossUp = wt2 - wt1 <= 0;
def WTCrossDown = wt2 - wt1 >= 0;
def WTOverSold = wt2 <= osLevel2;
def WTOverBought = wt2 >= obLevel2;
#// MA Calculations
def MA1 = if ma1_Type == ma1_Type."SMA" then
SimpleMovingAvg(c, ma1_Length) else ExpAverage(c, ma1_Length);
def MA2 = if ma2_Type == ma2_Type."SMA" then
SimpleMovingAvg(c, ma2_Length) else ExpAverage(c, ma2_Length);
def MA3 = if ma3_Type == ma3_Type."SMA" then
SimpleMovingAvg(c, ma3_Length) else ExpAverage(c, ma3_Length);
def MA4 = if ma4_Type == ma4_Type."SMA" then
SimpleMovingAvg(c, ma4_Length) else ExpAverage(c, ma4_Length);
#// MA Crossover Condition
def MACrossover1 = if MA1 > MA2 then 1 else 0;
def MACrossover2 = if MA3 > MA4 then 1 else 0;
#// MA Direction Condition
def MA1Direction = if MA1 > MA1[1] then 1 else 0;
def MA2Direction = if MA2 > MA2[1] then 1 else 0;
def MA3Direction = if MA3 > MA3[1] then 1 else 0;
def MA4Direction = if MA4 > MA4[1] then 1 else 0;
#// MA Direction Change Condition
def MA1PositiveDirectionChange = if MA1Direction and !MA1Direction[1] then 1 else 0;
def MA2PositiveDirectionChange = if MA2Direction and !MA2Direction[1] then 1 else 0;
def MA3PositiveDirectionChange = if MA3Direction and !MA3Direction[1] then 1 else 0;
def MA4PositiveDirectionChange = if MA4Direction and !MA4Direction[1] then 1 else 0;
def MA1NegativeDirectionChange = if !MA1Direction and MA1Direction[1] then 1 else 0;
def MA2NegativeDirectionChange = if !MA2Direction and MA2Direction[1] then 1 else 0;
def MA3NegativeDirectionChange = if !MA3Direction and MA3Direction[1] then 1 else 0;
def MA4NegativeDirectionChange = if !MA4Direction and MA4Direction[1] then 1 else 0;
#// MACD and MOM & DAD - Top Dog Trading
#// Standard MACD Calculations
def MACDfastMA = 12;
def MACDslowMA = 26;
def MACDsignalSmooth = 9;
def MACDLine = ExpAverage(c, MACDfastMA) - ExpAverage(c, MACDslowMA);
def SignalLine = ExpAverage(MACDLine, MACDsignalSmooth);
def MACDHistogram = MACDLine - SignalLine;
#// MACD- Background Color Change Condition
def MACDHistogramCross = if MACDHistogram > 0 then 1 else 0;
def MACDLineOverZero = if MACDLine > 0 then 1 else 0;
def MACDLineOverZeroandHistogramCross = if MACDHistogramCross and MACDLineOverZero then 1 else 0;
def MACDLineUnderZeroandHistogramCross = if !MACDHistogramCross and !MACDLineOverZero then 1 else 0;
#// Fast MACD Calculations
def FastMACDfastMA = 8;
def FastMACDslowMA = 21;
def FastMACDsignalSmooth = 5;
def FastMACDLine = ExpAverage(c, FastMACDfastMA) - ExpAverage(c, FastMACDslowMA);
def FastSignalLine = ExpAverage(FastMACDLine, FastMACDsignalSmooth);
def FastMACDHistogram = FastMACDLine - FastSignalLine;
#// Fast MACD- Background Color Change Condition
def FastMACDHistogramCross = if FastMACDHistogram > 0 then 1 else 0;
def FastMACDLineOverZero = if FastMACDLine > 0 then 1 else 0;
def FastMACDLineOverZeroandHistogramCross = if FastMACDHistogramCross and FastMACDLineOverZero then 1 else 0;
def FastMACDLineUnderZeroandHistogramCross = if !FastMACDHistogramCross and !FastMACDLineOverZero then 1 else 0;
#// Top Dog Trading - Mom Dad Calculations
def TopDog_Fast_MA = 5;
def TopDog_Slow_MA = 20;
def TopDog_Sig = 30;
def TopDogMom = ExpAverage(c, TopDog_Fast_MA) - ExpAverage(c, TopDog_Slow_MA);
def TopDogDad = ExpAverage(TopDogMom, TopDog_Sig);
#// Top Dog Dad - Background Color Change Condition
def TopDogDadDirection = If(TopDogDad > TopDogDad[1], 1, 0);
def TopDogMomOverDad = If(TopDogMom > TopDogDad, 1, 0);
def TopDogMomOverZero = If(TopDogMom > 0, 1, 0);
def TopDogDadDirectandMomOverZero = If(TopDogDadDirection and TopDogMomOverZero, 1, 0);
def TopDogDadDirectandMomUnderZero = If(!TopDogDadDirection and !TopDogMomOverZero, 1, 0);
#////// Trend Barmeter Calculations //////
#// UCS_Trend / Trend Candles Trend Barmeter Calculations
#//UCS_Trend by ucsgears copy Trend Candles
#//Interpretation of TTM Trend bars. It is really close to the actual.
def haclose = if UseChartTimeFrame then ohlc4 else ohlc4(Period = Aggregation);
def haopen = if IsNaN(haopen[1]) then (o + c) / 2 else (haopen[1] + haclose[1]) / 2;
def ccolor = If(haclose - haopen > 0, 1, 0);
def inside6 = If(haopen <= Max(haopen[6], haclose[6]) and haopen >= Min(haopen[6], haclose[6]) and
haclose <= Max(haopen[6], haclose[6]) and haclose >= Min(haopen[6], haclose[6]), 1, 0);
def inside5 = If(haopen <= Max(haopen[5], haclose[5]) and haopen >= Min(haopen[5], haclose[5]) and
haclose <= Max(haopen[5], haclose[5]) and haclose >= Min(haopen[5], haclose[5]), 1, 0);
def inside4 = If(haopen <= Max(haopen[4], haclose[4]) and haopen >= Min(haopen[4], haclose[4]) and
haclose <= Max(haopen[4], haclose[4]) and haclose >= Min(haopen[4], haclose[4]), 1, 0);
def inside3 = If(haopen <= Max(haopen[3], haclose[3]) and haopen >= Min(haopen[3], haclose[3]) and
haclose <= Max(haopen[3], haclose[3]) and haclose >= Min(haopen[3], haclose[3]), 1, 0);
def inside2 = If(haopen <= Max(haopen[2], haclose[2]) and haopen >= Min(haopen[2], haclose[2]) and
haclose <= Max(haopen[2], haclose[2]) and haclose >= Min(haopen[2], haclose[2]), 1, 0);
def inside1 = If(haopen <= Max(haopen[1], haclose[1]) and haopen >= Min(haopen[1], haclose[1]) and
haclose <= Max(haopen[1], haclose[1]) and haclose >= Min(haopen[1], haclose[1]), 1, 0);
def colorvalue = if inside6 then ccolor[6] else if inside5 then ccolor[5] else if inside4 then ccolor[4] else if inside3 then ccolor[3] else if inside2 then ccolor[2] else if inside1 then ccolor[1] else ccolor;
def TrendBarTrend_Candle = if colorvalue then 1 else 0;
#// RSI 5 Trend Barmeter Calculations
def RSI5 = RSI(Price = c, Length = 5);
def RSI5Above50 = if RSI5 > 50 then 1 else 0;
def RSI5Color = if RSI5Above50 then 1 else 0;# ? #288a75 : color.red
#// RSI 5 Trend Barmeter Calculations
def RSI13 = RSI(Price = c, Length = 13);
#// Linear Regression Calculation For RSI Signal Line
def SignalLineLength1 = 21;
def x = BarNumber();
def y = RSI13;
def x_ = SimpleMovingAvg(x, SignalLineLength1);
def y_ = SimpleMovingAvg(y, SignalLineLength1);
def mx = StDev(x, SignalLineLength1);
def my = StDev(y, SignalLineLength1);
def corr = Correlation(x, y, SignalLineLength1);
def slope = corr * (my / mx);
def inter = y_ - slope * x_;
def LinReg1 = x * slope + inter;
def RSISigDirection = If(LinReg1 > LinReg1[1], 1, 0);
def RSISigCross = If(RSI13 > LinReg1, 1, 0);
def RSI13Above50 = If(RSI13 > 50, 1, 0);
#// Trend Barmeter Color Calculation
#RSI13Color = RSI13Above50 ? #288a75 : color.red
def TrendBarRSI13Color = If(RSI13Above50, 1, 0);
def TrendBarRSISigCrossColor = If(RSISigCross, 1, 0);
def TrendBarMACDColor = If(MACDHistogramCross, 1, 0);
def TrendBarFastMACDColor = If(FastMACDHistogramCross, 1, 0);
def TrendBarMACrossColor = If(MACrossover1, 1, 0);
def TrendBarMomOverDadColor = If(TopDogMomOverDad, 1, 0);
def TrendBarDadDirectionColor = If(TopDogDadDirection, 1, 0);
def TrendBar1Result = if TrendMeter1 == TrendMeter1."MA Crossover" then MACrossover1 else if
TrendMeter1 == TrendMeter1."MACD Crossover - 12, 26, 9" then MACDHistogramCross else if
TrendMeter1 == TrendMeter1."MACD Crossover - Fast - 8, 21, 5" then FastMACDHistogramCross else if
TrendMeter1 == TrendMeter1."Mom Dad Cross (Top Dog Trading)" then TopDogMomOverDad else if
TrendMeter1 == TrendMeter1."DAD Direction (Top Dog Trading)" then TopDogDadDirection else if
TrendMeter1 == TrendMeter1."RSI Signal Line Cross - RSI 13, Sig 21" then RSISigCross else if
TrendMeter1 == TrendMeter1."RSI 5: > or < 50" then RSI5Above50 else if
TrendMeter1 == TrendMeter1."RSI 13: > or < 50" then RSI13Above50 else if
TrendMeter1 == TrendMeter1."Trend Candles" then TrendBarTrend_Candle else na;
def TrendBar2Result = if TrendMeter2 == TrendMeter2."MA Crossover" then MACrossover1 else if
TrendMeter2 == TrendMeter2."MACD Crossover - 12, 26, 9" then MACDHistogramCross else if
TrendMeter2 == TrendMeter2."MACD Crossover - Fast - 8, 21, 5" then FastMACDHistogramCross else if
TrendMeter2 == TrendMeter2."Mom Dad Cross (Top Dog Trading)" then TopDogMomOverDad else if
TrendMeter2 == TrendMeter2."DAD Direction (Top Dog Trading)" then TopDogDadDirection else if
TrendMeter2 == TrendMeter2."RSI Signal Line Cross - RSI 13, Sig 21" then RSISigCross else if
TrendMeter2 == TrendMeter2."RSI 5: > or < 50" then RSI5Above50 else if
TrendMeter2 == TrendMeter2."RSI 13: > or < 50" then RSI13Above50 else if
TrendMeter2 == TrendMeter2."Trend Candles" then TrendBarTrend_Candle else na;
def TrendBar3Result = if TrendMeter3 == TrendMeter3."MA Crossover" then MACrossover1 else if
TrendMeter3 == TrendMeter3."MACD Crossover - 12, 26, 9" then MACDHistogramCross else if
TrendMeter3 == TrendMeter3."MACD Crossover - Fast - 8, 21, 5" then FastMACDHistogramCross else if
TrendMeter3 == TrendMeter3."Mom Dad Cross (Top Dog Trading)" then TopDogMomOverDad else if
TrendMeter3 == TrendMeter3."DAD Direction (Top Dog Trading)" then TopDogDadDirection else if
TrendMeter3 == TrendMeter3."RSI Signal Line Cross - RSI 13, Sig 21" then RSISigCross else if
TrendMeter3 == TrendMeter3."RSI 5: > or < 50" then RSI5Above50 else if
TrendMeter3 == TrendMeter3."RSI 13: > or < 50" then RSI13Above50 else if
TrendMeter3 == TrendMeter3."Trend Candles" then TrendBarTrend_Candle else na;
def TrendBars2Positive = If(TrendBar1Result and TrendBar2Result or TrendBar1Result and
TrendBar3Result or TrendBar2Result and TrendBar3Result, 1, 0);
def TrendBars2Negative = If(!TrendBar1Result and !TrendBar2Result or !TrendBar1Result and
!TrendBar3Result or !TrendBar2Result and !TrendBar3Result, 1, 0);
def TrendBars3Positive = If(TrendBar1Result and TrendBar2Result and TrendBar3Result, 1, 0);
def TrendBars3Negative = If(!TrendBar1Result and !TrendBar2Result and !TrendBar3Result, 1, 0);
#// Signal Filters
def FilterXUp = FastMACDHistogramCross and ExpAverage(c, 15) > ExpAverage(c, 15)[1];
def FilterXDown = !FastMACDHistogramCross and ExpAverage(c, 15) < ExpAverage(c, 15)[1];
def TrendFilterPlus = If(ExpAverage(c, 15) > ExpAverage(c, 20) and ExpAverage(c, 20) > ExpAverage(c, 30) and ExpAverage(c, 30) > ExpAverage(c, 40) and ExpAverage(c, 40) > ExpAverage(c, 50), 1, 0);
def TrendFilterMinus = If(ExpAverage(c, 15) < ExpAverage(c, 20) and ExpAverage(c, 20) < ExpAverage(c, 30) and ExpAverage(c, 30) < ExpAverage(c, 40) and ExpAverage(c, 40) < ExpAverage(c, 50), 1, 0);
#// // Wave Trend - Conditions
def MSBar1PositiveWaveTrendSignal =
if Filter1 == Filter1."Filter X" then FilterXUp and WTCross and WTCrossUp else if
Filter1 == Filter1."Trend Filter" then TrendFilterPlus and WTCross and WTCrossUp else if
Filter1 == Filter1."Filter X + Trend Filter" then
FilterXUp and TrendFilterPlus and WTCross and WTCrossUp else WTCross and WTCrossUp;
def MSBar1NegativeWaveTrendSignal =
if Filter1 == Filter1."Filter X" then FilterXDown and WTCross and WTCrossDown else if
Filter1 == Filter1."Trend Filter" then TrendFilterMinus and WTCross and WTCrossDown else if
Filter1 == Filter1."Filter X + Trend Filter" then
FilterXDown and TrendFilterMinus and WTCross and WTCrossDown else
WTCross and WTCrossDown;
def MSBar2PositiveWaveTrendSignal =
if Filter2 == Filter2."Filter X" then FilterXUp and WTCross and WTCrossUp else if
Filter2 == Filter2."Trend Filter" then TrendFilterPlus and WTCross and WTCrossUp else if
Filter2 == Filter2."Filter X + Trend Filter" then
FilterXUp and TrendFilterPlus and WTCross and WTCrossUp else WTCross and WTCrossUp;
def MSBar2NegativeWaveTrendSignal =
if Filter2 == Filter2."Filter X" then FilterXDown and WTCross and WTCrossDown else if
Filter2 == Filter2."Trend Filter" then TrendFilterMinus and WTCross and WTCrossDown else if
Filter2 == Filter2."Filter X + Trend Filter" then
FilterXDown and TrendFilterMinus and WTCross and WTCrossDown else WTCross and WTCrossDown;
#////////////////////////
def BackgroundColorChangePositive = TrendBars3Positive and !TrendBars3Positive[1];
def BackgroundColorChangeNegative = TrendBars3Negative and !TrendBars3Negative[1];
#// Signals Color Calculations
def MSBar1Color = if MSBar1PositiveWaveTrendSignal then 1 else
if MSBar1NegativeWaveTrendSignal then -1 else na;#
def MSBar2Color = if BackgroundColorChangePositive then 1 else
if BackgroundColorChangeNegative then -1 else na;
#// Trend Barmeter Color Assignments
def TrendBar1Color =
if TrendMeter1 == TrendMeter1."N/A" then na else if
TrendMeter1 == TrendMeter1."MACD Crossover - 12, 26, 9" then TrendBarMACDColor else if
TrendMeter1 == TrendMeter1."MACD Crossover - Fast - 8, 21, 5" then TrendBarFastMACDColor else if
TrendMeter1 == TrendMeter1."Mom Dad Cross (Top Dog Trading)" then TrendBarMomOverDadColor else if
TrendMeter1 == TrendMeter1."DAD Direction (Top Dog Trading)" then TrendBarDadDirectionColor else if
TrendMeter1 == TrendMeter1."RSI Signal Line Cross - RSI 13, Sig 21" then TrendBarRSISigCrossColor else if
TrendMeter1 == TrendMeter1."RSI 5: > or < 50" then RSI5Color else if
TrendMeter1 == TrendMeter1."RSI 13: > or < 50" then TrendBarRSI13Color else if
TrendMeter1 == TrendMeter1."Trend Candles" then TrendBarTrend_Candle else if
TrendMeter1 == TrendMeter1."MA Crossover" then TrendBarMACrossColor else na;
def TrendBar2Color =
if TrendMeter2 == TrendMeter2."N/A" then na else if
TrendMeter2 == TrendMeter2."MACD Crossover - 12, 26, 9" then TrendBarMACDColor else if
TrendMeter2 == TrendMeter2."MACD Crossover - Fast - 8, 21, 5" then TrendBarFastMACDColor else if
TrendMeter2 == TrendMeter2."Mom Dad Cross (Top Dog Trading)" then TrendBarMomOverDadColor else if
TrendMeter2 == TrendMeter2."DAD Direction (Top Dog Trading)" then TrendBarDadDirectionColor else if
TrendMeter2 == TrendMeter2."RSI Signal Line Cross - RSI 13, Sig 21" then TrendBarRSISigCrossColor else if
TrendMeter2 == TrendMeter2."RSI 5: > or < 50" then RSI5Color else if
TrendMeter2 == TrendMeter2."RSI 13: > or < 50" then TrendBarRSI13Color else if
TrendMeter2 == TrendMeter2."Trend Candles" then TrendBarTrend_Candle else if
TrendMeter2 == TrendMeter2."MA Crossover" then TrendBarMACrossColor else na;
def TrendBar3Color =
if TrendMeter3 == TrendMeter3."N/A" then na else if
TrendMeter3 == TrendMeter3."MACD Crossover - 12, 26, 9" then TrendBarMACDColor else if
TrendMeter3 == TrendMeter3."MACD Crossover - Fast - 8, 21, 5" then TrendBarFastMACDColor else if
TrendMeter3 == TrendMeter3."Mom Dad Cross (Top Dog Trading)" then TrendBarMomOverDadColor else if
TrendMeter3 == TrendMeter3."DAD Direction (Top Dog Trading)" then TrendBarDadDirectionColor else if
TrendMeter3 == TrendMeter3."RSI Signal Line Cross - RSI 13, Sig 21" then TrendBarRSISigCrossColor else if
TrendMeter3 == TrendMeter3."RSI 5: > or < 50" then RSI5Color else if
TrendMeter3 == TrendMeter3."RSI 13: > or < 50" then TrendBarRSI13Color else if
TrendMeter3 == TrendMeter3."Trend Candles" then TrendBarTrend_Candle else if
TrendMeter3 == TrendMeter3."MA Crossover" then TrendBarMACrossColor else na;
def CrossoverType2 =
if TrendBar1 == TrendBar1."DAD Direction (Top Dog Trading)" then TopDogDadDirection else if
TrendBar1 == TrendBar1."MACD Crossover" then MACDHistogramCross else if
TrendBar1 == TrendBar1."MA Direction - Fast MA - TB1" then MA1Direction else if
TrendBar1 == TrendBar1."MA Direction - Slow MA - TB1" then MA2Direction else MACrossover1;
def TrendBar4Color1 = if TrendBar1 == TrendBar1."N/A" then na else
if CrossoverType2 then 1 else 0;
def CrossoverType3 =
if TrendBar2 == TrendBar2."DAD Direction (Top Dog Trading)" then TopDogDadDirection else if
TrendBar2 == TrendBar2."MACD Crossover" then MACDHistogramCross else if
TrendBar2 == TrendBar2."MA Direction - Fast MA - TB2" then MA3Direction else if
TrendBar2 == TrendBar2."MA Direction - Slow MA - TB2" then MA4Direction else MACrossover2;
def TrendBar5Color1 = if TrendBar2 == TrendBar2."N/A" then na else
if CrossoverType3 then 1 else 0;
#// Momentum Setup Plots
plot Signals1 = If(IsNaN(c) or IsNaN(MSBar1Color), na, If(ShowTrendBar and WaveTrendSignalLine, 129, na)); # "Signals 1 - Wave Trend Signals"
Signals1.SetPaintingStrategy(PaintingStrategy.SQUARES);
Signals1.AssignValueColor(if MSBar1Color > 0 then GlobalColor("green") else GlobalColor("RED"));
plot Signals2 = If(IsNaN(c) or IsNaN(MSBar2Color), na, If(ShowTrendBar and TrendMeterLine, 126, na)); # "Signals 2 - All 3 Trend Meters Now Align"
Signals2.SetPaintingStrategy(PaintingStrategy.POINTS);
Signals2.AssignValueColor(if MSBar2Color > 0 then GlobalColor("green") else GlobalColor("RED"));
#// Trend Barmeter Plots
plot TM1 = If(IsNaN(c), na, If(ShowTrendBar, 123, na)); # "Trend Meter 1"
TM1.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
TM1.AssignValueColor(if TrendBar1Color then GlobalColor("green") else GlobalColor("RED"));
plot TM2 = If(IsNaN(c), na, If(ShowTrendBar, 120.5, na));# "Trend Meter 2"
TM2.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
TM2.AssignValueColor(if TrendBar2Color then GlobalColor("green") else GlobalColor("RED"));
plot TM3 = If(IsNaN(c), na, If(ShowTrendBar, 118, na));# "Trend Meter 3"
TM3.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
TM3.AssignValueColor(if TrendBar3Color then GlobalColor("green") else GlobalColor("RED"));
plot ThinLine = If(IsNaN(c), na, If(ShowTrendBar and !(TrendBar2 == TrendBar2."N/A"), 115, na));
ThinLine.AssignValueColor(if TrendBar4Color1 then Color.GREEN else Color.RED);
ThinLine.SetLineWeight(2);
plot ThikLine = If(IsNaN(c), na, If(ShowTrendBar and TrendBar2 == TrendBar2."N/A" and !(TrendBar1 == TrendBar1."N/A"), 107.25, na));
ThikLine.AssignValueColor(if TrendBar4Color1 then Color.GREEN else Color.RED);
ThikLine.SetLineWeight(5);
plot ThinLine2 = If(IsNaN(c), na, If(ShowTrendBar and !(TrendBar1 == TrendBar1."N/A"), 112.5, na));
ThinLine2.AssignValueColor(if TrendBar5Color1 then Color.GREEN else Color.RED);
ThinLine2.SetLineWeight(2);
plot ThikLine2 = If(IsNaN(c), na, If(ShowTrendBar and TrendBar1 == TrendBar1."N/A" and !(TrendBar2 == TrendBar2."N/A"), 107.25, na));
ThikLine2.AssignValueColor(if TrendBar5Color1 then Color.GREEN else Color.RED);
ThikLine2.SetLineWeight(5);
#--- Stratgy Line
def EMA1 = ExpAverage(c,SignalMALength1);
def EMA2 = ExpAverage(c,SignalMALength2);
def diff = c - o;
def UpperBand = StDev(diff, VolatilityLength);
def LowerBand = StDev(diff, VolatilityLength) * -1;
def Long = Signals2 and MSBar2Color>0 and ThinLine and ThinLine2 and TrendBar4Color1 and TrendBar5Color1 and diff>=UpperBand and EMA1>EMA2;
def short = Signals2 and MSBar2Color<0 and ThinLine and ThinLine2 and !TrendBar4Color1 and !TrendBar5Color1 and diff<=LowerBand and EMA1<EMA2;
plot LongSignal = if Long then 126 else na;
plot ShortSignal = if short then 126 else na;
LongSignal.SetPaintingStrategy(PaintingStrategy.POINTS);
LongSignal.SetDefaultColor(Color.GREEN);
LongSignal.SetLineWeight(5);
ShortSignal.SetPaintingStrategy(PaintingStrategy.POINTS);
ShortSignal.SetDefaultColor(Color.RED);
ShortSignal.SetLineWeight(5);
#// Background Highlights
AddCloud(if TrendBars3Positive then Double.NEGATIVE_INFINITY else if TrendBars3Negative then Double.POSITIVE_INFINITY else na, if TrendBars3Positive then Double.POSITIVE_INFINITY else if TrendBars3Negative then Double.NEGATIVE_INFINITY else na, Color.DARK_RED, Color.DARK_GREEN);
#--- BarColor
AssignPriceColor(if !ColorBars then Color.CURRENT else
if TrendBars3Positive and CrossoverType2 and CrossoverType3 then Color.GREEN else
if TrendBars3Positive and (!CrossoverType2 or !CrossoverType3) then Color.DARK_GREEN else
if TrendBars3Negative and !CrossoverType2 and !CrossoverType3 then Color.RED else
if TrendBars3Negative and (!CrossoverType2 or !CrossoverType3) then Color.DARK_RED else Color.GRAY);
#---END Code
Last edited by a moderator: