here my conversion with option of AlphaTrend and AlphaTrend Max.
Author states:
With Trend Magic; we had some problems.
Alpha Trend tries to solve those problems such as:
1-To minimize stop losses and overcome sideways market conditions.
2-To have more accurate BUY/SELL signals during trending market conditions.
3- To have significant support and resistance levels.
4- To bring together indicators from different categories that are compatible with each other and make a meaningful combination regarding momentum, trend, volatility, volume and trailing stop loss.
according to those purposes, Alpha Trend:
1- Acts like a dead indicator like its ancestor Magic Trend sideways market conditions and doesn't give many false signals.
2- With another line with 2 bars offsetted off the original one Alpha Trend have BUY and SELL signals from their crossovers.
BUY / LONG when Alpha Trend line crosses above its 2 bars offsetted line and there would be a green filling between them
SELL / SHORT when Alpha Trend line crosses below its 2 bars offsetted line and filling would be red then.
3- Alpha Trend lines
-act as support levels when an uptrend occurs trailing 1*ATR (default coefficient) distance from bar's low values
-conversely, act as resistance levels when a downtrend occurs trailing 1*ATR (default coefficient) distance from bar's high values
and acting as trailing stop losses
the more Alpha Trend lines straighter the more supports and resistances become stronger.
4- Trend Magic has CCI in calculation
Alpha Trend has MFI as momentum, but when there's no volume data MFI has 0 values, so there's a button to change calculation considering RSI after checking the relevant box to overcome this problem when there is no volume data in that chart.
Momentum: RSI and MFI
Trend: Magic Trend
Volatility: ATR,
Trailing STOP: ATR TRAILING STOP
Volume: MFI
Alpha trend is really a combination of different types...
default values:
coefficient: 1 which is the factor of trailing ATR value
common period: 14 which is the length of ATR MFI and RSI
Author states:
With Trend Magic; we had some problems.
Alpha Trend tries to solve those problems such as:
1-To minimize stop losses and overcome sideways market conditions.
2-To have more accurate BUY/SELL signals during trending market conditions.
3- To have significant support and resistance levels.
4- To bring together indicators from different categories that are compatible with each other and make a meaningful combination regarding momentum, trend, volatility, volume and trailing stop loss.
according to those purposes, Alpha Trend:
1- Acts like a dead indicator like its ancestor Magic Trend sideways market conditions and doesn't give many false signals.
2- With another line with 2 bars offsetted off the original one Alpha Trend have BUY and SELL signals from their crossovers.
BUY / LONG when Alpha Trend line crosses above its 2 bars offsetted line and there would be a green filling between them
SELL / SHORT when Alpha Trend line crosses below its 2 bars offsetted line and filling would be red then.
3- Alpha Trend lines
-act as support levels when an uptrend occurs trailing 1*ATR (default coefficient) distance from bar's low values
-conversely, act as resistance levels when a downtrend occurs trailing 1*ATR (default coefficient) distance from bar's high values
and acting as trailing stop losses
the more Alpha Trend lines straighter the more supports and resistances become stronger.
4- Trend Magic has CCI in calculation
Alpha Trend has MFI as momentum, but when there's no volume data MFI has 0 values, so there's a button to change calculation considering RSI after checking the relevant box to overcome this problem when there is no volume data in that chart.
Momentum: RSI and MFI
Trend: Magic Trend
Volatility: ATR,
Trailing STOP: ATR TRAILING STOP
Volume: MFI
Alpha trend is really a combination of different types...
default values:
coefficient: 1 which is the factor of trailing ATR value
common period: 14 which is the length of ATR MFI and RSI
CSS:
#https://www.tradingview.com/script/o50NYLAZ-AlphaTrend/
#// author © KivancOzbilgic
#// developer © KivancOzbilgic
# Converted and mod by Sam4Cok@Samer800 - 09/2022
#indicator('AlphaTrend', shorttitle='AT',
input showLebel = no; # Show Lebel?
input SignalType = {Non,Default AlphaTrend, AlphaMax, Both};
input MomType = {default MFI, RSI, FireFly};
input AlphaTrendWidth = 2;
input Multiplier = 1.1; # 'Multiplier'
input Period = 14; # 'Common Period'
input AlphaMaxLength =10; # 'AlphaMaxLength'
input src = close;
def na = Double.NaN;
AddLabel(showLebel, SignalType, Color.WHITE);
##### Script
script nz {
input data = 0;
input replacement = 0;
def ret_val = if IsNaN(data) then replacement else data;
plot return = ret_val;
}
#rescale(_src, _oldMin, _oldMax, _newMin, _newMax) =>
script rescale {
input _src = close;
input _oldMin = 0;
input _oldMax = 0;
input _newMin = 0;
input _newMax = 0;
def rescale = _newMin + (_newMax - _newMin) * (_src - _oldMin) / Max(_oldMax - _oldMin, 0.0000000010);
plot return = rescale;
}
# stoch(source, high, low, length) =>
script stoch {
input src = close;
input h = high;
input l = low;
input len = 0;
def stoch = 100 * (src - Lowest(l, len)) / (Highest(h, len) - Lowest(l, len));
plot return = stoch;
}
#averageS(bp, tr_, length) =>
script averageS {
input bp = close;
input tr_ = close;
input length = 0;
def average = Sum(bp, length) / Sum(tr_, length);
plot return = average;
}
#barssince(Condition) =>
script barssince {
input Condition = 0;
def barssince = if Condition then 1 else barssince[1] + 1;
plot return = barssince;
}
### Filters
def rsi1 = RSI(Price = src, Length = Period);
def mfi1 = MoneyFlowIndex(Length = Period);
### FireFly Oscillator
def v2 = (high + low + close * 2) / 4;
def v3 = ExpAverage(v2, Period);
def v4 = StDev(v2, Period);
def v5 = (v2 - v3) * 100 / If(v4 == 0, 1, v4);
def v6 = ExpAverage(v5, 3);
def v7 = v6;
def ww = (ExpAverage(v7, Period) + 100) / 2 - 4;
def FireFly = rescale(ww, -50, 150, 0, 100);
#######
def nATR = SimpleMovingAvg(TrueRange(high, close, low), Period);
def upT = low - nATR * Multiplier;
def downT = high + nATR * Multiplier;
#### AlphaTrend Calc
def AlphaTrend =
if (if MomType == MomType.RSI then rsi1 >= 50 else
if MomType == MomType.MFI then mfi1 >= 50 else
if MomType == MomType.FireFly then FireFly >= 50 else na) then
if upT < nz(AlphaTrend[1]) then nz(AlphaTrend[1]) else upT else
if downT > nz(AlphaTrend[1]) then nz(AlphaTrend[1]) else downT;
def color1 = if AlphaTrend > AlphaTrend[2] then 1 else
if AlphaTrend < AlphaTrend[2] then -1 else
if AlphaTrend[1] > AlphaTrend[3] then 1 else -1;
plot Alpha = AlphaTrend;
Alpha.SetDefaultColor(CreateColor(33, 150, 243));
plot Alpha2 = AlphaTrend[AlphaTrendWidth];
Alpha2.SetDefaultColor(CreateColor(156, 39, 176));
AddCloud(Alpha, Alpha2, CreateColor(33, 150, 243), CreateColor(136, 14, 79));
###########
def buySignalk = AlphaTrend crosses above AlphaTrend[AlphaTrendWidth];
def sellSignalk = AlphaTrend crosses below AlphaTrend[AlphaTrendWidth];
def K1 = barssince(buySignalk);
def K2 = barssince(sellSignalk);
def O1 = barssince(buySignalk[1]);
def O2 = barssince(sellSignalk[1]);
def BuySig = if (SignalType == SignalType.AlphaTrend or SignalType == SignalType.Both) and buySignalk and O1 > K2 then AlphaTrend[AlphaTrendWidth] * 0.9999 else na;
def SellSig = if (SignalType == SignalType.AlphaTrend or SignalType == SignalType.Both) and sellSignalk and O2 > K1 then AlphaTrend[AlphaTrendWidth] * 1.0001 else na;
AddChartBubble(BuySig, low - 7 * TickSize(), "Buy", CreateColor(33, 150, 243), no);
AddChartBubble(SellSig, high + 7 * TickSize(), "Sell", CreateColor(156, 39, 176), yes);
#### Alpha Max
#//----
def ama;
def hhama = highest(high, AlphaMaxLength);
def llama = lowest(low, AlphaMaxLength);
def hh = max(sign(hhama-hhama[1]),0);
def ll = max(sign(llama-llama[1])*-1,0);
def tc = power(SimpleMovingAvg(if hh or ll then 1 else 0,AlphaMaxLength),2);
ama = nz(ama[1]+tc*(src-ama[1]),src);
def AlphaMx = ama; #,"Plot",#ff1100,2)
def buySignalMx = ((AlphaMx crosses above AlphaTrend[AlphaTrendWidth]) and AlphaMx > AlphaMx[1]);
def sellSignalMx = ((AlphaMx crosses below AlphaTrend[AlphaTrendWidth]) and AlphaMx < AlphaMx[1]);
def BuySigMx = if (SignalType == SignalType.AlphaMax or SignalType == SignalType.Both) and buySignalMx and O1 > K2 then AlphaTrend[AlphaTrendWidth] * 0.9999 else na;
def SellSigMx = if (SignalType == SignalType.AlphaMax or SignalType == SignalType.Both) and sellSignalMx and O2 > K1 then AlphaTrend[AlphaTrendWidth] * 1.0001 else na;
AddChartBubble(BuySigMx, low - 7 * TickSize(), "Max", Color.GREEN, no);
AddChartBubble(SellSigMx, high + 7 * TickSize(), "Max", Color.RED, yes);
##### END
Last edited by a moderator: