Hello, added mtf.
Re: Already Converted TradingView Indicators to MT4 Indicators
631- These users thanked the author mrtools for the post (total 7):
- Jimmy, Krunal Gajjar, thomdel, MeNiazi, Akela, talaate, macd & rsi
Hello, added mtf.
Code: Select all
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RedKTrader
//@version=5
indicator('RedK Dual VADER with Energy Bars [VADER-DEB]', 'RedK VADER-DEB v5.0', precision=0, timeframe='', timeframe_gaps=false)
// This version is the same as VADER v3.0 with enhanced visuals, using Energy Bars instead of the positive/energy lines
// Sentiment plot changed from histogram to area and is exposed by default (hence Dual w/ Energy Bars -- DEB)
// No change in core calculations from VADER v4.0 -- and that's why i'll just call it VADER v4.0
// ***********************************************************************************************************
// Choose MA type for the base DER calculation ..
// WMA is my preference and is default .. SMA is really slow and lags a lot - but added for comparison
f_derma(_data, _len, MAOption) =>
value =
MAOption == 'SMA' ? ta.sma(_data, _len) :
MAOption == 'EMA' ? ta.ema(_data, _len) :
ta.wma(_data, _len)
// ***********************************************************************************************************
// ===========================================================================================================
// Inputs
// ===========================================================================================================
price = close
length = input.int(10, minval=1)
DER_avg = input.int(5, 'Average', minval=1, inline='DER', group='Directional Energy Ratio')
MA_Type = input.string('WMA', 'DER MA type', options=['WMA', 'EMA', 'SMA'], inline='DER', group='Directional Energy Ratio')
smooth = input.int(3, 'Smooth', minval=1, inline='DER_1', group='Directional Energy Ratio')
show_senti = input.bool(true, 'Sentiment', inline='DER_s', group='Directional Energy Ratio')
senti = input.int(20, 'Length', minval=1, inline='DER_s', group='Directional Energy Ratio')
v_calc = input.string('Relative', 'Calculation', options=['Relative', 'Full', 'None'], group='Volume Parameters')
vlookbk = input.int(20, 'Lookback (for Relative)', minval=1, group='Volume Parameters')
// ===========================================================================================================
// Calculations
// ===========================================================================================================
// Volume Calculation Option -- will revert to no volume acceleration for instruments with no volume data
v = volume
vola =
v_calc == 'None' or na(volume) ? 1 :
v_calc == 'Relative' ? ta.stoch(v, v, v, vlookbk) / 100 :
v
R = (ta.highest(2) - ta.lowest(2)) / 2 // R is the 2-bar average bar range - this method accomodates bar gaps
sr = ta.change(price) / R // calc ratio of change to R
rsr = math.max(math.min(sr, 1), -1) // ensure ratio is restricted to +1/-1 in case of big moves
c = fixnan(rsr * vola) // add volume accel -- fixnan adresses cases where no price change between bars
c_plus = math.max(c, 0) // calc directional vol-accel energy
c_minus = -math.min(c, 0)
// plot(c_plus)
// plot(c_minus)
avg_vola = f_derma(vola, length, MA_Type)
dem = f_derma(c_plus, length, MA_Type) / avg_vola // directional energy ratio
sup = f_derma(c_minus, length, MA_Type) / avg_vola
adp = 100 * ta.wma(nz(dem), DER_avg) // average DER
asp = 100 * ta.wma(nz(sup), DER_avg)
anp = adp - asp // net DER..
anp_s = ta.wma(anp, smooth)
// Calculate Sentiment - a VADER for a longer period and can act as a baseline (compared to a static 0 value)
// note we're not re-calculating vol_avg, demand or supply energy for sentiment. this would've been a different approach
s_adp = 100 * ta.wma(nz(dem), senti) // average DER for sentiment length
s_asp = 100 * ta.wma(nz(sup), senti)
V_senti = ta.wma(s_adp - s_asp, smooth)
// ===========================================================================================================
// Colors & plots
// ===========================================================================================================
c_adp = color.new(#11ff20, 30)
c_asp = color.new(#ff1111, 30)
c_fd = color.new(color.green, 80)
c_fs = color.new(color.red, 80)
c_zero = color.new(#ffee00, 70)
c_up = color.new(#11ff20, 0)
c_dn = color.new(#ff1111, 0)
up = anp_s >= 0
s_up = V_senti >=0
hline(0, 'Zero Line', c_zero, hline.style_solid)
// =============================================================================
// v4.0 --- Sentiment will be represented as a 4-color area graph
c_grow_above = #1b5e2080
c_grow_below = #dc4c4a80
c_fall_above = #66bb6a80
c_fall_below = #ef8e9880
sflag_up = math.abs(V_senti) >= math.abs(V_senti[1])
plot(show_senti ? V_senti : na, "Sentiment", style=plot.style_area,
color = s_up ? (sflag_up ? c_grow_above : c_fall_above) :
sflag_up ? c_grow_below : c_fall_below)
// ===========================================================================================================
// v4.0 Use Energy Bars instead of DER lines
// ===========================================================================================================
// Prep the Energy Bars
bo = fixnan(asp)
bc = fixnan(adp)
bh = math.max(bo, bc)
bl = math.min(bo, bc)
rising = ta.change(bc) > 0
c_barup = #11ff2088
c_bardn = #ff111188
c_bardj = #ffffff88
barcolor = bc > bo and rising ? c_barup : bc < bo and not rising ? c_bardn : c_bardj
plotcandle(bo, bh, bl, bc, 'Energy Bars', barcolor, barcolor, bordercolor = barcolor)
// ============================================================================================================
s = plot(asp, 'Supply Energy', c_asp, 2, display = display.none)
d = plot(adp, 'Demand Energy', c_adp, 2, display = display.none)
plot(anp, 'VADER', color.new(color.gray, 30), display=display.none)
plot(anp_s, 'Signal', up ? c_up : c_dn, 4)
// ===========================================================================================================
// v2.0 adding alerts
// ===========================================================================================================
Alert_up = ta.crossover(anp_s,0)
Alert_dn = ta.crossunder(anp_s,0)
Alert_swing = ta.cross(anp_s,0)
// "." in alert title for the alerts to show in the right order up/down/swing
alertcondition(Alert_up, ". VADER Crossing 0 Up", "VADER Up - Buying Energy Detected!")
alertcondition(Alert_dn, ".. VADER Crossing 0 Down", "VADER Down - Selling Energy Detected!")
alertcondition(Alert_swing, "... VADER Crossing 0", "VADER Swing - Possible Reversal")
// ===========================================================================================================
// v3.0 more alerts for VADER crossing Sentiment
// ===========================================================================================================
v_speedup = ta.crossover(anp_s, V_senti)
v_slowdn = ta.crossunder(anp_s, V_senti)
alertcondition(v_speedup, "* VADER Speeding Up", "VADER Speeding Up!")
alertcondition(v_slowdn, "** VADER Slowing Down", "VADER Slowing Down!")
Please read the very first post before making a request in this topic.
Code: Select all
//@version=4
// 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 2 Trend Bars 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
//
// Be CAUTIOUS of trading BREAKOUTs as 9 out of 10 Breakouts Fail
//
// Find confluence with other indicators
//
// Enter Long above the Setup Bar
//
// Enter Short Below the Setup Bar
study(title="Trend Meter")
// Inputs / Menus
PosNegPressure = input(true, "Pos / Neg Pressure", tooltip= "Positive Pressure = RSI14 and Wave Trend Over Sold with WT Delta Pointing Up Negative Pressure = RSI14 and Wave Trend Over Bought with WT Delta Pointing Down", group = "Signals")
TMSetups = input(true, "Trend Meter Signal", tooltip="All 3 Trend Meters Now Align", group = "Signals")
TMSetupsANDWT = input(true, "Wave Trend Cross Aligns with Trend Meter Signal", group = "Signals")
TrendBar1 = input(title="Trend Meter 1", defval="MACD Crossover - Fast - 8, 21, 5", options=["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", "RSI 5: > or < 50", "Trend Candles", "N/A"], group = "Trend Meters") // "MA Crossover", "DAD Direction (Top Dog Trading)",
TrendBar2 = input(title="Trend Meter 2", defval="RSI 13: > or < 50", options=["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", "RSI 5: > or < 50", "Trend Candles", "N/A"], group = "Trend Meters") // "MA Crossover", "DAD Direction (Top Dog Trading)",
TrendBar3 = input(title="Trend Meter 3", defval="RSI 5: > or < 50", options=["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", "RSI 5: > or < 50", "Trend Candles", "N/A"], group = "Trend Meters") // "MA Crossover", "DAD Direction (Top Dog Trading)",
////////////////Signals - Wave Trend/////////////////////////////////////////////////////////////////////////////////////////////////
// Wave Trend - RSI
RSIMC = rsi(close, 14)
// Wave Trend
ap = hlc3 // input(hlc3, "Wave Trend - Source")
n1 = 9 //input(9, "Wave Trend - WT Channel Length")
n2 = 12 // input(12, "Wave Trend - WT Average Length")
esa = ema(ap, n1)
de = ema(abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * de)
tci = ema(ci, n2)
wt1 = tci
wt2 = sma(wt1, 3)
YellowWave= wt1 -wt2
// Wave Trend - Overbought & Oversold lines
obLevel2 = 60 // input( 60, "Wave Trend - WT Very Overbought")
obLevel = 50 // input( 50, "Wave Trend - WT Overbought")
osLevel = -50 // input(-50, "Wave Trend - WT Oversold")
osLevel2 = -60 // input(-60, "Wave Trend - WT Very Oversold")
// Wave Trend - Conditions
WTCross = cross(wt1, wt2)
WTCrossUp = wt2 - wt1 <= 0
WTCrossDown = wt2 - wt1 >= 0
WTOverSold = wt2 <= osLevel2
WTOverBought = wt2 >= obLevel2
// MA Inputs
ShowTrendBar1 = input(true, "Trend Bar 1", group = "Trend Bar 1", inline = "Trend Bar 1")
ShowTrendBar2 = input(true, "Trend Bar 2", group = "Trend Bar 2", inline = "Trend Bar 2")
TrendBar4 = input(title="", defval="MA Crossover", options=["MA Crossover", "MA Direction - Fast MA - TB1", "MA Direction - Slow MA - TB1"], group = "Trend Bar 1", inline = "Trend Bar 1") // "MACD Crossover - 12, 26 9", "MACD Crossover - Fast - 8, 21, 5", "DAD Direction (Top Dog Trading)",
TrendBar5 = input(title="", defval="MA Crossover", options=["MA Crossover", "MA Direction - Fast MA - TB2", "MA Direction - Slow MA - TB2"], group = "Trend Bar 2", inline = "Trend Bar 2") // "MACD Crossover - 12, 26 9", "MACD Crossover - Fast - 8, 21, 5", "DAD Direction (Top Dog Trading)",
MA1_Length = input(5, title='Fast MA', minval=1, group = "Trend Bar 1", inline = "TB1 Fast")
MA1_Type = input( title='', defval="EMA", options=["EMA", "SMA"], group = "Trend Bar 1", inline = "TB1 Fast")
MA2_Length = input(11, title='Slow MA', minval=1, group = "Trend Bar 1", inline = "TB1 Slow")
MA2_Type = input( title='', defval="EMA", options=["EMA", "SMA"], group = "Trend Bar 1", inline = "TB1 Slow")
MA3_Length = input(13, title='Fast MA', minval=1, group = "Trend Bar 2", inline = "TB2 Fast")
MA3_Type = input( title='', defval="EMA", options=["EMA", "SMA"], group = "Trend Bar 2", inline = "TB2 Fast")
MA4_Length = input(36, title='Slow MA', minval=1, group = "Trend Bar 2", inline = "TB2 Slow")
MA4_Type = input( title='', defval="SMA", options=["EMA", "SMA"], group = "Trend Bar 2", inline = "TB2 Slow")
// MA Calculations
Close = close //security(syminfo.tickerid, timeframe.period, close, barmerge.lookahead_off)
MA1 = if MA1_Type == "SMA"
sma(Close, MA1_Length)
else
ema(Close, MA1_Length)
MA2 = if MA2_Type == "SMA"
sma(Close, MA2_Length)
else
ema(Close, MA2_Length)
MA3 = if MA3_Type == "SMA"
sma(Close, MA3_Length)
else
ema(Close, MA3_Length)
MA4 = if MA4_Type == "SMA"
sma(Close, MA4_Length)
else
ema(Close, MA4_Length)
// MA Crossover Condition
MACrossover1 = MA1 > MA2 ? 1 : 0
MACrossover2 = MA3 > MA4 ? 1 : 0
// MA Direction Condition
MA1Direction = MA1 > MA1[1] ? 1 : 0
MA2Direction = MA2 > MA2[1] ? 1 : 0
MA3Direction = MA3 > MA3[1] ? 1 : 0
MA4Direction = MA4 > MA4[1] ? 1 : 0
// MA Direction Change Condition
MA1PositiveDirectionChange = MA1Direction and not MA1Direction[1] ? 1 : 0
MA2PositiveDirectionChange = MA2Direction and not MA2Direction[1] ? 1 : 0
MA3PositiveDirectionChange = MA3Direction and not MA3Direction[1] ? 1 : 0
MA4PositiveDirectionChange = MA4Direction and not MA4Direction[1] ? 1 : 0
MA1NegativeDirectionChange = not MA1Direction and MA1Direction[1] ? 1 : 0
MA2NegativeDirectionChange = not MA2Direction and MA2Direction[1] ? 1 : 0
MA3NegativeDirectionChange = not MA3Direction and MA3Direction[1] ? 1 : 0
MA4NegativeDirectionChange = not MA4Direction and MA4Direction[1] ? 1 : 0
// MACD and MOM & DAD - Top Dog Trading
// Standard MACD Calculations
MACDfastMA = 12
MACDslowMA = 26
MACDsignalSmooth = 9
MACDLine = ema(close, MACDfastMA) - ema(close, MACDslowMA)
SignalLine = ema(MACDLine, MACDsignalSmooth)
MACDHistogram = MACDLine - SignalLine
// MACD- Background Color Change Condition
MACDHistogramCross = MACDHistogram > 0 ? 1 : 0
MACDLineOverZero = MACDLine > 0 ? 1 : 0
MACDLineOverZeroandHistogramCross = MACDHistogramCross and MACDLineOverZero ? 1 : 0
MACDLineUnderZeroandHistogramCross = not MACDHistogramCross and not MACDLineOverZero ? 1 : 0
// Fast MACD Calculations
FastMACDfastMA = 8
FastMACDslowMA = 21
FastMACDsignalSmooth = 5
FastMACDLine = ema(close, FastMACDfastMA) - ema(close, FastMACDslowMA)
FastSignalLine = ema(FastMACDLine, FastMACDsignalSmooth)
FastMACDHistogram = FastMACDLine - FastSignalLine
// Fast MACD- Background Color Change Condition
FastMACDHistogramCross = FastMACDHistogram > 0 ? 1 : 0
FastMACDLineOverZero = FastMACDLine > 0 ? 1 : 0
FastMACDLineOverZeroandHistogramCross = FastMACDHistogramCross and FastMACDLineOverZero ? 1 : 0
FastMACDLineUnderZeroandHistogramCross = not FastMACDHistogramCross and not FastMACDLineOverZero ? 1 : 0
// Top Dog Trading - Mom Dad Calculations
TopDog_Fast_MA = 5
TopDog_Slow_MA = 20
TopDog_Sig = 30
TopDogMom = ema(close, TopDog_Fast_MA) - ema(close, TopDog_Slow_MA)
TopDogDad = ema(TopDogMom, TopDog_Sig)
// Top Dog Dad - Background Color Change Condition
TopDogDadDirection = TopDogDad > TopDogDad[1] ? 1 : 0
TopDogMomOverDad = TopDogMom > TopDogDad ? 1 : 0
TopDogMomOverZero = TopDogMom > 0 ? 1 : 0
TopDogDadDirectandMomOverZero = TopDogDadDirection and TopDogMomOverZero ? 1 : 0
TopDogDadDirectandMomUnderZero = not TopDogDadDirection and not 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.
haclose = ohlc4
haopen = 0.0
haopen := na(haopen[1]) ? (open + close) / 2 : (haopen[1] + haclose[1]) / 2
//hahigh = max(high, max(haopen, haclose))
//halow = min(low, min(haopen, haclose))
ccolor = haclose - haopen > 0 ? 1 : 0
inside6 = 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
inside5 = 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
inside4 = 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
inside3 = 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
inside2 = 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
inside1 = 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
colorvalue = inside6 ? ccolor[6] : inside5 ? ccolor[5] : inside4 ? ccolor[4] :
inside3 ? ccolor[3] : inside2 ? ccolor[2] : inside1 ? ccolor[1] : ccolor
TrendBarTrend_Candle_Color = colorvalue ? #288a75 : color.red
TrendBarTrend_Candle = colorvalue ? 1 : 0
// RSI 5 Trend Barmeter Calculations
RSI5 = rsi(close, 5)
RSI5Above50 = RSI5 > 50 ? 1 : 0
RSI5Color = RSI5Above50 ? #288a75 : color.red
TrendBarRSI5Color = RSI5Above50 ? #288a75 : color.red
// RSI 5 Trend Barmeter Calculations
RSI13 = rsi(close, 13)
// Linear Regression Calculation For RSI Signal Line
SignalLineLength1 = 21
x = bar_index
y = RSI13
x_ = sma(x, SignalLineLength1)
y_ = sma(y, SignalLineLength1)
mx = stdev(x, SignalLineLength1)
my = stdev(y, SignalLineLength1)
c = correlation(x, y, SignalLineLength1)
slope = c * (my / mx)
inter = y_ - slope * x_
LinReg1 = x * slope + inter
RSISigDirection = LinReg1 > LinReg1[1] ? 1 : 0
RSISigCross = RSI13 > LinReg1 ? 1 : 0
RSI13Above50 = RSI13 > 50 ? 1 : 0
// Trend Barmeter Color Calculation
RSI13Color = RSI13Above50 ? #288a75 : color.red
TrendBarRSI13Color = RSI13Above50 ? #288a75 : color.red
TrendBarRSISigCrossColor = RSISigCross ? #288a75 : color.red
TrendBarMACDColor = MACDHistogramCross ? #288a75 : color.red
TrendBarFastMACDColor = FastMACDHistogramCross ? #288a75 : color.red
TrendBarMACrossColor = MACrossover1 ? #288a75 : color.red
TrendBarMomOverDadColor = TopDogMomOverDad ? #288a75 : color.red
TrendBarDadDirectionColor = TopDogDadDirection ? #288a75 : color.red
TrendBar1Result = TrendBar1 == "MA Crossover" ? MACrossover1 :
TrendBar1 == "MACD Crossover - 12, 26, 9" ? MACDHistogramCross :
TrendBar1 == "MACD Crossover - Fast - 8, 21, 5" ? FastMACDHistogramCross :
TrendBar1 == "Mom Dad Cross (Top Dog Trading)" ? TopDogMomOverDad :
TrendBar1 == "DAD Direction (Top Dog Trading)" ? TopDogDadDirection :
TrendBar1 == "RSI Signal Line Cross - RSI 13, Sig 21" ? RSISigCross :
TrendBar1 == "RSI 5: > or < 50" ? RSI5Above50 :
TrendBar1 == "RSI 13: > or < 50" ? RSI13Above50 :
TrendBar1 == "Trend Candles" ? TrendBarTrend_Candle : na
TrendBar2Result = TrendBar2 == "MA Crossover" ? MACrossover1 :
TrendBar2 == "MACD Crossover - 12, 26, 9" ? MACDHistogramCross :
TrendBar2 == "MACD Crossover - Fast - 8, 21, 5" ? FastMACDHistogramCross :
TrendBar2 == "Mom Dad Cross (Top Dog Trading)" ? TopDogMomOverDad :
TrendBar2 == "DAD Direction (Top Dog Trading)" ? TopDogDadDirection :
TrendBar2 == "RSI Signal Line Cross - RSI 13, Sig 21" ? RSISigCross :
TrendBar2 == "RSI 5: > or < 50" ? RSI5Above50 :
TrendBar2 == "RSI 13: > or < 50" ? RSI13Above50 :
TrendBar2 == "Trend Candles" ? TrendBarTrend_Candle : na
TrendBar3Result = TrendBar3 == "MA Crossover" ? MACrossover1 :
TrendBar3 == "MACD Crossover - 12, 26, 9" ? MACDHistogramCross :
TrendBar3 == "MACD Crossover - Fast - 8, 21, 5" ? FastMACDHistogramCross :
TrendBar3 == "Mom Dad Cross (Top Dog Trading)" ? TopDogMomOverDad :
TrendBar3 == "DAD Direction (Top Dog Trading)" ? TopDogDadDirection :
TrendBar3 == "RSI Signal Line Cross - RSI 13, Sig 21" ? RSISigCross :
TrendBar3 == "RSI 5: > or < 50" ? RSI5Above50 :
TrendBar3 == "RSI 13: > or < 50" ? RSI13Above50 :
TrendBar3 == "Trend Candles" ? TrendBarTrend_Candle : na
TrendBars2Positive = TrendBar1Result and TrendBar2Result or TrendBar1Result and TrendBar3Result or
TrendBar2Result and TrendBar3Result ? 1 : 0
TrendBars2Negative = not TrendBar1Result and not TrendBar2Result or
not TrendBar1Result and not TrendBar3Result or
not TrendBar2Result and not TrendBar3Result ? 1 : 0
TrendBars3Positive = TrendBar1Result and TrendBar2Result and TrendBar3Result ? 1 : 0
TrendBars3Negative = not TrendBar1Result and not TrendBar2Result and not TrendBar3Result ? 1 : 0
PositiveWaveTrendCross = WTCross and WTCrossUp
NegativeWaveTrendCross = WTCross and WTCrossDown
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
BackgroundColorChangePositive = TrendBars3Positive and not TrendBars3Positive[1]
BackgroundColorChangeNegative = TrendBars3Negative and not TrendBars3Negative[1]
// Signals Color Calculations
MSBar2Color = BackgroundColorChangePositive ? #288a75 :
BackgroundColorChangeNegative ? color.red : na
// Trend Barmeter Color Assignments
TrendBar1Color = TrendBar1 == "N/A" ? na :
TrendBar1 == "MACD Crossover - 12, 26, 9" ? TrendBarMACDColor :
TrendBar1 == "MACD Crossover - Fast - 8, 21, 5" ? TrendBarFastMACDColor :
TrendBar1 == "Mom Dad Cross (Top Dog Trading)" ? TrendBarMomOverDadColor :
TrendBar1 == "DAD Direction (Top Dog Trading)" ? TrendBarDadDirectionColor :
TrendBar1 == "RSI Signal Line Cross - RSI 13, Sig 21" ? TrendBarRSISigCrossColor :
TrendBar1 == "RSI 5: > or < 50" ? TrendBarRSI5Color :
TrendBar1 == "RSI 13: > or < 50" ? TrendBarRSI13Color :
TrendBar1 == "Trend Candles" ? TrendBarTrend_Candle_Color :
TrendBar1 == "MA Crossover" ? TrendBarMACrossColor : na
TrendBar2Color = TrendBar2 == "N/A" ? na :
TrendBar2 == "MACD Crossover - 12, 26, 9" ? TrendBarMACDColor :
TrendBar2 == "MACD Crossover - Fast - 8, 21, 5" ? TrendBarFastMACDColor :
TrendBar2 == "Mom Dad Cross (Top Dog Trading)" ? TrendBarMomOverDadColor :
TrendBar2 == "DAD Direction (Top Dog Trading)" ? TrendBarDadDirectionColor :
TrendBar2 == "RSI Signal Line Cross - RSI 13, Sig 21" ? TrendBarRSISigCrossColor :
TrendBar2 == "RSI 5: > or < 50" ? TrendBarRSI5Color :
TrendBar2 == "RSI 13: > or < 50" ? TrendBarRSI13Color :
TrendBar2 == "Trend Candles" ? TrendBarTrend_Candle_Color :
TrendBar2 == "MA Crossover" ? TrendBarMACrossColor : na
TrendBar3Color = TrendBar3 == "N/A" ? na :
TrendBar3 == "MACD Crossover - 12, 26, 9" ? TrendBarMACDColor :
TrendBar3 == "MACD Crossover - Fast - 8, 21, 5" ? TrendBarFastMACDColor :
TrendBar3 == "Mom Dad Cross (Top Dog Trading)" ? TrendBarMomOverDadColor :
TrendBar3 == "DAD Direction (Top Dog Trading)" ? TrendBarDadDirectionColor :
TrendBar3 == "RSI Signal Line Cross - RSI 13, Sig 21" ? TrendBarRSISigCrossColor :
TrendBar3 == "RSI 5: > or < 50" ? TrendBarRSI5Color :
TrendBar3 == "RSI 13: > or < 50" ? TrendBarRSI13Color :
TrendBar3 == "Trend Candles" ? TrendBarTrend_Candle_Color :
TrendBar3 == "MA Crossover" ? TrendBarMACrossColor : na
CrossoverType2 = TrendBar4 == "DAD Direction (Top Dog Trading)" ? TopDogDadDirection :
TrendBar4 == "MACD Crossover" ? MACDHistogramCross :
TrendBar4 == "MA Direction - Fast MA - TB1" ? MA1Direction :
TrendBar4 == "MA Direction - Slow MA - TB1" ? MA2Direction : MACrossover1
color_1 = color.new(color.green, 15)
color_2 = color.new(color.red, 20)
TrendBar4Color1 = TrendBar4 == "N/A" ? na : CrossoverType2 ? color_1 : color_2
CrossoverType3 = TrendBar5 == "DAD Direction (Top Dog Trading)" ? TopDogDadDirection :
TrendBar5 == "MACD Crossover" ? MACDHistogramCross :
TrendBar5 == "MA Direction - Fast MA - TB2" ? MA3Direction :
TrendBar5 == "MA Direction - Slow MA - TB2" ? MA4Direction : MACrossover2
color_3 = color.new(color.green, 15)
color_4 = color.new(color.red, 20)
TrendBar5Color1 = TrendBar5 == "N/A" ? na : CrossoverType3 ? color_3 : color_4
WTVOB = wt1 > 60
WTVOS = wt1 < -60
// Weekness / Pos/Neg Pressure
YellowWavePointingUp = YellowWave > YellowWave[1]
RSI14 = rsi(close, 14)
RSI14OB = RSI14 > 70 ? 1 : 0
RSI14OS = RSI14 < 30 ? 1 : 0
RSI14OBOS = RSI14OB or RSI14OS ? 1 : 0
OBIndicatorsYellowPointingDown = (RSI14OB or RSI14OB[1]) and WTVOB and not YellowWavePointingUp
OSIndicatorsYellowPointingUp = (RSI14OS or RSI14OS[1]) and WTVOS and YellowWavePointingUp
plot(PosNegPressure and OSIndicatorsYellowPointingUp ? 138.5 : na, "Wave Trend - Positive Pressure", color=color.new(#288a75, 25), style=plot.style_circles, linewidth=1)
plot(PosNegPressure and OBIndicatorsYellowPointingDown ? 138.5 : na, "Wave Trend - Negative Pressure", color=color.new(#DC143C, 32), style=plot.style_circles, linewidth=1)
alertcondition(OBIndicatorsYellowPointingDown or OSIndicatorsYellowPointingUp, title=' - Pos / Neg Pressure', message='Pos / Neg Pressure - Trend Meter')
plot(TMSetups ? 134.5 : na, title = "All 3 Trend Meters Now Align", style=plot.style_circles, color=MSBar2Color, linewidth=3, transp=20)
plot(TMSetupsANDWT and ((PositiveWaveTrendCross and TrendBars3Positive) or (NegativeWaveTrendCross and TrendBars3Negative)) ? 134.5 : na, title="Wave Trend X & All 3 Trend Meters Now Align", style=plot.style_cross, color=MSBar2Color, linewidth=4, transp=20)
// Trend Barmeter Plots
plot(128.5, title="Trend Meter 1", style=plot.style_circles, color=TrendBar1Color, linewidth=2, transp=18)
plot(122.5, title="Trend Meter 2", style=plot.style_circles, color=TrendBar2Color, linewidth=2, transp=18)
plot(116.5, title="Trend Meter 3", style=plot.style_circles, color=TrendBar3Color, linewidth=2, transp=18)
plot(ShowTrendBar1 and ShowTrendBar2 ? 110 : na, title="Trend Bar 1 - Thin Line", style=plot.style_line, color=TrendBar4Color1, linewidth=4, transp=20)
plot(ShowTrendBar1 and not ShowTrendBar2 ? 110 : na, title="Trend Bar 1 - Thick Line", style=plot.style_line, color=TrendBar4Color1, linewidth=9, transp=20)
plot(ShowTrendBar2 and ShowTrendBar1 ? 104.5 : na, title="Trend Bar 2 - Thin Line", style=plot.style_line, color=TrendBar5Color1, linewidth=6, transp=20)
plot(ShowTrendBar2 and not ShowTrendBar1 ? 110 : na, title="Trend Bar 2 - Thick Line", style=plot.style_line, color=TrendBar5Color1, linewidth=9, transp=20)
// Background Highlights
TrendBar3BarsSame = TrendBars3Positive ? color.green : TrendBars3Negative ? color.red : na
TMa = hline(113.7, color=color.new(color.white, 100))
TMb = hline(131.3, color=color.new(color.white, 100))
fill(TMa, TMb, color=TrendBar3BarsSame, transp=91, title="Trend Meter Background Highlight - 3 Trend Meter Conditions Met")
// Alerts & Conditions - MA Crossing & Background Color
alertcondition(BackgroundColorChangePositive, title=' -- 3 TMs Turn Green', message='All 3 Trend Meters Turn Green - Trend Meter')
alertcondition(BackgroundColorChangeNegative, title=' -- 3 TMs Turn Red', message='All 3 Trend Meters Turn Red - Trend Meter')
alertcondition(BackgroundColorChangePositive or BackgroundColorChangeNegative, title=' -- 3 TMs Change to Same Color', message='All 3 Trend Meters Change to Same Color - Trend Meter')
alertcondition(PositiveWaveTrendCross and TrendBars3Positive, title="--- 3 TMs Turn Green & WaveTrend X", message='Green - Wave Trend Signal - Aligns with 3 Trend Meters - Trend Meter')
alertcondition(NegativeWaveTrendCross and TrendBars3Negative, title="--- 3 TMs Turn Red & WaveTrend X", message='Red - Wave Trend Signal - Aligns with 3 Trend Meters - Trend Meter')
alertcondition((PositiveWaveTrendCross and TrendBars3Positive) or (NegativeWaveTrendCross and TrendBars3Negative), title="--- 3 TMs Change to Same Color & WT X", message='Red / Green - Wave Trend Signal - Aligns with 3 Trend Meters - Trend Meter')
TrendMetersNoLongerAlign = ((not TrendBars3Positive or not TrendBars3Negative) and TrendBars3Positive[1]) or ((not TrendBars3Positive or not TrendBars3Negative) and TrendBars3Negative[1])
alertcondition(TrendMetersNoLongerAlign, title='---- 3 Trend Meters No Longer Align', message='3 Trend Meters No Longer Align - Trend Meter')
RapidColorChangePositive = TrendBars3Positive and (TrendBars3Negative[1] or TrendBars3Negative[2])
RapidColorChangeNegative = TrendBars3Negative and (TrendBars3Positive[1] or TrendBars3Positive[2])
alertcondition(RapidColorChangePositive, title='All 3 TMs Rapid Change Red to Green', message='All 3 Trend Meters Rapid Change Red to Green - Trend Meter')
alertcondition(RapidColorChangeNegative, title='All 3 TMs Rapid Change Green to Red', message='All 3 Trend Meters Rapid Change Green to Red - Trend Meter')
alertcondition(RapidColorChangePositive or RapidColorChangeNegative, title='All 3 TMs Rapid Change to Same Color', message='All 3 Trend Meters Rapid Change to Same Color - Trend Meter')
MaxValueMACrossUp = crossover( ema(Close, 5), ema(Close, 11))
MaxValueMACrossDown = crossunder(ema(Close, 5), ema(Close, 11))
TB1MACrossUp = crossover( MA1, MA2)
TB1MACrossDown = crossunder(MA1, MA2)
alertcondition(TB1MACrossUp, title='TB 1 Turns Green', message='Trend Bar 1 - Turns Green - Trend Meter')
alertcondition(TB1MACrossDown, title='TB 1 Turns Red', message='Trend Bar 1 - Turns Red - Trend Meter')
alertcondition(TB1MACrossUp or TB1MACrossDown, title='TB 1 Color Change', message='Trend Bar 1 - Color Change - Trend Meter')
TB2MACrossUp = crossover(MA3, MA4)
TB2MACrossDown = crossunder(MA3, MA4)
alertcondition(TB2MACrossUp, title='TB 2 Turns Green', message='Trend Bar 2 - Turns Green - Trend Meter')
alertcondition(TB2MACrossDown, title='TB 2 Turns Red', message='Trend Bar 2 - Turns Red - Trend Meter')
alertcondition(TB2MACrossUp or TB2MACrossDown, title='TB 2 Color Change', message='Trend Bar 2 - Color Change - Trend Meter')
TB1Green = MA1 > MA2
TB1Red = MA1 < MA2
TB2Green = MA3 > MA4
TB2Red = MA3 < MA4
TB12Green = TB1Green and TB2Green and (TB1MACrossUp or TB2MACrossUp)
TB12Red = TB1Red and TB2Red and (TB1MACrossDown or TB2MACrossDown)
alertcondition(TB12Green, title='TBs 1+2 Turn Green', message='Trend Bars 1+2 - Turn Green - Trend Meter')
alertcondition(TB12Red, title='TBs 1+2 Turn Red', message='Trend Bars 1+2 - Turn Red - Trend Meter')
alertcondition(TB12Green or TB12Red, title='TBs 1+2 Change to Same Color', message='Trend Bars 1+2 - Change to Same Color - MAs Crossing - Trend Meter')
alertcondition(TB12Green and TrendBars3Positive, title='TBs 1+2 Turn Green with 3 TMs', message='Trend Bars 1+2 - Turn Green with 3 TMs - Trend Meter')
alertcondition(TB12Red and TrendBars3Negative, title='TBs 1+2 Turn Red with 3 TMs', message='Trend Bars 1+2 - Turn Red with 3 TMs- Trend Meter')
alertcondition((TB12Green and TrendBars3Positive) or (TB12Red and TrendBars3Negative) , title='TBs 1+2 Change to Same Color with 3 TMs', message='Trend Bars 1+2 - Change to Same Color with 3 TMs - Trend Meter')
alertcondition(TB1Green and TrendBars3Positive, title='TB 1 Turns Green with 3 TMs', message='Trend Bar 1 - Turn Green with 3 TMs - Trend Meter')
alertcondition(TB1Red and TrendBars3Negative, title='TB 1 Turns Red with 3 TMs', message='Trend Bar 1 - Turn Red with 3 TMs- Trend Meter')
alertcondition((TB1Green and TrendBars3Positive) or (TB1Red and TrendBars3Negative) , title='TB 1 Change to Same Color with 3 TMs', message='Trend Bar 1 - Change to Same Color with 3 TMs - Trend Meter')
alertcondition(TB2Green and TrendBars3Positive, title='TB 2 Turns Green with 3 TMs', message='Trend Bar 2 - Turn Green with 3 TMs - Trend Meter')
alertcondition(TB2Red and TrendBars3Negative, title='TB 2 Turns Red with 3 TMs', message='Trend Bar 2 - Turn Red with 3 TMs- Trend Meter')
alertcondition((TB2Green and TrendBars3Positive) or (TB2Red and TrendBars3Negative) , title='TB 2 Change to Same Color with 3 TMs', message='Trend Bar 2 - Change to Same Color with 3 TMs - Trend Meter')
alertcondition( BackgroundColorChangePositive and TB1Green, title='3 TMs Turn Green with TB 1', message='All 3 Trend Meters Turn Green with TB 1 - Trend Meter')
alertcondition( BackgroundColorChangeNegative and TB1Red, title='3 TMs Turn Red with TB 1', message='All 3 Trend Meters Turn Red with TB 1 - Trend Meter')
alertcondition((BackgroundColorChangePositive and TB1Green) or (BackgroundColorChangeNegative and TB1Red), title='3 TMs Change Color with TB 1', message='All 3 Trend Meters Change Color with TB 1 - Trend Meter')
alertcondition( BackgroundColorChangePositive and TB2Green, title='3 TMs Turn Green with TB 2', message='All 3 Trend Meters Turn Green with TB 2 - Trend Meter')
alertcondition( BackgroundColorChangeNegative and TB2Red, title='3 TMs Turn Red with TB 2', message='All 3 Trend Meters Turn Red with TB 2 - Trend Meter')
alertcondition((BackgroundColorChangePositive and TB2Green) or (BackgroundColorChangeNegative and TB2Red), title='3 TMs Change Color with TB 2', message='All 3 Trend Meters Change Color with TB 2 - Trend Meter')
alertcondition( BackgroundColorChangePositive and TB1Green and TB2Green, title='3 TMs Turn Green with TBs 1+2', message='All 3 Trend Meters Turn Green with Trend Bar 1+2 - Trend Meter')
alertcondition( BackgroundColorChangeNegative and TB1Red and TB2Red, title='3 TMs Turn Red with TBs 1+2', message='All 3 Trend Meters Turn Red with Trend Bar 1+2 - Trend Meter')
alertcondition((BackgroundColorChangePositive and TB1Green and TB2Green) or (BackgroundColorChangeNegative and TB1Red and TB2Red), title='3 TMs Change Color with TBs 1+2', message='All 3 Trend Meters Change Color with Trend Bar 1+2 - Trend Meter')
Hello the built in standard mt4 macd it's calculation is based off of an ema fast - ema slow with the signal line being a sma. The official macd uses an ema fast - ema slow with it's signal line being an ema as well. That could be the reason. Posting this one if you leave the macd type = 0 you should get the macd that matches the version in the code above.Coolcrow wrote: Wed Sep 03, 2025 10:52 pm Hello.
I once posted a request to convert a trading view indicator to MT4 and I never got a response so I assume it wasn't possible. Today I thought that maybe if I toned down my request and only ask for a specific section of the indicator that's the most helpful to me I might get some help.
TREND METER
https://www.tradingview.com/v/Ciurp4Qn/
It's very helpful as a confirmation indicator when scalping on the 5 min but tradingview can sometimes be slightly sluggish and limited backtest options for free users can be annoying.
I only need the first part of the indicator, the first line of dots, called Trend Meter 1 / TrendBar1, which, according to it, uses MACD Crossover Fast - 8, 21, 5.
I've tried using several MT4 MACD indicators with the same settings, but unfortunately, I'm just not getting the same result. Alternatively, if there is an already existing MACD indicator that can provide the same results, please feel free to recommend/link it.
Code: Select all
//@version=4 // 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 2 Trend Bars 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 // // Be CAUTIOUS of trading BREAKOUTs as 9 out of 10 Breakouts Fail // // Find confluence with other indicators // // Enter Long above the Setup Bar // // Enter Short Below the Setup Bar study(title="Trend Meter") // Inputs / Menus PosNegPressure = input(true, "Pos / Neg Pressure", tooltip= "Positive Pressure = RSI14 and Wave Trend Over Sold with WT Delta Pointing Up Negative Pressure = RSI14 and Wave Trend Over Bought with WT Delta Pointing Down", group = "Signals") TMSetups = input(true, "Trend Meter Signal", tooltip="All 3 Trend Meters Now Align", group = "Signals") TMSetupsANDWT = input(true, "Wave Trend Cross Aligns with Trend Meter Signal", group = "Signals") TrendBar1 = input(title="Trend Meter 1", defval="MACD Crossover - Fast - 8, 21, 5", options=["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", "RSI 5: > or < 50", "Trend Candles", "N/A"], group = "Trend Meters") // "MA Crossover", "DAD Direction (Top Dog Trading)", TrendBar2 = input(title="Trend Meter 2", defval="RSI 13: > or < 50", options=["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", "RSI 5: > or < 50", "Trend Candles", "N/A"], group = "Trend Meters") // "MA Crossover", "DAD Direction (Top Dog Trading)", TrendBar3 = input(title="Trend Meter 3", defval="RSI 5: > or < 50", options=["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", "RSI 5: > or < 50", "Trend Candles", "N/A"], group = "Trend Meters") // "MA Crossover", "DAD Direction (Top Dog Trading)", ////////////////Signals - Wave Trend///////////////////////////////////////////////////////////////////////////////////////////////// // Wave Trend - RSI RSIMC = rsi(close, 14) // Wave Trend ap = hlc3 // input(hlc3, "Wave Trend - Source") n1 = 9 //input(9, "Wave Trend - WT Channel Length") n2 = 12 // input(12, "Wave Trend - WT Average Length") esa = ema(ap, n1) de = ema(abs(ap - esa), n1) ci = (ap - esa) / (0.015 * de) tci = ema(ci, n2) wt1 = tci wt2 = sma(wt1, 3) YellowWave= wt1 -wt2 // Wave Trend - Overbought & Oversold lines obLevel2 = 60 // input( 60, "Wave Trend - WT Very Overbought") obLevel = 50 // input( 50, "Wave Trend - WT Overbought") osLevel = -50 // input(-50, "Wave Trend - WT Oversold") osLevel2 = -60 // input(-60, "Wave Trend - WT Very Oversold") // Wave Trend - Conditions WTCross = cross(wt1, wt2) WTCrossUp = wt2 - wt1 <= 0 WTCrossDown = wt2 - wt1 >= 0 WTOverSold = wt2 <= osLevel2 WTOverBought = wt2 >= obLevel2 // MA Inputs ShowTrendBar1 = input(true, "Trend Bar 1", group = "Trend Bar 1", inline = "Trend Bar 1") ShowTrendBar2 = input(true, "Trend Bar 2", group = "Trend Bar 2", inline = "Trend Bar 2") TrendBar4 = input(title="", defval="MA Crossover", options=["MA Crossover", "MA Direction - Fast MA - TB1", "MA Direction - Slow MA - TB1"], group = "Trend Bar 1", inline = "Trend Bar 1") // "MACD Crossover - 12, 26 9", "MACD Crossover - Fast - 8, 21, 5", "DAD Direction (Top Dog Trading)", TrendBar5 = input(title="", defval="MA Crossover", options=["MA Crossover", "MA Direction - Fast MA - TB2", "MA Direction - Slow MA - TB2"], group = "Trend Bar 2", inline = "Trend Bar 2") // "MACD Crossover - 12, 26 9", "MACD Crossover - Fast - 8, 21, 5", "DAD Direction (Top Dog Trading)", MA1_Length = input(5, title='Fast MA', minval=1, group = "Trend Bar 1", inline = "TB1 Fast") MA1_Type = input( title='', defval="EMA", options=["EMA", "SMA"], group = "Trend Bar 1", inline = "TB1 Fast") MA2_Length = input(11, title='Slow MA', minval=1, group = "Trend Bar 1", inline = "TB1 Slow") MA2_Type = input( title='', defval="EMA", options=["EMA", "SMA"], group = "Trend Bar 1", inline = "TB1 Slow") MA3_Length = input(13, title='Fast MA', minval=1, group = "Trend Bar 2", inline = "TB2 Fast") MA3_Type = input( title='', defval="EMA", options=["EMA", "SMA"], group = "Trend Bar 2", inline = "TB2 Fast") MA4_Length = input(36, title='Slow MA', minval=1, group = "Trend Bar 2", inline = "TB2 Slow") MA4_Type = input( title='', defval="SMA", options=["EMA", "SMA"], group = "Trend Bar 2", inline = "TB2 Slow") // MA Calculations Close = close //security(syminfo.tickerid, timeframe.period, close, barmerge.lookahead_off) MA1 = if MA1_Type == "SMA" sma(Close, MA1_Length) else ema(Close, MA1_Length) MA2 = if MA2_Type == "SMA" sma(Close, MA2_Length) else ema(Close, MA2_Length) MA3 = if MA3_Type == "SMA" sma(Close, MA3_Length) else ema(Close, MA3_Length) MA4 = if MA4_Type == "SMA" sma(Close, MA4_Length) else ema(Close, MA4_Length) // MA Crossover Condition MACrossover1 = MA1 > MA2 ? 1 : 0 MACrossover2 = MA3 > MA4 ? 1 : 0 // MA Direction Condition MA1Direction = MA1 > MA1[1] ? 1 : 0 MA2Direction = MA2 > MA2[1] ? 1 : 0 MA3Direction = MA3 > MA3[1] ? 1 : 0 MA4Direction = MA4 > MA4[1] ? 1 : 0 // MA Direction Change Condition MA1PositiveDirectionChange = MA1Direction and not MA1Direction[1] ? 1 : 0 MA2PositiveDirectionChange = MA2Direction and not MA2Direction[1] ? 1 : 0 MA3PositiveDirectionChange = MA3Direction and not MA3Direction[1] ? 1 : 0 MA4PositiveDirectionChange = MA4Direction and not MA4Direction[1] ? 1 : 0 MA1NegativeDirectionChange = not MA1Direction and MA1Direction[1] ? 1 : 0 MA2NegativeDirectionChange = not MA2Direction and MA2Direction[1] ? 1 : 0 MA3NegativeDirectionChange = not MA3Direction and MA3Direction[1] ? 1 : 0 MA4NegativeDirectionChange = not MA4Direction and MA4Direction[1] ? 1 : 0 // MACD and MOM & DAD - Top Dog Trading // Standard MACD Calculations MACDfastMA = 12 MACDslowMA = 26 MACDsignalSmooth = 9 MACDLine = ema(close, MACDfastMA) - ema(close, MACDslowMA) SignalLine = ema(MACDLine, MACDsignalSmooth) MACDHistogram = MACDLine - SignalLine // MACD- Background Color Change Condition MACDHistogramCross = MACDHistogram > 0 ? 1 : 0 MACDLineOverZero = MACDLine > 0 ? 1 : 0 MACDLineOverZeroandHistogramCross = MACDHistogramCross and MACDLineOverZero ? 1 : 0 MACDLineUnderZeroandHistogramCross = not MACDHistogramCross and not MACDLineOverZero ? 1 : 0 // Fast MACD Calculations FastMACDfastMA = 8 FastMACDslowMA = 21 FastMACDsignalSmooth = 5 FastMACDLine = ema(close, FastMACDfastMA) - ema(close, FastMACDslowMA) FastSignalLine = ema(FastMACDLine, FastMACDsignalSmooth) FastMACDHistogram = FastMACDLine - FastSignalLine // Fast MACD- Background Color Change Condition FastMACDHistogramCross = FastMACDHistogram > 0 ? 1 : 0 FastMACDLineOverZero = FastMACDLine > 0 ? 1 : 0 FastMACDLineOverZeroandHistogramCross = FastMACDHistogramCross and FastMACDLineOverZero ? 1 : 0 FastMACDLineUnderZeroandHistogramCross = not FastMACDHistogramCross and not FastMACDLineOverZero ? 1 : 0 // Top Dog Trading - Mom Dad Calculations TopDog_Fast_MA = 5 TopDog_Slow_MA = 20 TopDog_Sig = 30 TopDogMom = ema(close, TopDog_Fast_MA) - ema(close, TopDog_Slow_MA) TopDogDad = ema(TopDogMom, TopDog_Sig) // Top Dog Dad - Background Color Change Condition TopDogDadDirection = TopDogDad > TopDogDad[1] ? 1 : 0 TopDogMomOverDad = TopDogMom > TopDogDad ? 1 : 0 TopDogMomOverZero = TopDogMom > 0 ? 1 : 0 TopDogDadDirectandMomOverZero = TopDogDadDirection and TopDogMomOverZero ? 1 : 0 TopDogDadDirectandMomUnderZero = not TopDogDadDirection and not 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. haclose = ohlc4 haopen = 0.0 haopen := na(haopen[1]) ? (open + close) / 2 : (haopen[1] + haclose[1]) / 2 //hahigh = max(high, max(haopen, haclose)) //halow = min(low, min(haopen, haclose)) ccolor = haclose - haopen > 0 ? 1 : 0 inside6 = 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 inside5 = 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 inside4 = 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 inside3 = 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 inside2 = 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 inside1 = 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 colorvalue = inside6 ? ccolor[6] : inside5 ? ccolor[5] : inside4 ? ccolor[4] : inside3 ? ccolor[3] : inside2 ? ccolor[2] : inside1 ? ccolor[1] : ccolor TrendBarTrend_Candle_Color = colorvalue ? #288a75 : color.red TrendBarTrend_Candle = colorvalue ? 1 : 0 // RSI 5 Trend Barmeter Calculations RSI5 = rsi(close, 5) RSI5Above50 = RSI5 > 50 ? 1 : 0 RSI5Color = RSI5Above50 ? #288a75 : color.red TrendBarRSI5Color = RSI5Above50 ? #288a75 : color.red // RSI 5 Trend Barmeter Calculations RSI13 = rsi(close, 13) // Linear Regression Calculation For RSI Signal Line SignalLineLength1 = 21 x = bar_index y = RSI13 x_ = sma(x, SignalLineLength1) y_ = sma(y, SignalLineLength1) mx = stdev(x, SignalLineLength1) my = stdev(y, SignalLineLength1) c = correlation(x, y, SignalLineLength1) slope = c * (my / mx) inter = y_ - slope * x_ LinReg1 = x * slope + inter RSISigDirection = LinReg1 > LinReg1[1] ? 1 : 0 RSISigCross = RSI13 > LinReg1 ? 1 : 0 RSI13Above50 = RSI13 > 50 ? 1 : 0 // Trend Barmeter Color Calculation RSI13Color = RSI13Above50 ? #288a75 : color.red TrendBarRSI13Color = RSI13Above50 ? #288a75 : color.red TrendBarRSISigCrossColor = RSISigCross ? #288a75 : color.red TrendBarMACDColor = MACDHistogramCross ? #288a75 : color.red TrendBarFastMACDColor = FastMACDHistogramCross ? #288a75 : color.red TrendBarMACrossColor = MACrossover1 ? #288a75 : color.red TrendBarMomOverDadColor = TopDogMomOverDad ? #288a75 : color.red TrendBarDadDirectionColor = TopDogDadDirection ? #288a75 : color.red TrendBar1Result = TrendBar1 == "MA Crossover" ? MACrossover1 : TrendBar1 == "MACD Crossover - 12, 26, 9" ? MACDHistogramCross : TrendBar1 == "MACD Crossover - Fast - 8, 21, 5" ? FastMACDHistogramCross : TrendBar1 == "Mom Dad Cross (Top Dog Trading)" ? TopDogMomOverDad : TrendBar1 == "DAD Direction (Top Dog Trading)" ? TopDogDadDirection : TrendBar1 == "RSI Signal Line Cross - RSI 13, Sig 21" ? RSISigCross : TrendBar1 == "RSI 5: > or < 50" ? RSI5Above50 : TrendBar1 == "RSI 13: > or < 50" ? RSI13Above50 : TrendBar1 == "Trend Candles" ? TrendBarTrend_Candle : na TrendBar2Result = TrendBar2 == "MA Crossover" ? MACrossover1 : TrendBar2 == "MACD Crossover - 12, 26, 9" ? MACDHistogramCross : TrendBar2 == "MACD Crossover - Fast - 8, 21, 5" ? FastMACDHistogramCross : TrendBar2 == "Mom Dad Cross (Top Dog Trading)" ? TopDogMomOverDad : TrendBar2 == "DAD Direction (Top Dog Trading)" ? TopDogDadDirection : TrendBar2 == "RSI Signal Line Cross - RSI 13, Sig 21" ? RSISigCross : TrendBar2 == "RSI 5: > or < 50" ? RSI5Above50 : TrendBar2 == "RSI 13: > or < 50" ? RSI13Above50 : TrendBar2 == "Trend Candles" ? TrendBarTrend_Candle : na TrendBar3Result = TrendBar3 == "MA Crossover" ? MACrossover1 : TrendBar3 == "MACD Crossover - 12, 26, 9" ? MACDHistogramCross : TrendBar3 == "MACD Crossover - Fast - 8, 21, 5" ? FastMACDHistogramCross : TrendBar3 == "Mom Dad Cross (Top Dog Trading)" ? TopDogMomOverDad : TrendBar3 == "DAD Direction (Top Dog Trading)" ? TopDogDadDirection : TrendBar3 == "RSI Signal Line Cross - RSI 13, Sig 21" ? RSISigCross : TrendBar3 == "RSI 5: > or < 50" ? RSI5Above50 : TrendBar3 == "RSI 13: > or < 50" ? RSI13Above50 : TrendBar3 == "Trend Candles" ? TrendBarTrend_Candle : na TrendBars2Positive = TrendBar1Result and TrendBar2Result or TrendBar1Result and TrendBar3Result or TrendBar2Result and TrendBar3Result ? 1 : 0 TrendBars2Negative = not TrendBar1Result and not TrendBar2Result or not TrendBar1Result and not TrendBar3Result or not TrendBar2Result and not TrendBar3Result ? 1 : 0 TrendBars3Positive = TrendBar1Result and TrendBar2Result and TrendBar3Result ? 1 : 0 TrendBars3Negative = not TrendBar1Result and not TrendBar2Result and not TrendBar3Result ? 1 : 0 PositiveWaveTrendCross = WTCross and WTCrossUp NegativeWaveTrendCross = WTCross and WTCrossDown /////////////////////////////////////////////////////////////////////////////////////////////////////////////// BackgroundColorChangePositive = TrendBars3Positive and not TrendBars3Positive[1] BackgroundColorChangeNegative = TrendBars3Negative and not TrendBars3Negative[1] // Signals Color Calculations MSBar2Color = BackgroundColorChangePositive ? #288a75 : BackgroundColorChangeNegative ? color.red : na // Trend Barmeter Color Assignments TrendBar1Color = TrendBar1 == "N/A" ? na : TrendBar1 == "MACD Crossover - 12, 26, 9" ? TrendBarMACDColor : TrendBar1 == "MACD Crossover - Fast - 8, 21, 5" ? TrendBarFastMACDColor : TrendBar1 == "Mom Dad Cross (Top Dog Trading)" ? TrendBarMomOverDadColor : TrendBar1 == "DAD Direction (Top Dog Trading)" ? TrendBarDadDirectionColor : TrendBar1 == "RSI Signal Line Cross - RSI 13, Sig 21" ? TrendBarRSISigCrossColor : TrendBar1 == "RSI 5: > or < 50" ? TrendBarRSI5Color : TrendBar1 == "RSI 13: > or < 50" ? TrendBarRSI13Color : TrendBar1 == "Trend Candles" ? TrendBarTrend_Candle_Color : TrendBar1 == "MA Crossover" ? TrendBarMACrossColor : na TrendBar2Color = TrendBar2 == "N/A" ? na : TrendBar2 == "MACD Crossover - 12, 26, 9" ? TrendBarMACDColor : TrendBar2 == "MACD Crossover - Fast - 8, 21, 5" ? TrendBarFastMACDColor : TrendBar2 == "Mom Dad Cross (Top Dog Trading)" ? TrendBarMomOverDadColor : TrendBar2 == "DAD Direction (Top Dog Trading)" ? TrendBarDadDirectionColor : TrendBar2 == "RSI Signal Line Cross - RSI 13, Sig 21" ? TrendBarRSISigCrossColor : TrendBar2 == "RSI 5: > or < 50" ? TrendBarRSI5Color : TrendBar2 == "RSI 13: > or < 50" ? TrendBarRSI13Color : TrendBar2 == "Trend Candles" ? TrendBarTrend_Candle_Color : TrendBar2 == "MA Crossover" ? TrendBarMACrossColor : na TrendBar3Color = TrendBar3 == "N/A" ? na : TrendBar3 == "MACD Crossover - 12, 26, 9" ? TrendBarMACDColor : TrendBar3 == "MACD Crossover - Fast - 8, 21, 5" ? TrendBarFastMACDColor : TrendBar3 == "Mom Dad Cross (Top Dog Trading)" ? TrendBarMomOverDadColor : TrendBar3 == "DAD Direction (Top Dog Trading)" ? TrendBarDadDirectionColor : TrendBar3 == "RSI Signal Line Cross - RSI 13, Sig 21" ? TrendBarRSISigCrossColor : TrendBar3 == "RSI 5: > or < 50" ? TrendBarRSI5Color : TrendBar3 == "RSI 13: > or < 50" ? TrendBarRSI13Color : TrendBar3 == "Trend Candles" ? TrendBarTrend_Candle_Color : TrendBar3 == "MA Crossover" ? TrendBarMACrossColor : na CrossoverType2 = TrendBar4 == "DAD Direction (Top Dog Trading)" ? TopDogDadDirection : TrendBar4 == "MACD Crossover" ? MACDHistogramCross : TrendBar4 == "MA Direction - Fast MA - TB1" ? MA1Direction : TrendBar4 == "MA Direction - Slow MA - TB1" ? MA2Direction : MACrossover1 color_1 = color.new(color.green, 15) color_2 = color.new(color.red, 20) TrendBar4Color1 = TrendBar4 == "N/A" ? na : CrossoverType2 ? color_1 : color_2 CrossoverType3 = TrendBar5 == "DAD Direction (Top Dog Trading)" ? TopDogDadDirection : TrendBar5 == "MACD Crossover" ? MACDHistogramCross : TrendBar5 == "MA Direction - Fast MA - TB2" ? MA3Direction : TrendBar5 == "MA Direction - Slow MA - TB2" ? MA4Direction : MACrossover2 color_3 = color.new(color.green, 15) color_4 = color.new(color.red, 20) TrendBar5Color1 = TrendBar5 == "N/A" ? na : CrossoverType3 ? color_3 : color_4 WTVOB = wt1 > 60 WTVOS = wt1 < -60 // Weekness / Pos/Neg Pressure YellowWavePointingUp = YellowWave > YellowWave[1] RSI14 = rsi(close, 14) RSI14OB = RSI14 > 70 ? 1 : 0 RSI14OS = RSI14 < 30 ? 1 : 0 RSI14OBOS = RSI14OB or RSI14OS ? 1 : 0 OBIndicatorsYellowPointingDown = (RSI14OB or RSI14OB[1]) and WTVOB and not YellowWavePointingUp OSIndicatorsYellowPointingUp = (RSI14OS or RSI14OS[1]) and WTVOS and YellowWavePointingUp plot(PosNegPressure and OSIndicatorsYellowPointingUp ? 138.5 : na, "Wave Trend - Positive Pressure", color=color.new(#288a75, 25), style=plot.style_circles, linewidth=1) plot(PosNegPressure and OBIndicatorsYellowPointingDown ? 138.5 : na, "Wave Trend - Negative Pressure", color=color.new(#DC143C, 32), style=plot.style_circles, linewidth=1) alertcondition(OBIndicatorsYellowPointingDown or OSIndicatorsYellowPointingUp, title=' - Pos / Neg Pressure', message='Pos / Neg Pressure - Trend Meter') plot(TMSetups ? 134.5 : na, title = "All 3 Trend Meters Now Align", style=plot.style_circles, color=MSBar2Color, linewidth=3, transp=20) plot(TMSetupsANDWT and ((PositiveWaveTrendCross and TrendBars3Positive) or (NegativeWaveTrendCross and TrendBars3Negative)) ? 134.5 : na, title="Wave Trend X & All 3 Trend Meters Now Align", style=plot.style_cross, color=MSBar2Color, linewidth=4, transp=20) // Trend Barmeter Plots plot(128.5, title="Trend Meter 1", style=plot.style_circles, color=TrendBar1Color, linewidth=2, transp=18) plot(122.5, title="Trend Meter 2", style=plot.style_circles, color=TrendBar2Color, linewidth=2, transp=18) plot(116.5, title="Trend Meter 3", style=plot.style_circles, color=TrendBar3Color, linewidth=2, transp=18) plot(ShowTrendBar1 and ShowTrendBar2 ? 110 : na, title="Trend Bar 1 - Thin Line", style=plot.style_line, color=TrendBar4Color1, linewidth=4, transp=20) plot(ShowTrendBar1 and not ShowTrendBar2 ? 110 : na, title="Trend Bar 1 - Thick Line", style=plot.style_line, color=TrendBar4Color1, linewidth=9, transp=20) plot(ShowTrendBar2 and ShowTrendBar1 ? 104.5 : na, title="Trend Bar 2 - Thin Line", style=plot.style_line, color=TrendBar5Color1, linewidth=6, transp=20) plot(ShowTrendBar2 and not ShowTrendBar1 ? 110 : na, title="Trend Bar 2 - Thick Line", style=plot.style_line, color=TrendBar5Color1, linewidth=9, transp=20) // Background Highlights TrendBar3BarsSame = TrendBars3Positive ? color.green : TrendBars3Negative ? color.red : na TMa = hline(113.7, color=color.new(color.white, 100)) TMb = hline(131.3, color=color.new(color.white, 100)) fill(TMa, TMb, color=TrendBar3BarsSame, transp=91, title="Trend Meter Background Highlight - 3 Trend Meter Conditions Met") // Alerts & Conditions - MA Crossing & Background Color alertcondition(BackgroundColorChangePositive, title=' -- 3 TMs Turn Green', message='All 3 Trend Meters Turn Green - Trend Meter') alertcondition(BackgroundColorChangeNegative, title=' -- 3 TMs Turn Red', message='All 3 Trend Meters Turn Red - Trend Meter') alertcondition(BackgroundColorChangePositive or BackgroundColorChangeNegative, title=' -- 3 TMs Change to Same Color', message='All 3 Trend Meters Change to Same Color - Trend Meter') alertcondition(PositiveWaveTrendCross and TrendBars3Positive, title="--- 3 TMs Turn Green & WaveTrend X", message='Green - Wave Trend Signal - Aligns with 3 Trend Meters - Trend Meter') alertcondition(NegativeWaveTrendCross and TrendBars3Negative, title="--- 3 TMs Turn Red & WaveTrend X", message='Red - Wave Trend Signal - Aligns with 3 Trend Meters - Trend Meter') alertcondition((PositiveWaveTrendCross and TrendBars3Positive) or (NegativeWaveTrendCross and TrendBars3Negative), title="--- 3 TMs Change to Same Color & WT X", message='Red / Green - Wave Trend Signal - Aligns with 3 Trend Meters - Trend Meter') TrendMetersNoLongerAlign = ((not TrendBars3Positive or not TrendBars3Negative) and TrendBars3Positive[1]) or ((not TrendBars3Positive or not TrendBars3Negative) and TrendBars3Negative[1]) alertcondition(TrendMetersNoLongerAlign, title='---- 3 Trend Meters No Longer Align', message='3 Trend Meters No Longer Align - Trend Meter') RapidColorChangePositive = TrendBars3Positive and (TrendBars3Negative[1] or TrendBars3Negative[2]) RapidColorChangeNegative = TrendBars3Negative and (TrendBars3Positive[1] or TrendBars3Positive[2]) alertcondition(RapidColorChangePositive, title='All 3 TMs Rapid Change Red to Green', message='All 3 Trend Meters Rapid Change Red to Green - Trend Meter') alertcondition(RapidColorChangeNegative, title='All 3 TMs Rapid Change Green to Red', message='All 3 Trend Meters Rapid Change Green to Red - Trend Meter') alertcondition(RapidColorChangePositive or RapidColorChangeNegative, title='All 3 TMs Rapid Change to Same Color', message='All 3 Trend Meters Rapid Change to Same Color - Trend Meter') MaxValueMACrossUp = crossover( ema(Close, 5), ema(Close, 11)) MaxValueMACrossDown = crossunder(ema(Close, 5), ema(Close, 11)) TB1MACrossUp = crossover( MA1, MA2) TB1MACrossDown = crossunder(MA1, MA2) alertcondition(TB1MACrossUp, title='TB 1 Turns Green', message='Trend Bar 1 - Turns Green - Trend Meter') alertcondition(TB1MACrossDown, title='TB 1 Turns Red', message='Trend Bar 1 - Turns Red - Trend Meter') alertcondition(TB1MACrossUp or TB1MACrossDown, title='TB 1 Color Change', message='Trend Bar 1 - Color Change - Trend Meter') TB2MACrossUp = crossover(MA3, MA4) TB2MACrossDown = crossunder(MA3, MA4) alertcondition(TB2MACrossUp, title='TB 2 Turns Green', message='Trend Bar 2 - Turns Green - Trend Meter') alertcondition(TB2MACrossDown, title='TB 2 Turns Red', message='Trend Bar 2 - Turns Red - Trend Meter') alertcondition(TB2MACrossUp or TB2MACrossDown, title='TB 2 Color Change', message='Trend Bar 2 - Color Change - Trend Meter') TB1Green = MA1 > MA2 TB1Red = MA1 < MA2 TB2Green = MA3 > MA4 TB2Red = MA3 < MA4 TB12Green = TB1Green and TB2Green and (TB1MACrossUp or TB2MACrossUp) TB12Red = TB1Red and TB2Red and (TB1MACrossDown or TB2MACrossDown) alertcondition(TB12Green, title='TBs 1+2 Turn Green', message='Trend Bars 1+2 - Turn Green - Trend Meter') alertcondition(TB12Red, title='TBs 1+2 Turn Red', message='Trend Bars 1+2 - Turn Red - Trend Meter') alertcondition(TB12Green or TB12Red, title='TBs 1+2 Change to Same Color', message='Trend Bars 1+2 - Change to Same Color - MAs Crossing - Trend Meter') alertcondition(TB12Green and TrendBars3Positive, title='TBs 1+2 Turn Green with 3 TMs', message='Trend Bars 1+2 - Turn Green with 3 TMs - Trend Meter') alertcondition(TB12Red and TrendBars3Negative, title='TBs 1+2 Turn Red with 3 TMs', message='Trend Bars 1+2 - Turn Red with 3 TMs- Trend Meter') alertcondition((TB12Green and TrendBars3Positive) or (TB12Red and TrendBars3Negative) , title='TBs 1+2 Change to Same Color with 3 TMs', message='Trend Bars 1+2 - Change to Same Color with 3 TMs - Trend Meter') alertcondition(TB1Green and TrendBars3Positive, title='TB 1 Turns Green with 3 TMs', message='Trend Bar 1 - Turn Green with 3 TMs - Trend Meter') alertcondition(TB1Red and TrendBars3Negative, title='TB 1 Turns Red with 3 TMs', message='Trend Bar 1 - Turn Red with 3 TMs- Trend Meter') alertcondition((TB1Green and TrendBars3Positive) or (TB1Red and TrendBars3Negative) , title='TB 1 Change to Same Color with 3 TMs', message='Trend Bar 1 - Change to Same Color with 3 TMs - Trend Meter') alertcondition(TB2Green and TrendBars3Positive, title='TB 2 Turns Green with 3 TMs', message='Trend Bar 2 - Turn Green with 3 TMs - Trend Meter') alertcondition(TB2Red and TrendBars3Negative, title='TB 2 Turns Red with 3 TMs', message='Trend Bar 2 - Turn Red with 3 TMs- Trend Meter') alertcondition((TB2Green and TrendBars3Positive) or (TB2Red and TrendBars3Negative) , title='TB 2 Change to Same Color with 3 TMs', message='Trend Bar 2 - Change to Same Color with 3 TMs - Trend Meter') alertcondition( BackgroundColorChangePositive and TB1Green, title='3 TMs Turn Green with TB 1', message='All 3 Trend Meters Turn Green with TB 1 - Trend Meter') alertcondition( BackgroundColorChangeNegative and TB1Red, title='3 TMs Turn Red with TB 1', message='All 3 Trend Meters Turn Red with TB 1 - Trend Meter') alertcondition((BackgroundColorChangePositive and TB1Green) or (BackgroundColorChangeNegative and TB1Red), title='3 TMs Change Color with TB 1', message='All 3 Trend Meters Change Color with TB 1 - Trend Meter') alertcondition( BackgroundColorChangePositive and TB2Green, title='3 TMs Turn Green with TB 2', message='All 3 Trend Meters Turn Green with TB 2 - Trend Meter') alertcondition( BackgroundColorChangeNegative and TB2Red, title='3 TMs Turn Red with TB 2', message='All 3 Trend Meters Turn Red with TB 2 - Trend Meter') alertcondition((BackgroundColorChangePositive and TB2Green) or (BackgroundColorChangeNegative and TB2Red), title='3 TMs Change Color with TB 2', message='All 3 Trend Meters Change Color with TB 2 - Trend Meter') alertcondition( BackgroundColorChangePositive and TB1Green and TB2Green, title='3 TMs Turn Green with TBs 1+2', message='All 3 Trend Meters Turn Green with Trend Bar 1+2 - Trend Meter') alertcondition( BackgroundColorChangeNegative and TB1Red and TB2Red, title='3 TMs Turn Red with TBs 1+2', message='All 3 Trend Meters Turn Red with Trend Bar 1+2 - Trend Meter') alertcondition((BackgroundColorChangePositive and TB1Green and TB2Green) or (BackgroundColorChangeNegative and TB1Red and TB2Red), title='3 TMs Change Color with TBs 1+2', message='All 3 Trend Meters Change Color with Trend Bar 1+2 - Trend Meter')
It's working!!! Just like the TradingView version. You are a genius. Thank you!mrtools wrote: Thu Sep 04, 2025 1:16 am Hello the built in standard mt4 macd it's calculation is based off of an ema fast - ema slow with the signal line being a sma. The official macd uses an ema fast - ema slow with it's signal line being an ema as well. That could be the reason. Posting this one if you leave the macd type = 0 you should get the macd that matches the version in the code above.
Code: Select all
https://www.tradingview.com/script/tHK4O1Fi-Zero-Lag-Trend-Signals-MTF-AlgoAlpha/
Code: Select all
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AlgoAlpha
//@version=5
indicator("Zero Lag Trend Signals (MTF) [AlgoAlpha]", shorttitle="AlgoAlpha - 0️⃣Zero Lag Signals", overlay=true)
length = input.int(70, "Length", tooltip = "The Look-Back window for the Zero-Lag EMA calculations", group = "Main Calculations")
mult = input.float(1.2, "Band Multiplier", tooltip = "This value controls the thickness of the bands, a larger value makes the indicato less noisy", group = "Main Calculations")
t1 = input.timeframe("5", "Time frame 1", group = "Extra Timeframes")
t2 = input.timeframe("15", "Time frame 2", group = "Extra Timeframes")
t3 = input.timeframe("60", "Time frame 3", group = "Extra Timeframes")
t4 = input.timeframe("240", "Time frame 4", group = "Extra Timeframes")
t5 = input.timeframe("1D", "Time frame 5", group = "Extra Timeframes")
green = input.color(#00ffbb, "Bullish Color", group = "Appearance")
red = input.color(#ff1100, "Bearish Color", group = "Appearance")
src = close
lag = math.floor((length - 1) / 2)
zlema = ta.ema(src + (src - src[lag]), length)
volatility = ta.highest(ta.atr(length), length*3) * mult
var trend = 0
if ta.crossover(close, zlema+volatility)
trend := 1
if ta.crossunder(close, zlema-volatility)
trend := -1
zlemaColor = trend == 1 ? color.new(green, 70) : color.new(red, 70)
m = plot(zlema, title="Zero Lag Basis", linewidth=2, color=zlemaColor)
upper = plot(trend == -1 ? zlema+volatility : na, style = plot.style_linebr, color = color.new(red, 90), title = "Upper Deviation Band")
lower = plot(trend == 1 ? zlema-volatility : na, style = plot.style_linebr, color = color.new(green, 90), title = "Lower Deviation Band")
fill(m, upper, (open + close) / 2, zlema+volatility, color.new(red, 90), color.new(red, 70))
fill(m, lower, (open + close) / 2, zlema-volatility, color.new(green, 90), color.new(green, 70))
plotshape(ta.crossunder(trend, 0) ? zlema+volatility : na, "Bearish Trend", shape.labeldown, location.absolute, red, text = "▼", textcolor = chart.fg_color, size = size.small)
plotshape(ta.crossover(trend, 0) ? zlema-volatility : na, "Bullish Trend", shape.labelup, location.absolute, green, text = "▲", textcolor = chart.fg_color, size = size.small)
plotchar(ta.crossover(close, zlema) and trend == 1 and trend[1] == 1 ? zlema-volatility*1.5 : na, "Bullish Entry", "▲", location.absolute, green, size = size.tiny)
plotchar(ta.crossunder(close, zlema) and trend == -1 and trend[1] == -1 ? zlema+volatility*1.5 : na, "Bearish Entry", "▼", location.absolute, red, size = size.tiny)
s1 = request.security(syminfo.tickerid, t1, trend)
s2 = request.security(syminfo.tickerid, t2, trend)
s3 = request.security(syminfo.tickerid, t3, trend)
s4 = request.security(syminfo.tickerid, t4, trend)
s5 = request.security(syminfo.tickerid, t5, trend)
s1a = s1 == 1 ? "Bullish" : "Bearish"
s2a = s2 == 1 ? "Bullish" : "Bearish"
s3a = s3 == 1 ? "Bullish" : "Bearish"
s4a = s4 == 1 ? "Bullish" : "Bearish"
s5a = s5 == 1 ? "Bullish" : "Bearish"
if barstate.islast
var data_table = table.new(position=position.top_right, columns=2, rows=6, bgcolor=chart.bg_color, border_width=1, border_color=chart.fg_color, frame_color=chart.fg_color, frame_width=1)
table.cell(data_table, text_halign=text.align_center, column=0, row=0, text="Time Frame", text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=0, text="Signal", text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=0, row=1, text=t1, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=1, text=s1a, text_color=chart.fg_color, bgcolor=s1a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=2, text=t2, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=2, text=s2a, text_color=chart.fg_color, bgcolor=s2a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=3, text=t3, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=3, text=s3a, text_color=chart.fg_color, bgcolor=s3a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=4, text=t4, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=4, text=s4a, text_color=chart.fg_color, bgcolor=s4a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=5, text=t5, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=5, text=s5a, text_color=chart.fg_color, bgcolor=s5a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
/////////////////////////////////////////ALERTS FOR SMALL ARROWS (ENTRY SIGNALS)
alertcondition(ta.crossover(close, zlema) and trend == 1 and trend[1] == 1, "Bullish Entry Signal",
message="Bullish Entry Signal detected. Consider entering a long position.")
alertcondition(ta.crossunder(close, zlema) and trend == -1 and trend[1] == -1, "Bearish Entry Signal",
message="Bearish Entry Signal detected. Consider entering a short position.")
/////////////////////////////////////////ALERTS FOR TREND CONDITIONS
alertcondition(ta.crossover(trend, 0), "Bullish Trend")
alertcondition(ta.crossunder(trend, 0), "Bearish Trend")
alertcondition(ta.cross(trend, 0), "(Bullish or Bearish) Trend")
alertcondition(ta.crossover(s1, 0), "Bullish Trend Time Frame 1")
alertcondition(ta.crossunder(s1, 0), "Bearish Trend Time Frame 1")
alertcondition(ta.cross(s1, 0), "(Bullish or Bearish) Trend Time Frame 1")
alertcondition(ta.crossover(s2, 0), "Bullish Trend Time Frame 2")
alertcondition(ta.crossunder(s2, 0), "Bearish Trend Time Frame 2")
alertcondition(ta.cross(s2, 0), "(Bullish or Bearish) Trend Time Frame 2")
alertcondition(ta.crossover(s3, 0), "Bullish Trend Time Frame 3")
alertcondition(ta.crossunder(s3, 0), "Bearish Trend Time Frame 3")
alertcondition(ta.cross(s3, 0), "(Bullish or Bearish) Trend Time Frame 3")
alertcondition(ta.crossover(s4, 0), "Bullish Trend Time Frame 4")
alertcondition(ta.crossunder(s4, 0), "Bearish Trend Time Frame 4")
alertcondition(ta.cross(s4, 0), "(Bullish or Bearish) Trend Time Frame 4")
alertcondition(ta.crossover(s5, 0), "Bullish Trend Time Frame 5")
alertcondition(ta.crossunder(s5, 0), "Bearish Trend Time Frame 5")
alertcondition(ta.cross(s5, 0), "(Bullish or Bearish) Trend Time Frame 5")
alertcondition(ta.crossover(close, zlema) and trend == 1 and trend[1] == 1, "Bullish Entry")
alertcondition(ta.crossunder(close, zlema) and trend == -1 and trend[1] == -1, "Bearish Entry")