Trend-Following Combo-SuperTrend, EMA, Aroon, DMI, Laguerre RSI For ThinkOrSwim

ajai

New member
VIP
Author states:
This is a trend-following indicator which condenses two SuperTrend indicators -- one based on analysis over a shorter period of time (1.5, 7), and one based on analysis over a longer period of time (1.65, 100) -- into a single indicator which appears on your chart only when both the shorter- and longer-term analysis indicates a "SuperTrend" in the same direction.

Additionally, potential trade entry indicators are displayed in the form of up and down arrows when (by default) three of the following five indicators suggest that the market is trending in the same direction as both the shorter- and longer-term SuperTrend indicators:

  • EMA Crossover (8, 15)
  • Aroon Indicator (8)
  • Aroon Oscillator (8)
  • Directional Movement Index (DI +/-) (8)
  • Laguerre RSI (13)

jSDpFsq.png


Original Tradingview Code:
https://www.tradingview.com/script/...-Combo-SuperTrend-EMA-Aroon-DMI-Laguerre-RSI/

For ThinkOrSwim Code, see below post.
 
Last edited by a moderator:
https://www.tradingview.com/script/...-Combo-SuperTrend-EMA-Aroon-DMI-Laguerre-RSI/
// This source code is subject to the terms of the Mozilla Public License 2.0 at
// https://mozilla.org/MPL/2.0/
//
// Created by jadamcraig
//
// Much of this tool is made possible thanks to indicator code made available by
// the following authors:
// * SuperTrend by Rajandran R
// * Aroon w/ crossovers highlighted by seiglerj
// * Aroon Oscillator by jcrewolinsky
// * Directional Movement Index by TradingView
// * Laguerre RSA (Self Adjusting Alpha with Fractals Energy) by everget
//
//@version=4

study("Trend-Following Combo - SuperTrend, EMA Crossover, Aroon Indicator, Aroon Oscillator, DMI (DI +/-), Laguerre RSI", shorttitle="TFC", overlay = true)

// Input Variables
GetConfirmation = input(title="Get trend confirmation from longer timeframe?", defval=true)
ConfirmationResolution = input(title="Confirmation Timeframe", type = input.resolution, defval = "D")
St1Factor = input(title = "SuperTrend 1: Factor", defval = 1.5, minval = 1.00, maxval = 100, step = 0.01)
St1Period = input(title = "SuperTrend 1: Period", defval = 7, minval = 1, maxval = 100, step = 1)
St2Factor = input(title = "SuperTrend 2: Factor", defval = 1.65, minval = 1.00, maxval = 100, step = 0.01)
St2Period = input(title = "SuperTrend 2: Period", defval = 100, minval = 1, maxval = 100, step = 1)
EmaFast = input(title = "EMA Cross: Fast", defval = 8, step = 1)
EmaSlow = input(title = "EMA Cross: Slow", defval = 15, step = 1)
AroonLength = input(title = "Aroon: Length", defval = 8, step = 1)
DmiLength = input(title = "DMI: Length", defval = 8, step = 1)
LrsiAlpha = input(title = "LRSI: Alpha", defval = 0.7, minval = 0, step = 0.1)
LrsiFeLength = input(title = "LRSI: Fractals Energy Length", type = input.integer, defval = 13)
LrsiApplyFractalsEnergy = input(title="LRSI: Apply Fractals Energy?", defval=true)
LrsiApplyNormalization = input(title="LRSI: Apply Normalization to [0, 100]?", defval=false)
Threshold = input(title = "Indicator Threshold", defval = 3, minval = 1, maxval = 5, step = 1)

// Define SuperTrend Functions
StUp(StFactor, StPeriod) => hl2 - (StFactor * atr(StPeriod))
StDn(StFactor, StPeriod) => hl2 + (StFactor * atr(StPeriod))

// Determine SuperTrend 1 Values on First Timeframe
St1TrendUp_Tf1 = 0.0
St1TrendUp_Tf1 := close[1] > St1TrendUp_Tf1[1] ? max(StUp(St1Factor, St1Period), St1TrendUp_Tf1[1]) : StUp(St1Factor, St1Period)
St1TrendDown_Tf1 = 0.0
St1TrendDown_Tf1 := close[1] < St1TrendDown_Tf1[1] ? min(StDn(St1Factor, St1Period), St1TrendDown_Tf1[1]) : StDn(St1Factor, St1Period)
St1Trend_Tf1 = 0.0
St1Trend_Tf1 := close > St1TrendDown_Tf1[1] ? 1 : close < St1TrendUp_Tf1[1] ? -1 : nz(St1Trend_Tf1[1],1)

// Determine SuperTrend 1 Values on Second Timeframe
St1TrendUp_Tf2 = 0.0
St1TrendUp_Tf2 := close[1] > St1TrendUp_Tf2[1] ? max(security(syminfo.tickerid, ConfirmationResolution, StUp(St1Factor, St1Period)), St1TrendUp_Tf2[1]) : security(syminfo.tickerid, ConfirmationResolution, StUp(St1Factor, St1Period))
St1TrendDown_Tf2 = 0.0
St1TrendDown_Tf2 := close[1] < St1TrendDown_Tf2[1] ? min(security(syminfo.tickerid, ConfirmationResolution, StDn(St1Factor, St1Period)), St1TrendDown_Tf2[1]) : security(syminfo.tickerid, ConfirmationResolution, StDn(St1Factor, St1Period))
St1Trend_Tf2 = 0.0
St1Trend_Tf2 := close > St1TrendDown_Tf2[1] ? 1 : close < St1TrendUp_Tf2[1] ? -1 : nz(St1Trend_Tf2[1],1)

// Determine SuperTrend 2 Values on First Timeframe
St2TrendUp_Tf1 = 0.0
St2TrendUp_Tf1 := close[1] > St2TrendUp_Tf1[1] ? max(StUp(St2Factor, St2Period), St2TrendUp_Tf1[1]) : StUp(St2Factor, St2Period)
St2TrendDown_Tf1 = 0.0
St2TrendDown_Tf1 := close[1] < St2TrendDown_Tf1[1] ? min(StDn(St2Factor, St2Period), St2TrendDown_Tf1[1]) : StDn(St2Factor, St2Period)
St2Trend_Tf1 = 0.0
St2Trend_Tf1 := close > St2TrendDown_Tf1[1] ? 1 : close < St2TrendUp_Tf1[1] ? -1 : nz(St2Trend_Tf1[1],1)

// Determine SuperTrend 2 Values on Second Timeframe
St2TrendUp_Tf2 = 0.0
St2TrendUp_Tf2 := close[1] > St2TrendUp_Tf2[1] ? max(security(syminfo.tickerid, ConfirmationResolution, StUp(St2Factor, St2Period)), St2TrendUp_Tf2[1]) : security(syminfo.tickerid, ConfirmationResolution, StUp(St2Factor, St2Period))
St2TrendDown_Tf2 = 0.0
St2TrendDown_Tf2 := close[1] < St2TrendDown_Tf2[1] ? min(security(syminfo.tickerid, ConfirmationResolution, StDn(St2Factor, St2Period)), St2TrendDown_Tf2[1]) : security(syminfo.tickerid, ConfirmationResolution, StDn(St2Factor, St2Period))
St2Trend_Tf2 = 0.0
St2Trend_Tf2 := close > St2TrendDown_Tf2[1] ? 1 : close < St2TrendUp_Tf2[1] ? -1 : nz(St2Trend_Tf2[1],1)

// Combine the SuperTrends on the first timeframe into one, determine values, and plot
StComboTrend_Tf1 = 0.0
StComboTrend_Tf1 := St1Trend_Tf1 == St2Trend_Tf1 ? St1Trend_Tf1 : na
StComboTrendUp_Tf1 = St1TrendUp_Tf1 < St2TrendUp_Tf1 ? St1TrendUp_Tf1 : St2TrendUp_Tf1
StComboTrendDown_Tf1 = St1TrendDown_Tf1 > St2TrendDown_Tf1 ? St1TrendDown_Tf1 : St2TrendDown_Tf1
StComboTsl_Tf1 = StComboTrend_Tf1 == 1 ? StComboTrendUp_Tf1 : StComboTrend_Tf1 == -1 ? StComboTrendDown_Tf1 : na
StComboLinecolor_Tf1 = StComboTrend_Tf1 == 1 ? #00ff00 : #ff0000
plot(StComboTsl_Tf1, color = StComboLinecolor_Tf1, style = plot.style_linebr, linewidth = 2, title = "SuperTrend Combo (Chart Timeframe)")

// Combine the SuperTrends on the second timeframe into one and determine values
StComboTrend_Tf2 = 0.0
StComboTrend_Tf2 := St1Trend_Tf2 == St2Trend_Tf2 ? St1Trend_Tf2 : na
StComboTrendUp_Tf2 = St1TrendUp_Tf2 < St2TrendUp_Tf2 ? St1TrendUp_Tf2 : St2TrendUp_Tf2
StComboTrendDown_Tf2 = St1TrendDown_Tf2 > St2TrendDown_Tf2 ? St1TrendDown_Tf2 : St2TrendDown_Tf2
StComboTsl_Tf2 = StComboTrend_Tf2 == 1 ? StComboTrendUp_Tf2 : StComboTrend_Tf2 == -1 ? StComboTrendDown_Tf2 : na

// Determine Overall SuperTrend Direction
StComboTrend = 0.0
StComboTrend := GetConfirmation == true ? StComboTrend_Tf1 == StComboTrend_Tf2 ? StComboTrend_Tf1 : na : StComboTrend_Tf1

// Define EMA Cross and Determine Status
Ma1 = ema(close, EmaFast)
Ma2 = ema(close, EmaSlow)
MaTrend = Ma1 < Ma2 ? -1 : 1

// Define Aroon Indicator and Determine Status
AroonIndicatorUpper = 100 * (highestbars(high, AroonLength + 1) + AroonLength) / AroonLength
AroonIndicatorLower = 100 * (lowestbars(low, AroonLength + 1) + AroonLength) / AroonLength
AroonIndictorTrend = 0
AroonIndictorTrend := crossover(AroonIndicatorUpper, AroonIndicatorLower) ? 1 : crossover(AroonIndicatorLower, AroonIndicatorUpper) ? -1 : AroonIndictorTrend[1]

// Define Aroon Oscillator and Determine Status
AroonOscillatorMidpoint = 0
AroonOscillator = AroonIndicatorUpper - AroonIndicatorLower
AroonOscillatorSignal = 0
AroonOscillatorSignal := crossover(AroonOscillator, -80) ? 1 : crossunder(AroonOscillator, 80) ? -1 : AroonOscillatorSignal[1]

// Define Directional Movement Index and Determine Values
DmiUp = change(high)
DmiDown = -change(low)
DmiPlusDm = na(DmiUp) ? na : (DmiUp > DmiDown and DmiUp > 0 ? DmiUp : 0)
DmiMinusDm = na(DmiDown) ? na : (DmiDown > DmiUp and DmiDown > 0 ? DmiDown : 0)
DmiTrur = rma(tr, DmiLength)
DmiPlus = fixnan(100 * rma(DmiPlusDm, DmiLength) / DmiTrur)
DmiMinus = fixnan(100 * rma(DmiMinusDm, DmiLength) / DmiTrur)
DmiTrend = 0
DmiTrend := crossover(DmiPlus, DmiMinus) ? 1 : crossover(DmiMinus, DmiPlus) ? -1 : DmiTrend[1]

// Define Laguerre RSI and Determine Values
LrsiOC = (open + nz(close[1])) / 2
LrsiHC = max(high, nz(close[1]))
LrsiLC = min(low, nz(close[1]))
LrsiFeSrc = (LrsiOC + LrsiHC + LrsiLC + close) / 4
LrsiFeAlpha = log(sum((LrsiHC - LrsiLC) / (highest(LrsiFeLength) - lowest(LrsiFeLength)), LrsiFeLength)) / log(LrsiFeLength)
LrsiAlphaCalc = LrsiApplyFractalsEnergy ? LrsiFeAlpha : LrsiAlpha
LrsiL0 = 0.0
LrsiL0 := LrsiAlphaCalc * (LrsiApplyFractalsEnergy ? LrsiFeSrc : close) + (1 - LrsiAlphaCalc) * nz(LrsiL0[1])
LrsiL1 = 0.0
LrsiL1 := -(1 - LrsiAlphaCalc) * LrsiL0 + nz(LrsiL0[1]) + (1 - LrsiAlphaCalc) * nz(LrsiL1[1])
LrsiL2 = 0.0
LrsiL2 := -(1 - LrsiAlphaCalc) * LrsiL1 + nz(LrsiL1[1]) + (1 - LrsiAlphaCalc) * nz(LrsiL2[1])
LrsiL3 = 0.0
LrsiL3 := -(1 - LrsiAlphaCalc) * LrsiL2 + nz(LrsiL2[1]) + (1 - LrsiAlphaCalc) * nz(LrsiL3[1])
LrsiCU = 0.0
LrsiCU := (LrsiL0 >= LrsiL1 ? LrsiL0 - LrsiL1 : 0) + (LrsiL1 >= LrsiL2 ? LrsiL1 - LrsiL2 : 0) + (LrsiL2 >= LrsiL3 ? LrsiL2 - LrsiL3 : 0)
LrsiCD = 0.0
LrsiCD := (LrsiL0 >= LrsiL1 ? 0 : LrsiL1 - LrsiL0) + (LrsiL1 >= LrsiL2 ? 0 : LrsiL2 - LrsiL1) + (LrsiL2 >= LrsiL3 ? 0 : LrsiL3 - LrsiL2)
Lrsi = LrsiCU + LrsiCD != 0
? LrsiApplyNormalization ? 100 * LrsiCU / (LrsiCU + LrsiCD) : LrsiCU / (LrsiCU + LrsiCD)
: 0
LrsiMult = (LrsiApplyNormalization ? 100 : 1)
LrsiOverBought = 0.8 * LrsiMult
LrsiOverSold = 0.2 * LrsiMult
LrsiSignal = 0
LrsiSignal := crossover(Lrsi, LrsiOverSold) ? 1 : crossunder(Lrsi, LrsiOverBought) ? -1 : LrsiSignal[1]

// Determine Strength of Trend Based on Status of All Indicators
MaTrendCalc = StComboTrend == MaTrend ? StComboTrend : 0
AroonIndictorTrendCalc = StComboTrend == AroonIndictorTrend ? StComboTrend : 0
AroonOscillatorSignalCalc = StComboTrend == AroonOscillatorSignal ? StComboTrend : 0
DmiTrendCalc = StComboTrend == DmiTrend ? StComboTrend : 0
LrsiSignalCalc = StComboTrend == LrsiSignal ? StComboTrend : 0
TrendStrength = MaTrendCalc + AroonIndictorTrendCalc + AroonOscillatorSignalCalc + DmiTrendCalc + LrsiSignalCalc

// Plot Entry Arrows
EntryDirection = 0
EntryDirection := StComboTrend == 1 and TrendStrength >= Threshold and TrendStrength[1] < Threshold ? 1 : StComboTrend == -1 and TrendStrength <= -Threshold and TrendStrength[1] > -Threshold ? -1 : EntryDirection[1]
plotarrow(StComboTrend == 1 and TrendStrength >= Threshold and TrendStrength[1] < Threshold ? StComboTrend : na, title="Up Entry Arrow", colorup=color.yellow, maxheight=40, minheight=20, transp=20)
//plotarrow(EntryDirection == 1 and EntryDirection[1] != 1 ? StComboTrend : na, title="Up Entry Arrow", colorup=color.yellow, maxheight=40, minheight=20, transp=20)
plotarrow(StComboTrend == -1 and TrendStrength <= -Threshold and TrendStrength[1] > -Threshold ? StComboTrend : na, title="Down Entry Arrow", colordown=color.yellow, maxheight=40, minheight=20, transp=20)
//plotarrow(EntryDirection == -1 and EntryDirection[1] != -1 ? StComboTrend : na, title="Down Entry Arrow", colordown=color.yellow, maxheight=40, minheight=20, transp=20)
check the below:

CSS:
# indicator for TOS
#// Created by jadamcraig
#// Much of this tool is made possible thanks to indicator code made available by
#// the following authors:
#//  * SuperTrend by Rajandran R
#//  * Aroon w/ crossovers highlighted by seiglerj
#//  * Aroon Oscillator by jcrewolinsky
#//  * Directional Movement Index by TradingView
#//  * Laguerre RSA (Self Adjusting Alpha with Fractals Energy) by everget
#study("Trend-Following Combo - SuperTrend, EMA Crossover, Aroon Indicator, Aroon Oscillator, DMI (DI +/-), Laguerre RSI", shorttitle="TFC"
# Converted by Sam4Cok@Samer800    - 08/2024

#Hint LaguerreRsiNormalization: Apply Normalization to [0, 100]?.

input signalThreshold = 3;                           # "Indicator Threshold"
input GetTrendConfirmationFromLongerTimeframe = yes ;
input ConfirmationTimeframe = AggregationPeriod.DAY; # "Confirmation Timeframe"
input SuperTrendFactor1 = 1.5;                       # "SuperTrend 1: Factor"
input SuperTrendPeriod1 = 7;                         # "SuperTrend 1: Period"
input SuperTrendFactor2 = 1.65;                      # "SuperTrend 2: Factor"
input SuperTrendPeriod2 = 100;                       # "SuperTrend 2: Period"
input trendMovAvgType = AverageType.EXPONENTIAL;
input fastMovAvgLength = 8;                          # "EMA Cross: Fast"
input slowMovAvgLength = 15;                         # "EMA Cross: Slow"
input AroonLength = 8;                               # "Aroon: Length"
input DmiLength = 8;                                 # "DMI: Length"
input useLaguerreRsiFractalsEnergy = yes;            # "LRSI: Apply Fractals Energy?"
input LaguerreRsiNormalization = no;                 # "LRSI: Apply Normalization to [0, 100]?"
input LaguerreRsiAlpha = 0.7;                        # "LRSI: Alpha"
input LrsiFractalsEnergyLength = 13;                 # "LRSI: Fractals Energy Length"


def na = Double.NaN;
def current = GetAggregationPeriod();
def tf = Max(current, ConfirmationTimeframe);
def trHF = TrueRange(high(Period = tf), close(Period = tf), low(Period = tf));
def atr1 = ATR(Length = SuperTrendPeriod1);
def atr2 = ATR(Length = SuperTrendPeriod2);
def atrHTF1 = WildersAverage(trHF, SuperTrendPeriod1);
def atrHTF2 = WildersAverage(trHF, SuperTrendPeriod2);
def StUp1 = hl2 - (SuperTrendFactor1 * atr1);
def StUp2 = hl2 - (SuperTrendFactor2 * atr2);
def StDn1 = hl2 + (SuperTrendFactor1 * atr1);
def StDn2 = hl2 + (SuperTrendFactor2 * atr2);
def StUpHTF1 = hl2(Period = tf) - (SuperTrendFactor1 * atrHTF1);
def StUpHTF2 = hl2(Period = tf) - (SuperTrendFactor2 * atrHTF2);
def StDnHTF1 = hl2(Period = tf) + (SuperTrendFactor1 * atrHTF1);
def StDnHTF2 = hl2(Period = tf) + (SuperTrendFactor2 * atrHTF2);

#// Determine SuperTrend 1 Values on First Timeframe
def St1TrendUp_Tf1 = if close[1] > St1TrendUp_Tf1[1] then Max(StUp1, St1TrendUp_Tf1[1]) else StUp1;
def St1TrendDown_Tf1 = if close[1] < St1TrendDown_Tf1[1] then Min(StDn1, St1TrendDown_Tf1[1]) else StDn1;
def St1Trend_Tf1 = if (St1TrendUp_Tf1 and St1TrendDown_Tf1) then
                   if close > St1TrendDown_Tf1[1] then 1 else
                   if close < St1TrendUp_Tf1[1] then -1 else St1Trend_Tf1[1] else 1;
#// Determine SuperTrend 1 Values on Second Timeframe
def St1TrendUp_Tf2 = if close[1] > St1TrendUp_Tf2[1] then Max(StUpHTF1, St1TrendUp_Tf2[1]) else StUpHTF1;
def St1TrendDown_Tf2 = if close[1] < St1TrendDown_Tf2[1] then Min(StDnHTF1, St1TrendDown_Tf2[1]) else StDnHTF1;
def St1Trend_Tf2 = if (St1TrendUp_Tf2 and St1TrendDown_Tf2) then
                   if close > St1TrendDown_Tf2[1] then 1 else
                   if close < St1TrendUp_Tf2[1] then -1 else St1Trend_Tf2[1] else 1;
#// Determine SuperTrend 2 Values on First Timeframe
def St2TrendUp_Tf1 = if close[1] > St2TrendUp_Tf1[1] then Max(StUp2, St2TrendUp_Tf1[1]) else StUp2;
def St2TrendDown_Tf1 = if close[1] < St2TrendDown_Tf1[1] then Min(StDn2, St2TrendDown_Tf1[1]) else StDn2;
def St2Trend_Tf1 = if (St2TrendUp_Tf1 and St2TrendDown_Tf1) then
                   if close > St2TrendDown_Tf1[1] then 1 else
                   if close < St2TrendUp_Tf1[1] then -1 else St2Trend_Tf1[1] else 1;
#// Determine SuperTrend 2 Values on Second Timeframe
def St2TrendUp_Tf2 = if close[1] > St2TrendUp_Tf2[1] then Max(StUpHTF2, St2TrendUp_Tf2[1]) else StUpHTF2;
def St2TrendDown_Tf2 = if close[1] < St2TrendDown_Tf2[1] then Min(StDnHTF2, St2TrendDown_Tf2[1]) else StDnHTF2;
def St2Trend_Tf2 = if (St2TrendUp_Tf2 and St2TrendDown_Tf2) then
                   if close > St2TrendDown_Tf2[1] then 1 else
                   if close < St2TrendUp_Tf2[1] then -1 else St2Trend_Tf2[1] else 1;
#// Combine the SuperTrends on the first timeframe into one, determine values, and plot
def StComboTrend_Tf1 = if St1Trend_Tf1 == St2Trend_Tf1 then St1Trend_Tf1 else 0;
def StComboTrendUp_Tf1 = if St1TrendUp_Tf1 < St2TrendUp_Tf1 then St1TrendUp_Tf1 else St2TrendUp_Tf1;
def StComboTrendDown_Tf1 = if St1TrendDown_Tf1 > St2TrendDown_Tf1 then St1TrendDown_Tf1 else St2TrendDown_Tf1;
def StComboTsl_Tf1 = if StComboTrend_Tf1 == 1 then StComboTrendUp_Tf1 else
                     if StComboTrend_Tf1 == -1 then StComboTrendDown_Tf1 else 0;
def StComboLinecolor_Tf1 = StComboTrend_Tf1 == 1; # ? #00ff00 : #ff0000
#-- plot combo
plot SuperTrendCombo = if StComboTsl_Tf1 then StComboTsl_Tf1 else na;
SuperTrendCombo.AssignValueColor(if StComboLinecolor_Tf1 then Color.GREEN else Color.RED);

#// Combine the SuperTrends on the second timeframe into one and determine values
def StComboTrend_Tf2 = if St1Trend_Tf2 == St2Trend_Tf2 then St1Trend_Tf2 else 0;
#// Determine Overall SuperTrend Direction
def StComboTrend = if GetTrendConfirmationFromLongerTimeframe then
                   if StComboTrend_Tf1 == StComboTrend_Tf2 then StComboTrend_Tf1 else 0 else StComboTrend_Tf1;
#// Define EMA Cross and Determine Status
def Ma1 = MovingAverage(trendMovAvgType, close, fastMovAvgLength);
def Ma2 = MovingAverage(trendMovAvgType, close, slowMovAvgLength);
def MaTrend = if Ma1 < Ma2 then -1 else 1;

#// Define Aroon Indicator and Determine Status
def AroonIndicatorUpper = 100 * (GetMaxValueOffset(high, AroonLength + 1) + AroonLength) / AroonLength;
def AroonIndicatorLower = 100 * (GetMinValueOffset(low, AroonLength + 1) + AroonLength) / AroonLength;
def AroonIndictorTrend = if (AroonIndicatorUpper crosses above AroonIndicatorLower) then 1 else
                         if (AroonIndicatorLower crosses below AroonIndicatorUpper) then -1 else AroonIndictorTrend[1];
#// Define Aroon Oscillator and Determine Status
def AroonOscillator = AroonIndicatorUpper - AroonIndicatorLower;
def AroonOscillatorSignal = if (AroonOscillator Crosses Above -80) then 1 else
                            if (AroonOscillator Crosses Below  80) then -1 else AroonOscillatorSignal[1];
#// Define Directional Movement Index and Determine Values
def DmiUp = (high - high[1]);
def DmiDown = -(low - low[1]);
def DmiPlusDm = if !DmiUp then na else (if DmiUp > DmiDown and DmiUp > 0 then DmiUp else 0);
def DmiMinusDm = if !DmiDown then na else (if DmiDown > DmiUp and DmiDown > 0 then DmiDown else 0);
def DmiTrur = ATR(Length = DmiLength);
def DmiP = (100 * WildersAverage(DmiPlusDm, DmiLength) / DmiTrur);
def DmiM = (100 * WildersAverage(DmiMinusDm, DmiLength) / DmiTrur);
def DmiPlus = if !isNaN(DmiP) then DmiP else DmiPlus[1];
def DmiMinus = if !isNaN(DmiM) then DmiM else DmiMinus[1];
def DmiTrend = if (DmiPlus Crosses Above DmiMinus) then 1 else
               if (DmiMinus Crosses Below DmiPlus) then -1 else DmiTrend[1];
#// Define Laguerre RSI and Determine Values
def LrsiOC = (open + close[1]) / 2;
def LrsiHC = max(high, close[1]);
def LrsiLC = min(low, close[1]);
def LrsiFeSrc = (LrsiOC + LrsiHC + LrsiLC + close) / 4;
def hh = highest(high, LrsiFractalsEnergyLength);
def ll = lowest(low, LrsiFractalsEnergyLength);
def LrsiFeAlpha = log(sum((LrsiHC - LrsiLC) / (hh - ll), LrsiFractalsEnergyLength)) / log(LrsiFractalsEnergyLength);
def LrsiAlphaCalc = if useLaguerreRsiFractalsEnergy then LrsiFeAlpha else LaguerreRsiAlpha;
def LrsiL0 = LrsiAlphaCalc * (if useLaguerreRsiFractalsEnergy then LrsiFeSrc else close) +
            (1 - LrsiAlphaCalc) * LrsiL0[1];
def LrsiL1 = -(1 - LrsiAlphaCalc) * LrsiL0 + LrsiL0[1] + (1 - LrsiAlphaCalc) * LrsiL1[1];
def LrsiL2 = -(1 - LrsiAlphaCalc) * LrsiL1 + LrsiL1[1] + (1 - LrsiAlphaCalc) * LrsiL2[1];
def LrsiL3 = -(1 - LrsiAlphaCalc) * LrsiL2 + LrsiL2[1] + (1 - LrsiAlphaCalc) * LrsiL3[1];
def LrsiCU = (if LrsiL0 >= LrsiL1 then LrsiL0 - LrsiL1 else 0) + (if LrsiL1 >= LrsiL2 then LrsiL1 - LrsiL2 else 0) +
             (if LrsiL2 >= LrsiL3 then LrsiL2 - LrsiL3 else 0);
def LrsiCD = (if LrsiL0 >= LrsiL1 then 0 else LrsiL1 - LrsiL0) + (if LrsiL1 >= LrsiL2 then 0 else LrsiL2 - LrsiL1) +
             (if LrsiL2 >= LrsiL3 then 0 else LrsiL3 - LrsiL2);
def Lrsi = if (LrsiCU + LrsiCD) != 0 then if LaguerreRsiNormalization then
            100 * LrsiCU / (LrsiCU + LrsiCD) else LrsiCU / (LrsiCU + LrsiCD) else 0;
def LrsiMult = (if LaguerreRsiNormalization then 100 else 1);
def LrsiOverBought = 0.8 * LrsiMult;
def LrsiOverSold = 0.2 * LrsiMult;
def LrsiSignal = if (Lrsi Crosses Above LrsiOverSold) then 1 else
                 if (Lrsi Crosses Below LrsiOverBought) then -1 else LrsiSignal[1];

#// Determine Strength of Trend Based on Status of All Indicators
def MaTrendCalc = if StComboTrend == MaTrend then StComboTrend else 0;
def AroonIndictorTrendCalc = if StComboTrend == AroonIndictorTrend then StComboTrend else 0;
def AroonOscillatorSignalCalc = if StComboTrend == AroonOscillatorSignal then StComboTrend else 0;
def DmiTrendCalc = if StComboTrend == DmiTrend then StComboTrend else 0;
def LrsiSignalCalc = if StComboTrend == LrsiSignal then StComboTrend else 0;
def TrendStrength = MaTrendCalc + AroonIndictorTrendCalc + AroonOscillatorSignalCalc + DmiTrendCalc + LrsiSignalCalc;

#/ Plot Entry Arrows
def sigUp = StComboTrend == 1 and TrendStrength >= signalThreshold and TrendStrength[1] < signalThreshold;
def sigDn = StComboTrend == -1 and TrendStrength <= -signalThreshold and TrendStrength[1] > -signalThreshold;
#-- Signals
plot signalUp = if sigUp then low else na;
plot signalDn = if sigDn then high else na;
signalUp.SetPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
signalDn.SetPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN);
signalUp.SetDefaultColor(Color.CYAN);
signalDn.SetDefaultColor(Color.MAGENTA);

AddCloud(SuperTrendCombo, hl2, Color.DARK_RED, Color.DARK_GREEN);
#-- END of CODE
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
285 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top