LNL Trend System for ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
BhNM8b0.png

Author Message:
LNL Trend System is an ATR based day trading system specifically designed for intra-day traders and scalpers. The System works on any chart time frame & can be applied to any market. The study consist of two components - the Trend Line and the Stop Line. Trend System is based on a special ATR calculation that is achieved by combining the previous values of the 13 EMA in relation to the ATR which creates a line of deviations that visually look similar to the basic moving average but actually produce very different results ESPECIALLY in sideways market.
More Details: https://www.tradingview.com/v/m0G2Xv7r/

CODE:
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at
#// https://www.tradingview.com/v/m0G2Xv7r/
#// Created by © L&L Capital
# indicator("LNL Trend System", shorttitle = "LNL Trend System", overlay=true)
# Converted by Sam4Cok@Samer800    - 08/2023
#// Inputs

input TrendMode     = {"Tight", default "Normal", "Loose", "FOMC", "Net"};    # "Trend Mode"
input HtfMode       = {default "Auto", "Manual"};  # "HTF Mode"
input ManualTimeframe = AggregationPeriod.HOUR;    # "HTF Aggregation"
input ShowTrendBars = yes;        # "Show Trend Bars"
input ShowTrend     = yes;        # "Show Trend Line"
input ShowStopLine  = yes;        # "Show Stop Line"
input ShowHtfTrendLine = no;      # "Show HTF Trend Line"
input ShowHtfStopLine = no;       # "Show HTF Stop Line"
input ShowCloud = yes;            # "Show Cloud"
input ShowHtfCloud = no;          # "Show HTF Cloud"

def na = Double.NaN;
def last = isNaN(close);
def net = TrendMode == TrendMode."Net";
#fixnan(data)
script fixnan {
 input src = close;
     def data2;
     def bar = barnumber();
     if bar == 1 then {data2 = 0;} else
     if IsNaN(src) then {data2 = data2[1];} else
      {data2 = src;}
plot valid = data2;
}

#vwma(source, length)
script VWMA {
    input src = close;
    input len = 15;
    input v_ = volume;
    def v = if IsNaN(v_) then 1 else v_;
    def srcV = src * v;
    def srcVol = if IsNaN(srcV) then src else srcV;
    def VWMA = Average(srcVol, len) / Average(v, len);
    plot result = VWMA;
}
DefineGlobalColor("Bullish", CreateColor(39, 194, 46));
DefineGlobalColor("Bearish", CreateColor(255, 82, 82));
DefineGlobalColor("Neutral", CreateColor(67, 70, 81));
#// Trend Bars (DMI Colored Candles)
def tr_ = TrueRange(high, close, low);
def tr  = if IsNaN(tr_) then 0 else tr_;
def nATR = WildersAverage(tr, 14);
def hi = ((high - high[1]) > (low[1] - low)) and ((high - high[1]) > 0);
def lo = ((low[1] - low) > (high - high[1])) and ((low[1] - low) > 0);
def BullishDMI = if hi then (high - high[1]) else 0;
def BearishDMI = if lo then (low[1] - low) else 0;
def DMIUp = 100 * WildersAverage(BullishDMI, 14) / nATR;
def DMIDown = 100 * WildersAverage(BearishDMI, 14) / nATR;
def ADXx = if (DMIUp + DMIDown) > 0 then 100 * AbsValue(DMIUp - DMIDown) / (DMIUp + DMIDown) else na;
def ADX = WildersAverage(ADXx, 14);
def ColorBars = if (DMIUp > DMIDown and ADX > 20) then 1 else
                if (DMIUp < DMIDown and ADX > 20) then -1 else 0;
#ShowTrendBars
AssignPriceColor(if !ShowTrendBars then Color.CURRENT else
                 if ColorBars > 0 then GlobalColor("Bullish") else
                 if ColorBars < 0 then GlobalColor("Bearish") else GlobalColor("Neutral"));
#// Trend System (First Time Frame)
def ema8 =  vwma(close, 8);
def ema13 = vwma(close, 13);
def ema21 = vwma(close, 21);
def ema34 = vwma(close, 34);
def emaup = ema8 > ema13  and ema13 > ema21 and ema21 > ema34;
def emadn = ema8 < ema13  and ema13 < ema21 and ema21 < ema34;
def Trend = ExpAverage(close, 13);
def TrendColor = if emadn and close <= Trend then -1 else
                 if emaup and close >= Trend then 1 else 0;
plot TrendLine = if !ShowTrend then na else Trend; # "Trend", color = TrendColor
TrendLine.SetLineWeight(2);
TrendLine.AssignValueColor(if TrendColor > 0 then GlobalColor("Bullish") else
                           if TrendColor < 0 then GlobalColor("Bearish") else GlobalColor("Neutral"));
def ATRLength;
switch (TrendMode) {
case "Tight" :
    ATRLength = 60;
case "Normal":
    ATRLength = 80;
case "Loose" :
    ATRLength = 100;
case "FOMC"  :
    ATRLength = 120;
case "Net"   :
    ATRLength = 140;
}
def emaTr8 = ExpAverage(tr , 8);
def ATR = (ATRLength / 100) * emaTr8;
def Up = close > (Trend + ATR);
def Down = close < (Trend - ATR);
def T = if Up then 1 else if Down then -1 else T[1];
def StopLineColor =  T == 1;
plot StopLine = if !ShowStopLine then na else
                 if T == 1  then (Trend - ATR) else
                 if T == -1 then (Trend + ATR) else T[1];     # "StopLine"
StopLine.AssignValueColor(if StopLineColor then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLine.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRA = (ATRLength - 20) / 100 * emaTr8;
def Up11 = close > (Trend + ATRA);
def Down11 = close < (Trend - ATRA);
def T11 = if Up11 then 1 else if Down11 then -1 else T11[1];
def StopLineColor1 = T11 == 1;

plot StopLine2 = if !ShowStopLine then na else
                if T11 == 1 then (Trend - ATRA) else
                if T11 == -1 then (Trend + ATRA) else T11[1]; # "StopLine2"
StopLine2.AssignValueColor(if StopLineColor1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLine2.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRNET = if net then (ATRLength - 40) / 100 * emaTr8 else na;
def UpNET = close > (Trend + ATRNET);
def DownNET = close < (Trend - ATRNET);
def TNET = if UpNET then 1 else if DownNET then -1 else TNET[1];
def StopLineColorNET = TNET == 1;

plot StopLineNET = if !ShowStopLine then na else
                   if TNET == 1 then (Trend - ATRNET) else
                   if TNET == -1 then (Trend + ATRNET) else TNET[1];    # "StopLineNET"
StopLineNET.AssignValueColor(if StopLineColorNET then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNET.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRNET1 = if net then (ATRLength - 60) / 100 * emaTr8 else na;
def UpNET1 = close > (Trend + ATRNET1);
def DownNET1 = close < (Trend - ATRNET1);
def TNET1 = if UpNET1 then 1 else if DownNET1 then -1 else TNET1[1];
def StopLineColorNET1 = TNET1 == 1;

plot StopLineNET1 = if !ShowStopLine then na else
                    if TNET1 == 1 then (Trend - ATRNET1) else
                    if TNET1 == -1 then (Trend + ATRNET1) else TNET1[1]; # "StopLineNET1"
StopLineNET1.AssignValueColor(if StopLineColorNET1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNET1.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRNET2 = if net then (ATRLength - 80) / 100 * emaTr8 else na;
def UpNET2 = close > (Trend + ATRNET2);
def DownNET2 = close < (Trend - ATRNET2);
def TNET2 = if UpNET2 then 1 else if DownNET2 then -1 else TNET2[1];
def StopLineColorNET2 = TNET2 == 1;

plot StopLineNET2 = if !ShowStopLine then na else
                    if TNET2 == 1 then (Trend - ATRNET2) else
                    if TNET2 == -1 then (Trend + ATRNET2) else TNET2[1]; # "StopLineNET2"
StopLineNET2.AssignValueColor(if StopLineColorNET2 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNET2.SetPaintingStrategy(PaintingStrategy.DASHES);

#// Higher Time Frame Aggregations

def current = GetAggregationPeriod();
def TimeFrameA = 
      if current < AggregationPeriod.FIVE_MIN then AggregationPeriod.FIVE_MIN else
      if current < AggregationPeriod.THIRTY_MIN then AggregationPeriod.THIRTY_MIN else
      if current < AggregationPeriod.FOUR_HOURS then AggregationPeriod.FOUR_HOURS else
      if current < AggregationPeriod.DAY then AggregationPeriod.DAY else 
      if current < AggregationPeriod.WEEK then AggregationPeriod.WEEK else
      if current < AggregationPeriod.MONTH then AggregationPeriod.MONTH else 
      if current < AggregationPeriod.QUARTER then AggregationPeriod.QUARTER else current;
def TimeFrame;
switch (HTFMode) {
case "Auto" :
    TimeFrame = TimeFrameA;
case "Manual" :
    TimeFrame = ManualTimeframe;
}
def HighTf = high(Period = TimeFrame);
def LowTf  = low(Period = TimeFrame);
def CloseTf = close(Period = TimeFrame);
def volTf   = volume(Period = TimeFrame);
def trTf_   = TrueRange(HighTf, CloseTf, LowTf);
def trTf     = if IsNaN(trTf_) then (HighTf-LowTf) else trTf_;
def ematrTf8 = fixnan(ExpAverage(trTf, 8));
def ATRLength2 = ATRLength;

def ema82  = vwma(CloseTf, 8, volTf);
def ema132 = vwma(CloseTf, 13, volTf);
def ema212 = vwma(CloseTf, 21, volTf);
def ema342 = vwma(CloseTf, 34, volTf);
def emaup2 = ema82 > ema132  and ema132 > ema212 and ema212 > ema342;
def emadn2 = ema82 < ema132  and ema132 < ema212 and ema212 < ema342;

def Trend2 = ExpAverage(CloseTf, 13);
def TrendColor2 = if emadn2 and CloseTf <= Trend2 then -1 else
                  if emaup2 and CloseTf >= Trend2 then 1 else 0;

plot Trend2Line = if !ShowHtfTrendLine then na else Trend2;    # "Trend2"
Trend2Line.SetLineWeight(2);
Trend2Line.AssignValueColor(if TrendColor2 > 0 then GlobalColor("Bullish") else
                            if TrendColor2 < 0 then GlobalColor("Bearish") else GlobalColor("Neutral"));

def ATR2 = (ATRLength2 / 100) * ematrTf8;
def Up2 = CloseTf > (Trend2 + ATR2);
def Down2 = CloseTf < (Trend2 - ATR2);
def T2 = if Up2 then 1 else if Down2 then -1 else T2[1];
def StopLineColor2 = T2 == 1;

plot StopLineTf = if !ShowHtfStopLine then na else
                 if T2 == 1 then (Trend2 - ATR2) else
                 if T2 == -1 then (Trend2 + ATR2) else T2[1];    # "StopLine2"
StopLineTf.AssignValueColor(if StopLineColor2 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineTf.SetPaintingStrategy(PaintingStrategy.DASHES);
#ShowStop2

def ATR2A = (ATRLength2 - 20) / 100 * ematrTf8;
def Up2A = CloseTf > (Trend2 + ATR2A);
def Down2A = CloseTf < (Trend2 - ATR2A);
def T2A = if Up2A then 1 else if Down2A[1] then -1 else T2A[1];
def StopLineColor2A = T2A == 1;

plot StopLine2Tf = if !ShowHtfStopLine then na else
                   if T2A == 1 then (Trend2 - ATR2A) else
                   if T2A == -1 then (Trend2 + ATR2A) else T2A[1];    #  "StopLine2"
StopLine2Tf.AssignValueColor(if StopLineColor2A then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLine2Tf.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATR2ANET = if net then (ATRLength2 - 40) / 100 * ematrTf8 else na;
def Up2ANET = CloseTf > (Trend2 + ATR2ANET);
def Down2ANET = CloseTf < (Trend2 - ATR2ANET);
def T2ANET = if Up2ANET then 1 else if Down2ANET[1] then -1 else T2ANET[1];
def StopLineColor2ANET = T2ANET == 1;

plot StopLineNETtf = if !ShowHtfStopLine then na else
                     if T2ANET == 1 then (Trend2 - ATR2ANET) else
                     if T2ANET == -1 then (Trend2 + ATR2ANET) else T2ANET[1];    # StopLineColor2ANET
StopLineNETtf.AssignValueColor(if StopLineColor2ANET then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNETtf.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATR2ANET1 = if Net then (ATRLength2 - 60) /100 * ematrTf8 else na;
def Up2ANET1 = CloseTf > (Trend2 + ATR2ANET1);
def Down2ANET1 = CloseTf < (Trend2 - ATR2ANET1);
def T2ANET1 = if Up2ANET1 then 1 else if Down2ANET1[1] then -1 else T2ANET1[1];
def StopLineColor2ANET1 = T2ANET1 == 1;

plot StopLineNETtf1 = if !ShowHtfStopLine then na else
                      if T2ANET1 == 1 then (Trend2-ATR2ANET1) else
                      if T2ANET1 == -1 then (Trend2+ATR2ANET1) else T2ANET1[1];
StopLineNETtf1.AssignValueColor(if StopLineColor2ANET1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNETtf1.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATR2ANET2 = if Net then (ATRLength2 - 80) /100 * ematrTf8 else na;
def Up2ANET2 = CloseTf > (Trend2 + ATR2ANET2);
def Down2ANET2 = CloseTf < (Trend2 - ATR2ANET2);
def T2ANET2 = if Up2ANET2 then 1 else if Down2ANET2[1] then -1 else T2ANET2[1];
def StopLineColor2ANET2 = T2ANET2 == 1;

plot StopLineNETtf2 = if !ShowHtfStopLine then na else
                      if T2ANET2 == 1 then (Trend2-ATR2ANET2) else
                      if T2ANET2 == -1 then (Trend2+ATR2ANET2) else T2ANET2[1];
StopLineNETtf2.AssignValueColor(if StopLineColor2ANET1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNETtf2.SetPaintingStrategy(PaintingStrategy.DASHES);

#// Trend Clouds

def p1 = Trend;
def p2 = if T == 1 then (Trend-ATR) else if T == -1 then (Trend+ATR) else T[1];
AddCloud(if !ShowCloud then na else p1, p2, Color.DARK_GREEN, Color.DARK_RED);

def p3 = Trend2;
def p4 = if T2 == 1 then (Trend2-ATR2) else if T2 == -1 then (Trend2+ATR2) else T2[1];

AddCloud(if !ShowHTFCloud then na else p3 ,p4, Color.DARK_GREEN, Color.DARK_RED);

#--- END of CODE
 

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

BhNM8b0.png

Author Message:
LNL Trend System is an ATR based day trading system specifically designed for intra-day traders and scalpers. The System works on any chart time frame & can be applied to any market. The study consist of two components - the Trend Line and the Stop Line. Trend System is based on a special ATR calculation that is achieved by combining the previous values of the 13 EMA in relation to the ATR which creates a line of deviations that visually look similar to the basic moving average but actually produce very different results ESPECIALLY in sideways market.
More Details: https://www.tradingview.com/v/m0G2Xv7r/

CODE:
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at
#// https://www.tradingview.com/v/m0G2Xv7r/
#// Created by © L&L Capital
# indicator("LNL Trend System", shorttitle = "LNL Trend System", overlay=true)
# Converted by Sam4Cok@Samer800    - 08/2023
#// Inputs

input TrendMode     = {"Tight", default "Normal", "Loose", "FOMC", "Net"};    # "Trend Mode"
input HtfMode       = {default "Auto", "Manual"};  # "HTF Mode"
input ManualTimeframe = AggregationPeriod.HOUR;    # "HTF Aggregation"
input ShowTrendBars = yes;        # "Show Trend Bars"
input ShowTrend     = yes;        # "Show Trend Line"
input ShowStopLine  = yes;        # "Show Stop Line"
input ShowHtfTrendLine = no;      # "Show HTF Trend Line"
input ShowHtfStopLine = no;       # "Show HTF Stop Line"
input ShowCloud = yes;            # "Show Cloud"
input ShowHtfCloud = no;          # "Show HTF Cloud"

def na = Double.NaN;
def last = isNaN(close);
def net = TrendMode == TrendMode."Net";
#fixnan(data)
script fixnan {
 input src = close;
     def data2;
     def bar = barnumber();
     if bar == 1 then {data2 = 0;} else
     if IsNaN(src) then {data2 = data2[1];} else
      {data2 = src;}
plot valid = data2;
}

#vwma(source, length)
script VWMA {
    input src = close;
    input len = 15;
    input v_ = volume;
    def v = if IsNaN(v_) then 1 else v_;
    def srcV = src * v;
    def srcVol = if IsNaN(srcV) then src else srcV;
    def VWMA = Average(srcVol, len) / Average(v, len);
    plot result = VWMA;
}
DefineGlobalColor("Bullish", CreateColor(39, 194, 46));
DefineGlobalColor("Bearish", CreateColor(255, 82, 82));
DefineGlobalColor("Neutral", CreateColor(67, 70, 81));
#// Trend Bars (DMI Colored Candles)
def tr_ = TrueRange(high, close, low);
def tr  = if IsNaN(tr_) then 0 else tr_;
def nATR = WildersAverage(tr, 14);
def hi = ((high - high[1]) > (low[1] - low)) and ((high - high[1]) > 0);
def lo = ((low[1] - low) > (high - high[1])) and ((low[1] - low) > 0);
def BullishDMI = if hi then (high - high[1]) else 0;
def BearishDMI = if lo then (low[1] - low) else 0;
def DMIUp = 100 * WildersAverage(BullishDMI, 14) / nATR;
def DMIDown = 100 * WildersAverage(BearishDMI, 14) / nATR;
def ADXx = if (DMIUp + DMIDown) > 0 then 100 * AbsValue(DMIUp - DMIDown) / (DMIUp + DMIDown) else na;
def ADX = WildersAverage(ADXx, 14);
def ColorBars = if (DMIUp > DMIDown and ADX > 20) then 1 else
                if (DMIUp < DMIDown and ADX > 20) then -1 else 0;
#ShowTrendBars
AssignPriceColor(if !ShowTrendBars then Color.CURRENT else
                 if ColorBars > 0 then GlobalColor("Bullish") else
                 if ColorBars < 0 then GlobalColor("Bearish") else GlobalColor("Neutral"));
#// Trend System (First Time Frame)
def ema8 =  vwma(close, 8);
def ema13 = vwma(close, 13);
def ema21 = vwma(close, 21);
def ema34 = vwma(close, 34);
def emaup = ema8 > ema13  and ema13 > ema21 and ema21 > ema34;
def emadn = ema8 < ema13  and ema13 < ema21 and ema21 < ema34;
def Trend = ExpAverage(close, 13);
def TrendColor = if emadn and close <= Trend then -1 else
                 if emaup and close >= Trend then 1 else 0;
plot TrendLine = if !ShowTrend then na else Trend; # "Trend", color = TrendColor
TrendLine.SetLineWeight(2);
TrendLine.AssignValueColor(if TrendColor > 0 then GlobalColor("Bullish") else
                           if TrendColor < 0 then GlobalColor("Bearish") else GlobalColor("Neutral"));
def ATRLength;
switch (TrendMode) {
case "Tight" :
    ATRLength = 60;
case "Normal":
    ATRLength = 80;
case "Loose" :
    ATRLength = 100;
case "FOMC"  :
    ATRLength = 120;
case "Net"   :
    ATRLength = 140;
}
def emaTr8 = ExpAverage(tr , 8);
def ATR = (ATRLength / 100) * emaTr8;
def Up = close > (Trend + ATR);
def Down = close < (Trend - ATR);
def T = if Up then 1 else if Down then -1 else T[1];
def StopLineColor =  T == 1;
plot StopLine = if !ShowStopLine then na else
                 if T == 1  then (Trend - ATR) else
                 if T == -1 then (Trend + ATR) else T[1];     # "StopLine"
StopLine.AssignValueColor(if StopLineColor then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLine.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRA = (ATRLength - 20) / 100 * emaTr8;
def Up11 = close > (Trend + ATRA);
def Down11 = close < (Trend - ATRA);
def T11 = if Up11 then 1 else if Down11 then -1 else T11[1];
def StopLineColor1 = T11 == 1;

plot StopLine2 = if !ShowStopLine then na else
                if T11 == 1 then (Trend - ATRA) else
                if T11 == -1 then (Trend + ATRA) else T11[1]; # "StopLine2"
StopLine2.AssignValueColor(if StopLineColor1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLine2.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRNET = if net then (ATRLength - 40) / 100 * emaTr8 else na;
def UpNET = close > (Trend + ATRNET);
def DownNET = close < (Trend - ATRNET);
def TNET = if UpNET then 1 else if DownNET then -1 else TNET[1];
def StopLineColorNET = TNET == 1;

plot StopLineNET = if !ShowStopLine then na else
                   if TNET == 1 then (Trend - ATRNET) else
                   if TNET == -1 then (Trend + ATRNET) else TNET[1];    # "StopLineNET"
StopLineNET.AssignValueColor(if StopLineColorNET then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNET.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRNET1 = if net then (ATRLength - 60) / 100 * emaTr8 else na;
def UpNET1 = close > (Trend + ATRNET1);
def DownNET1 = close < (Trend - ATRNET1);
def TNET1 = if UpNET1 then 1 else if DownNET1 then -1 else TNET1[1];
def StopLineColorNET1 = TNET1 == 1;

plot StopLineNET1 = if !ShowStopLine then na else
                    if TNET1 == 1 then (Trend - ATRNET1) else
                    if TNET1 == -1 then (Trend + ATRNET1) else TNET1[1]; # "StopLineNET1"
StopLineNET1.AssignValueColor(if StopLineColorNET1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNET1.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRNET2 = if net then (ATRLength - 80) / 100 * emaTr8 else na;
def UpNET2 = close > (Trend + ATRNET2);
def DownNET2 = close < (Trend - ATRNET2);
def TNET2 = if UpNET2 then 1 else if DownNET2 then -1 else TNET2[1];
def StopLineColorNET2 = TNET2 == 1;

plot StopLineNET2 = if !ShowStopLine then na else
                    if TNET2 == 1 then (Trend - ATRNET2) else
                    if TNET2 == -1 then (Trend + ATRNET2) else TNET2[1]; # "StopLineNET2"
StopLineNET2.AssignValueColor(if StopLineColorNET2 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNET2.SetPaintingStrategy(PaintingStrategy.DASHES);

#// Higher Time Frame Aggregations

def current = GetAggregationPeriod();
def TimeFrameA =
      if current < AggregationPeriod.FIVE_MIN then AggregationPeriod.FIVE_MIN else
      if current < AggregationPeriod.THIRTY_MIN then AggregationPeriod.THIRTY_MIN else
      if current < AggregationPeriod.FOUR_HOURS then AggregationPeriod.FOUR_HOURS else
      if current < AggregationPeriod.DAY then AggregationPeriod.DAY else
      if current < AggregationPeriod.WEEK then AggregationPeriod.WEEK else
      if current < AggregationPeriod.MONTH then AggregationPeriod.MONTH else
      if current < AggregationPeriod.QUARTER then AggregationPeriod.QUARTER else current;
def TimeFrame;
switch (HTFMode) {
case "Auto" :
    TimeFrame = TimeFrameA;
case "Manual" :
    TimeFrame = ManualTimeframe;
}
def HighTf = high(Period = TimeFrame);
def LowTf  = low(Period = TimeFrame);
def CloseTf = close(Period = TimeFrame);
def volTf   = volume(Period = TimeFrame);
def trTf_   = TrueRange(HighTf, CloseTf, LowTf);
def trTf     = if IsNaN(trTf_) then (HighTf-LowTf) else trTf_;
def ematrTf8 = fixnan(ExpAverage(trTf, 8));
def ATRLength2 = ATRLength;

def ema82  = vwma(CloseTf, 8, volTf);
def ema132 = vwma(CloseTf, 13, volTf);
def ema212 = vwma(CloseTf, 21, volTf);
def ema342 = vwma(CloseTf, 34, volTf);
def emaup2 = ema82 > ema132  and ema132 > ema212 and ema212 > ema342;
def emadn2 = ema82 < ema132  and ema132 < ema212 and ema212 < ema342;

def Trend2 = ExpAverage(CloseTf, 13);
def TrendColor2 = if emadn2 and CloseTf <= Trend2 then -1 else
                  if emaup2 and CloseTf >= Trend2 then 1 else 0;

plot Trend2Line = if !ShowHtfTrendLine then na else Trend2;    # "Trend2"
Trend2Line.SetLineWeight(2);
Trend2Line.AssignValueColor(if TrendColor2 > 0 then GlobalColor("Bullish") else
                            if TrendColor2 < 0 then GlobalColor("Bearish") else GlobalColor("Neutral"));

def ATR2 = (ATRLength2 / 100) * ematrTf8;
def Up2 = CloseTf > (Trend2 + ATR2);
def Down2 = CloseTf < (Trend2 - ATR2);
def T2 = if Up2 then 1 else if Down2 then -1 else T2[1];
def StopLineColor2 = T2 == 1;

plot StopLineTf = if !ShowHtfStopLine then na else
                 if T2 == 1 then (Trend2 - ATR2) else
                 if T2 == -1 then (Trend2 + ATR2) else T2[1];    # "StopLine2"
StopLineTf.AssignValueColor(if StopLineColor2 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineTf.SetPaintingStrategy(PaintingStrategy.DASHES);
#ShowStop2

def ATR2A = (ATRLength2 - 20) / 100 * ematrTf8;
def Up2A = CloseTf > (Trend2 + ATR2A);
def Down2A = CloseTf < (Trend2 - ATR2A);
def T2A = if Up2A then 1 else if Down2A[1] then -1 else T2A[1];
def StopLineColor2A = T2A == 1;

plot StopLine2Tf = if !ShowHtfStopLine then na else
                   if T2A == 1 then (Trend2 - ATR2A) else
                   if T2A == -1 then (Trend2 + ATR2A) else T2A[1];    #  "StopLine2"
StopLine2Tf.AssignValueColor(if StopLineColor2A then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLine2Tf.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATR2ANET = if net then (ATRLength2 - 40) / 100 * ematrTf8 else na;
def Up2ANET = CloseTf > (Trend2 + ATR2ANET);
def Down2ANET = CloseTf < (Trend2 - ATR2ANET);
def T2ANET = if Up2ANET then 1 else if Down2ANET[1] then -1 else T2ANET[1];
def StopLineColor2ANET = T2ANET == 1;

plot StopLineNETtf = if !ShowHtfStopLine then na else
                     if T2ANET == 1 then (Trend2 - ATR2ANET) else
                     if T2ANET == -1 then (Trend2 + ATR2ANET) else T2ANET[1];    # StopLineColor2ANET
StopLineNETtf.AssignValueColor(if StopLineColor2ANET then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNETtf.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATR2ANET1 = if Net then (ATRLength2 - 60) /100 * ematrTf8 else na;
def Up2ANET1 = CloseTf > (Trend2 + ATR2ANET1);
def Down2ANET1 = CloseTf < (Trend2 - ATR2ANET1);
def T2ANET1 = if Up2ANET1 then 1 else if Down2ANET1[1] then -1 else T2ANET1[1];
def StopLineColor2ANET1 = T2ANET1 == 1;

plot StopLineNETtf1 = if !ShowHtfStopLine then na else
                      if T2ANET1 == 1 then (Trend2-ATR2ANET1) else
                      if T2ANET1 == -1 then (Trend2+ATR2ANET1) else T2ANET1[1];
StopLineNETtf1.AssignValueColor(if StopLineColor2ANET1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNETtf1.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATR2ANET2 = if Net then (ATRLength2 - 80) /100 * ematrTf8 else na;
def Up2ANET2 = CloseTf > (Trend2 + ATR2ANET2);
def Down2ANET2 = CloseTf < (Trend2 - ATR2ANET2);
def T2ANET2 = if Up2ANET2 then 1 else if Down2ANET2[1] then -1 else T2ANET2[1];
def StopLineColor2ANET2 = T2ANET2 == 1;

plot StopLineNETtf2 = if !ShowHtfStopLine then na else
                      if T2ANET2 == 1 then (Trend2-ATR2ANET2) else
                      if T2ANET2 == -1 then (Trend2+ATR2ANET2) else T2ANET2[1];
StopLineNETtf2.AssignValueColor(if StopLineColor2ANET1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNETtf2.SetPaintingStrategy(PaintingStrategy.DASHES);

#// Trend Clouds

def p1 = Trend;
def p2 = if T == 1 then (Trend-ATR) else if T == -1 then (Trend+ATR) else T[1];
AddCloud(if !ShowCloud then na else p1, p2, Color.DARK_GREEN, Color.DARK_RED);

def p3 = Trend2;
def p4 = if T2 == 1 then (Trend2-ATR2) else if T2 == -1 then (Trend2+ATR2) else T2[1];

AddCloud(if !ShowHTFCloud then na else p3 ,p4, Color.DARK_GREEN, Color.DARK_RED);

#--- END of CODE
Hi Samer,

Is there a way incorporate this to Scan. like Bullish and Bearish .. I tried though but unable to pick the value? can you please develop scan based on the Trend or Stopline parameters
 
Hi Samer,

Is there a way incorporate this to Scan. like Bullish and Bearish .. I tried though but unable to pick the value? can you please develop scan based on the Trend or Stopline parameters
try to use below
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at
#// https://www.tradingview.com/v/m0G2Xv7r/
#// Created by © L&L Capital
# indicator("LNL Trend System", shorttitle = "LNL Trend System", overlay=true)
# Converted by Sam4Cok@Samer800    - 08/2023
# -- Scan Script
#// Inputs
def na = Double.NaN;
def last = isNaN(close);
#vwma(source, length)
script VWMA {
    input src = close;
    input len = 15;
    input v_ = volume;
    def v = if IsNaN(v_) then 1 else v_;
    def srcV = src * v;
    def srcVol = if IsNaN(srcV) then src else srcV;
    def VWMA = Average(srcVol, len) / Average(v, len);
    plot result = VWMA;
}
DefineGlobalColor("Bullish", CreateColor(39, 194, 46));
DefineGlobalColor("Bearish", CreateColor(255, 82, 82));
DefineGlobalColor("Neutral", CreateColor(67, 70, 81));
#// Trend Bars (DMI Colored Candles)
#// Trend Bars (DMI Colored Candles)
def tr_ = TrueRange(high, close, low);
def tr  = if IsNaN(tr_) then 0 else tr_;
def nATR = WildersAverage(tr, 14);
def hi = ((high - high[1]) > (low[1] - low)) and ((high - high[1]) > 0);
def lo = ((low[1] - low) > (high - high[1])) and ((low[1] - low) > 0);
def BullishDMI = if hi then (high - high[1]) else 0;
def BearishDMI = if lo then (low[1] - low) else 0;
def DMIUp = 100 * WildersAverage(BullishDMI, 14) / nATR;
def DMIDown = 100 * WildersAverage(BearishDMI, 14) / nATR;
def ADXx = if (DMIUp + DMIDown) > 0 then 100 * AbsValue(DMIUp - DMIDown) / (DMIUp + DMIDown) else na;
def ADX = WildersAverage(ADXx, 14);
def ColorBars = if (DMIUp > DMIDown and ADX > 20) then 1 else
                if (DMIUp < DMIDown and ADX > 20) then -1 else 0;

#// Trend System (First Time Frame)
def ema8 =  vwma(close, 8);
def ema13 = vwma(close, 13);
def ema21 = vwma(close, 21);
def ema34 = vwma(close, 34);
def emaup = ema8 > ema13  and ema13 > ema21 and ema21 > ema34;
def emadn = ema8 < ema13  and ema13 < ema21 and ema21 < ema34;
def Trend = ExpAverage(close, 13);
def TrendColor = if emadn and close <= Trend then -1 else
                 if emaup and close >= Trend then 1 else 0;
def TrendLine = Trend; # "Trend", color = TrendColor
#TrendLine.SetLineWeight(2);
#TrendLine.AssignValueColor(if TrendColor > 0 then GlobalColor("Bullish") else
#                           if TrendColor < 0 then GlobalColor("Bearish") else GlobalColor("Neutral"));
def bullCond =  TrendColor > 0 and TrendColor[1]<=0 and ColorBars > 0;
def bearCond =  TrendColor < 0 and TrendColor[1]>=0 and ColorBars < 0;

plot bull = if bullCond within 3 bars then low else na;
#plot Bear = if bearCond within 3 bars then high else na;

#-- END Scan
 
try to use below
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at
#// https://www.tradingview.com/v/m0G2Xv7r/
#// Created by © L&L Capital
# indicator("LNL Trend System", shorttitle = "LNL Trend System", overlay=true)
# Converted by Sam4Cok@Samer800    - 08/2023
# -- Scan Script
#// Inputs
def na = Double.NaN;
def last = isNaN(close);
#vwma(source, length)
script VWMA {
    input src = close;
    input len = 15;
    input v_ = volume;
    def v = if IsNaN(v_) then 1 else v_;
    def srcV = src * v;
    def srcVol = if IsNaN(srcV) then src else srcV;
    def VWMA = Average(srcVol, len) / Average(v, len);
    plot result = VWMA;
}
DefineGlobalColor("Bullish", CreateColor(39, 194, 46));
DefineGlobalColor("Bearish", CreateColor(255, 82, 82));
DefineGlobalColor("Neutral", CreateColor(67, 70, 81));
#// Trend Bars (DMI Colored Candles)
#// Trend Bars (DMI Colored Candles)
def tr_ = TrueRange(high, close, low);
def tr  = if IsNaN(tr_) then 0 else tr_;
def nATR = WildersAverage(tr, 14);
def hi = ((high - high[1]) > (low[1] - low)) and ((high - high[1]) > 0);
def lo = ((low[1] - low) > (high - high[1])) and ((low[1] - low) > 0);
def BullishDMI = if hi then (high - high[1]) else 0;
def BearishDMI = if lo then (low[1] - low) else 0;
def DMIUp = 100 * WildersAverage(BullishDMI, 14) / nATR;
def DMIDown = 100 * WildersAverage(BearishDMI, 14) / nATR;
def ADXx = if (DMIUp + DMIDown) > 0 then 100 * AbsValue(DMIUp - DMIDown) / (DMIUp + DMIDown) else na;
def ADX = WildersAverage(ADXx, 14);
def ColorBars = if (DMIUp > DMIDown and ADX > 20) then 1 else
                if (DMIUp < DMIDown and ADX > 20) then -1 else 0;

#// Trend System (First Time Frame)
def ema8 =  vwma(close, 8);
def ema13 = vwma(close, 13);
def ema21 = vwma(close, 21);
def ema34 = vwma(close, 34);
def emaup = ema8 > ema13  and ema13 > ema21 and ema21 > ema34;
def emadn = ema8 < ema13  and ema13 < ema21 and ema21 < ema34;
def Trend = ExpAverage(close, 13);
def TrendColor = if emadn and close <= Trend then -1 else
                 if emaup and close >= Trend then 1 else 0;
def TrendLine = Trend; # "Trend", color = TrendColor
#TrendLine.SetLineWeight(2);
#TrendLine.AssignValueColor(if TrendColor > 0 then GlobalColor("Bullish") else
#                           if TrendColor < 0 then GlobalColor("Bearish") else GlobalColor("Neutral"));
def bullCond =  TrendColor > 0 and TrendColor[1]<=0 and ColorBars > 0;
def bearCond =  TrendColor < 0 and TrendColor[1]>=0 and ColorBars < 0;

plot bull = if bullCond within 3 bars then low else na;
#plot Bear = if bearCond within 3 bars then high else na;

#-- END Scan
Hi Samer,
Thank you so much for scan. Appreciate your help
 
BhNM8b0.png

Author Message:
LNL Trend System is an ATR based day trading system specifically designed for intra-day traders and scalpers. The System works on any chart time frame & can be applied to any market. The study consist of two components - the Trend Line and the Stop Line. Trend System is based on a special ATR calculation that is achieved by combining the previous values of the 13 EMA in relation to the ATR which creates a line of deviations that visually look similar to the basic moving average but actually produce very different results ESPECIALLY in sideways market.
More Details: https://www.tradingview.com/v/m0G2Xv7r/

CODE:
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at
#// https://www.tradingview.com/v/m0G2Xv7r/
#// Created by © L&L Capital
# indicator("LNL Trend System", shorttitle = "LNL Trend System", overlay=true)
# Converted by Sam4Cok@Samer800    - 08/2023
#// Inputs

input TrendMode     = {"Tight", default "Normal", "Loose", "FOMC", "Net"};    # "Trend Mode"
input HtfMode       = {default "Auto", "Manual"};  # "HTF Mode"
input ManualTimeframe = AggregationPeriod.HOUR;    # "HTF Aggregation"
input ShowTrendBars = yes;        # "Show Trend Bars"
input ShowTrend     = yes;        # "Show Trend Line"
input ShowStopLine  = yes;        # "Show Stop Line"
input ShowHtfTrendLine = no;      # "Show HTF Trend Line"
input ShowHtfStopLine = no;       # "Show HTF Stop Line"
input ShowCloud = yes;            # "Show Cloud"
input ShowHtfCloud = no;          # "Show HTF Cloud"

def na = Double.NaN;
def last = isNaN(close);
def net = TrendMode == TrendMode."Net";
#fixnan(data)
script fixnan {
 input src = close;
     def data2;
     def bar = barnumber();
     if bar == 1 then {data2 = 0;} else
     if IsNaN(src) then {data2 = data2[1];} else
      {data2 = src;}
plot valid = data2;
}

#vwma(source, length)
script VWMA {
    input src = close;
    input len = 15;
    input v_ = volume;
    def v = if IsNaN(v_) then 1 else v_;
    def srcV = src * v;
    def srcVol = if IsNaN(srcV) then src else srcV;
    def VWMA = Average(srcVol, len) / Average(v, len);
    plot result = VWMA;
}
DefineGlobalColor("Bullish", CreateColor(39, 194, 46));
DefineGlobalColor("Bearish", CreateColor(255, 82, 82));
DefineGlobalColor("Neutral", CreateColor(67, 70, 81));
#// Trend Bars (DMI Colored Candles)
def tr_ = TrueRange(high, close, low);
def tr  = if IsNaN(tr_) then 0 else tr_;
def nATR = WildersAverage(tr, 14);
def hi = ((high - high[1]) > (low[1] - low)) and ((high - high[1]) > 0);
def lo = ((low[1] - low) > (high - high[1])) and ((low[1] - low) > 0);
def BullishDMI = if hi then (high - high[1]) else 0;
def BearishDMI = if lo then (low[1] - low) else 0;
def DMIUp = 100 * WildersAverage(BullishDMI, 14) / nATR;
def DMIDown = 100 * WildersAverage(BearishDMI, 14) / nATR;
def ADXx = if (DMIUp + DMIDown) > 0 then 100 * AbsValue(DMIUp - DMIDown) / (DMIUp + DMIDown) else na;
def ADX = WildersAverage(ADXx, 14);
def ColorBars = if (DMIUp > DMIDown and ADX > 20) then 1 else
                if (DMIUp < DMIDown and ADX > 20) then -1 else 0;
#ShowTrendBars
AssignPriceColor(if !ShowTrendBars then Color.CURRENT else
                 if ColorBars > 0 then GlobalColor("Bullish") else
                 if ColorBars < 0 then GlobalColor("Bearish") else GlobalColor("Neutral"));
#// Trend System (First Time Frame)
def ema8 =  vwma(close, 8);
def ema13 = vwma(close, 13);
def ema21 = vwma(close, 21);
def ema34 = vwma(close, 34);
def emaup = ema8 > ema13  and ema13 > ema21 and ema21 > ema34;
def emadn = ema8 < ema13  and ema13 < ema21 and ema21 < ema34;
def Trend = ExpAverage(close, 13);
def TrendColor = if emadn and close <= Trend then -1 else
                 if emaup and close >= Trend then 1 else 0;
plot TrendLine = if !ShowTrend then na else Trend; # "Trend", color = TrendColor
TrendLine.SetLineWeight(2);
TrendLine.AssignValueColor(if TrendColor > 0 then GlobalColor("Bullish") else
                           if TrendColor < 0 then GlobalColor("Bearish") else GlobalColor("Neutral"));
def ATRLength;
switch (TrendMode) {
case "Tight" :
    ATRLength = 60;
case "Normal":
    ATRLength = 80;
case "Loose" :
    ATRLength = 100;
case "FOMC"  :
    ATRLength = 120;
case "Net"   :
    ATRLength = 140;
}
def emaTr8 = ExpAverage(tr , 8);
def ATR = (ATRLength / 100) * emaTr8;
def Up = close > (Trend + ATR);
def Down = close < (Trend - ATR);
def T = if Up then 1 else if Down then -1 else T[1];
def StopLineColor =  T == 1;
plot StopLine = if !ShowStopLine then na else
                 if T == 1  then (Trend - ATR) else
                 if T == -1 then (Trend + ATR) else T[1];     # "StopLine"
StopLine.AssignValueColor(if StopLineColor then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLine.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRA = (ATRLength - 20) / 100 * emaTr8;
def Up11 = close > (Trend + ATRA);
def Down11 = close < (Trend - ATRA);
def T11 = if Up11 then 1 else if Down11 then -1 else T11[1];
def StopLineColor1 = T11 == 1;

plot StopLine2 = if !ShowStopLine then na else
                if T11 == 1 then (Trend - ATRA) else
                if T11 == -1 then (Trend + ATRA) else T11[1]; # "StopLine2"
StopLine2.AssignValueColor(if StopLineColor1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLine2.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRNET = if net then (ATRLength - 40) / 100 * emaTr8 else na;
def UpNET = close > (Trend + ATRNET);
def DownNET = close < (Trend - ATRNET);
def TNET = if UpNET then 1 else if DownNET then -1 else TNET[1];
def StopLineColorNET = TNET == 1;

plot StopLineNET = if !ShowStopLine then na else
                   if TNET == 1 then (Trend - ATRNET) else
                   if TNET == -1 then (Trend + ATRNET) else TNET[1];    # "StopLineNET"
StopLineNET.AssignValueColor(if StopLineColorNET then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNET.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRNET1 = if net then (ATRLength - 60) / 100 * emaTr8 else na;
def UpNET1 = close > (Trend + ATRNET1);
def DownNET1 = close < (Trend - ATRNET1);
def TNET1 = if UpNET1 then 1 else if DownNET1 then -1 else TNET1[1];
def StopLineColorNET1 = TNET1 == 1;

plot StopLineNET1 = if !ShowStopLine then na else
                    if TNET1 == 1 then (Trend - ATRNET1) else
                    if TNET1 == -1 then (Trend + ATRNET1) else TNET1[1]; # "StopLineNET1"
StopLineNET1.AssignValueColor(if StopLineColorNET1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNET1.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRNET2 = if net then (ATRLength - 80) / 100 * emaTr8 else na;
def UpNET2 = close > (Trend + ATRNET2);
def DownNET2 = close < (Trend - ATRNET2);
def TNET2 = if UpNET2 then 1 else if DownNET2 then -1 else TNET2[1];
def StopLineColorNET2 = TNET2 == 1;

plot StopLineNET2 = if !ShowStopLine then na else
                    if TNET2 == 1 then (Trend - ATRNET2) else
                    if TNET2 == -1 then (Trend + ATRNET2) else TNET2[1]; # "StopLineNET2"
StopLineNET2.AssignValueColor(if StopLineColorNET2 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNET2.SetPaintingStrategy(PaintingStrategy.DASHES);

#// Higher Time Frame Aggregations

def current = GetAggregationPeriod();
def TimeFrameA =
      if current < AggregationPeriod.FIVE_MIN then AggregationPeriod.FIVE_MIN else
      if current < AggregationPeriod.THIRTY_MIN then AggregationPeriod.THIRTY_MIN else
      if current < AggregationPeriod.FOUR_HOURS then AggregationPeriod.FOUR_HOURS else
      if current < AggregationPeriod.DAY then AggregationPeriod.DAY else
      if current < AggregationPeriod.WEEK then AggregationPeriod.WEEK else
      if current < AggregationPeriod.MONTH then AggregationPeriod.MONTH else
      if current < AggregationPeriod.QUARTER then AggregationPeriod.QUARTER else current;
def TimeFrame;
switch (HTFMode) {
case "Auto" :
    TimeFrame = TimeFrameA;
case "Manual" :
    TimeFrame = ManualTimeframe;
}
def HighTf = high(Period = TimeFrame);
def LowTf  = low(Period = TimeFrame);
def CloseTf = close(Period = TimeFrame);
def volTf   = volume(Period = TimeFrame);
def trTf_   = TrueRange(HighTf, CloseTf, LowTf);
def trTf     = if IsNaN(trTf_) then (HighTf-LowTf) else trTf_;
def ematrTf8 = fixnan(ExpAverage(trTf, 8));
def ATRLength2 = ATRLength;

def ema82  = vwma(CloseTf, 8, volTf);
def ema132 = vwma(CloseTf, 13, volTf);
def ema212 = vwma(CloseTf, 21, volTf);
def ema342 = vwma(CloseTf, 34, volTf);
def emaup2 = ema82 > ema132  and ema132 > ema212 and ema212 > ema342;
def emadn2 = ema82 < ema132  and ema132 < ema212 and ema212 < ema342;

def Trend2 = ExpAverage(CloseTf, 13);
def TrendColor2 = if emadn2 and CloseTf <= Trend2 then -1 else
                  if emaup2 and CloseTf >= Trend2 then 1 else 0;

plot Trend2Line = if !ShowHtfTrendLine then na else Trend2;    # "Trend2"
Trend2Line.SetLineWeight(2);
Trend2Line.AssignValueColor(if TrendColor2 > 0 then GlobalColor("Bullish") else
                            if TrendColor2 < 0 then GlobalColor("Bearish") else GlobalColor("Neutral"));

def ATR2 = (ATRLength2 / 100) * ematrTf8;
def Up2 = CloseTf > (Trend2 + ATR2);
def Down2 = CloseTf < (Trend2 - ATR2);
def T2 = if Up2 then 1 else if Down2 then -1 else T2[1];
def StopLineColor2 = T2 == 1;

plot StopLineTf = if !ShowHtfStopLine then na else
                 if T2 == 1 then (Trend2 - ATR2) else
                 if T2 == -1 then (Trend2 + ATR2) else T2[1];    # "StopLine2"
StopLineTf.AssignValueColor(if StopLineColor2 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineTf.SetPaintingStrategy(PaintingStrategy.DASHES);
#ShowStop2

def ATR2A = (ATRLength2 - 20) / 100 * ematrTf8;
def Up2A = CloseTf > (Trend2 + ATR2A);
def Down2A = CloseTf < (Trend2 - ATR2A);
def T2A = if Up2A then 1 else if Down2A[1] then -1 else T2A[1];
def StopLineColor2A = T2A == 1;

plot StopLine2Tf = if !ShowHtfStopLine then na else
                   if T2A == 1 then (Trend2 - ATR2A) else
                   if T2A == -1 then (Trend2 + ATR2A) else T2A[1];    #  "StopLine2"
StopLine2Tf.AssignValueColor(if StopLineColor2A then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLine2Tf.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATR2ANET = if net then (ATRLength2 - 40) / 100 * ematrTf8 else na;
def Up2ANET = CloseTf > (Trend2 + ATR2ANET);
def Down2ANET = CloseTf < (Trend2 - ATR2ANET);
def T2ANET = if Up2ANET then 1 else if Down2ANET[1] then -1 else T2ANET[1];
def StopLineColor2ANET = T2ANET == 1;

plot StopLineNETtf = if !ShowHtfStopLine then na else
                     if T2ANET == 1 then (Trend2 - ATR2ANET) else
                     if T2ANET == -1 then (Trend2 + ATR2ANET) else T2ANET[1];    # StopLineColor2ANET
StopLineNETtf.AssignValueColor(if StopLineColor2ANET then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNETtf.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATR2ANET1 = if Net then (ATRLength2 - 60) /100 * ematrTf8 else na;
def Up2ANET1 = CloseTf > (Trend2 + ATR2ANET1);
def Down2ANET1 = CloseTf < (Trend2 - ATR2ANET1);
def T2ANET1 = if Up2ANET1 then 1 else if Down2ANET1[1] then -1 else T2ANET1[1];
def StopLineColor2ANET1 = T2ANET1 == 1;

plot StopLineNETtf1 = if !ShowHtfStopLine then na else
                      if T2ANET1 == 1 then (Trend2-ATR2ANET1) else
                      if T2ANET1 == -1 then (Trend2+ATR2ANET1) else T2ANET1[1];
StopLineNETtf1.AssignValueColor(if StopLineColor2ANET1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNETtf1.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATR2ANET2 = if Net then (ATRLength2 - 80) /100 * ematrTf8 else na;
def Up2ANET2 = CloseTf > (Trend2 + ATR2ANET2);
def Down2ANET2 = CloseTf < (Trend2 - ATR2ANET2);
def T2ANET2 = if Up2ANET2 then 1 else if Down2ANET2[1] then -1 else T2ANET2[1];
def StopLineColor2ANET2 = T2ANET2 == 1;

plot StopLineNETtf2 = if !ShowHtfStopLine then na else
                      if T2ANET2 == 1 then (Trend2-ATR2ANET2) else
                      if T2ANET2 == -1 then (Trend2+ATR2ANET2) else T2ANET2[1];
StopLineNETtf2.AssignValueColor(if StopLineColor2ANET1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNETtf2.SetPaintingStrategy(PaintingStrategy.DASHES);

#// Trend Clouds

def p1 = Trend;
def p2 = if T == 1 then (Trend-ATR) else if T == -1 then (Trend+ATR) else T[1];
AddCloud(if !ShowCloud then na else p1, p2, Color.DARK_GREEN, Color.DARK_RED);

def p3 = Trend2;
def p4 = if T2 == 1 then (Trend2-ATR2) else if T2 == -1 then (Trend2+ATR2) else T2[1];

AddCloud(if !ShowHTFCloud then na else p3 ,p4, Color.DARK_GREEN, Color.DARK_RED);

#--- END of CODE
It says designed for intraday traders and scalpers. How to I set this up on a daily chart if I am a several day trader? Many thanks
 
It says designed for intraday traders and scalpers. How to I set this up on a daily chart if I am a several day trader? Many thanks
-Just a heads up the term for several day trading is swing trading/trader
-It looks like you just select whatever time frame you want to use on thinkorswim and it'll adjust automatically
 
try to use below
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at
#// https://www.tradingview.com/v/m0G2Xv7r/
#// Created by © L&L Capital
# indicator("LNL Trend System", shorttitle = "LNL Trend System", overlay=true)
# Converted by Sam4Cok@Samer800    - 08/2023
# -- Scan Script
#// Inputs
def na = Double.NaN;
def last = isNaN(close);
#vwma(source, length)
script VWMA {
    input src = close;
    input len = 15;
    input v_ = volume;
    def v = if IsNaN(v_) then 1 else v_;
    def srcV = src * v;
    def srcVol = if IsNaN(srcV) then src else srcV;
    def VWMA = Average(srcVol, len) / Average(v, len);
    plot result = VWMA;
}
DefineGlobalColor("Bullish", CreateColor(39, 194, 46));
DefineGlobalColor("Bearish", CreateColor(255, 82, 82));
DefineGlobalColor("Neutral", CreateColor(67, 70, 81));
#// Trend Bars (DMI Colored Candles)
#// Trend Bars (DMI Colored Candles)
def tr_ = TrueRange(high, close, low);
def tr  = if IsNaN(tr_) then 0 else tr_;
def nATR = WildersAverage(tr, 14);
def hi = ((high - high[1]) > (low[1] - low)) and ((high - high[1]) > 0);
def lo = ((low[1] - low) > (high - high[1])) and ((low[1] - low) > 0);
def BullishDMI = if hi then (high - high[1]) else 0;
def BearishDMI = if lo then (low[1] - low) else 0;
def DMIUp = 100 * WildersAverage(BullishDMI, 14) / nATR;
def DMIDown = 100 * WildersAverage(BearishDMI, 14) / nATR;
def ADXx = if (DMIUp + DMIDown) > 0 then 100 * AbsValue(DMIUp - DMIDown) / (DMIUp + DMIDown) else na;
def ADX = WildersAverage(ADXx, 14);
def ColorBars = if (DMIUp > DMIDown and ADX > 20) then 1 else
                if (DMIUp < DMIDown and ADX > 20) then -1 else 0;

#// Trend System (First Time Frame)
def ema8 =  vwma(close, 8);
def ema13 = vwma(close, 13);
def ema21 = vwma(close, 21);
def ema34 = vwma(close, 34);
def emaup = ema8 > ema13  and ema13 > ema21 and ema21 > ema34;
def emadn = ema8 < ema13  and ema13 < ema21 and ema21 < ema34;
def Trend = ExpAverage(close, 13);
def TrendColor = if emadn and close <= Trend then -1 else
                 if emaup and close >= Trend then 1 else 0;
def TrendLine = Trend; # "Trend", color = TrendColor
#TrendLine.SetLineWeight(2);
#TrendLine.AssignValueColor(if TrendColor > 0 then GlobalColor("Bullish") else
#                           if TrendColor < 0 then GlobalColor("Bearish") else GlobalColor("Neutral"));
def bullCond =  TrendColor > 0 and TrendColor[1]<=0 and ColorBars > 0;
def bearCond =  TrendColor < 0 and TrendColor[1]>=0 and ColorBars < 0;

plot bull = if bullCond within 3 bars then low else na;
#plot Bear = if bearCond within 3 bars then high else na;

#-- END Scan
I am going to set up this scan. In the Scan set up, do I just click "false" under the bull "plot" selection to get a bear condition. Or do I have to change the script? Thanks again Samer for all your expertise.
 
I am going to set up this scan. In the Scan set up, do I just click "false" under the bull "plot" selection to get a bear condition. Or do I have to change the script? Thanks again Samer for all your expertise.

For bear scan
change this:
#plot Bear = if bearCond within 3 bars then high else na;
to this:
plot Bear = if bearCond within 3 bars then high else na;
 
Hey Samer, thank you for sharing this! I noticed on $SPX the dash marks above and below each candle don't show up on any time frame. However, it does on $SPY. Not sure if this is fixable but thought I would throw it out there. It seems to work on every other ticker I've looked at it on though.
 
Hey Samer, thank you for sharing this! I noticed on $SPX the dash marks above and below each candle don't show up on any time frame. However, it does on $SPY. Not sure if this is fixable but thought I would throw it out there. It seems to work on every other ticker I've looked at it on though.

You are correct.
Given that there is no volume associated with $SPX, no indicator that uses volume in its calculations will work correctly on $SPX
 
BhNM8b0.png

Author Message:
LNL Trend System is an ATR based day trading system specifically designed for intra-day traders and scalpers. The System works on any chart time frame & can be applied to any market. The study consist of two components - the Trend Line and the Stop Line. Trend System is based on a special ATR calculation that is achieved by combining the previous values of the 13 EMA in relation to the ATR which creates a line of deviations that visually look similar to the basic moving average but actually produce very different results ESPECIALLY in sideways market.
More Details: https://www.tradingview.com/v/m0G2Xv7r/

CODE:
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at
#// https://www.tradingview.com/v/m0G2Xv7r/
#// Created by © L&L Capital
# indicator("LNL Trend System", shorttitle = "LNL Trend System", overlay=true)
# Converted by Sam4Cok@Samer800    - 08/2023
#// Inputs

input TrendMode     = {"Tight", default "Normal", "Loose", "FOMC", "Net"};    # "Trend Mode"
input HtfMode       = {default "Auto", "Manual"};  # "HTF Mode"
input ManualTimeframe = AggregationPeriod.HOUR;    # "HTF Aggregation"
input ShowTrendBars = yes;        # "Show Trend Bars"
input ShowTrend     = yes;        # "Show Trend Line"
input ShowStopLine  = yes;        # "Show Stop Line"
input ShowHtfTrendLine = no;      # "Show HTF Trend Line"
input ShowHtfStopLine = no;       # "Show HTF Stop Line"
input ShowCloud = yes;            # "Show Cloud"
input ShowHtfCloud = no;          # "Show HTF Cloud"

def na = Double.NaN;
def last = isNaN(close);
def net = TrendMode == TrendMode."Net";
#fixnan(data)
script fixnan {
 input src = close;
     def data2;
     def bar = barnumber();
     if bar == 1 then {data2 = 0;} else
     if IsNaN(src) then {data2 = data2[1];} else
      {data2 = src;}
plot valid = data2;
}

#vwma(source, length)
script VWMA {
    input src = close;
    input len = 15;
    input v_ = volume;
    def v = if IsNaN(v_) then 1 else v_;
    def srcV = src * v;
    def srcVol = if IsNaN(srcV) then src else srcV;
    def VWMA = Average(srcVol, len) / Average(v, len);
    plot result = VWMA;
}
DefineGlobalColor("Bullish", CreateColor(39, 194, 46));
DefineGlobalColor("Bearish", CreateColor(255, 82, 82));
DefineGlobalColor("Neutral", CreateColor(67, 70, 81));
#// Trend Bars (DMI Colored Candles)
def tr_ = TrueRange(high, close, low);
def tr  = if IsNaN(tr_) then 0 else tr_;
def nATR = WildersAverage(tr, 14);
def hi = ((high - high[1]) > (low[1] - low)) and ((high - high[1]) > 0);
def lo = ((low[1] - low) > (high - high[1])) and ((low[1] - low) > 0);
def BullishDMI = if hi then (high - high[1]) else 0;
def BearishDMI = if lo then (low[1] - low) else 0;
def DMIUp = 100 * WildersAverage(BullishDMI, 14) / nATR;
def DMIDown = 100 * WildersAverage(BearishDMI, 14) / nATR;
def ADXx = if (DMIUp + DMIDown) > 0 then 100 * AbsValue(DMIUp - DMIDown) / (DMIUp + DMIDown) else na;
def ADX = WildersAverage(ADXx, 14);
def ColorBars = if (DMIUp > DMIDown and ADX > 20) then 1 else
                if (DMIUp < DMIDown and ADX > 20) then -1 else 0;
#ShowTrendBars
AssignPriceColor(if !ShowTrendBars then Color.CURRENT else
                 if ColorBars > 0 then GlobalColor("Bullish") else
                 if ColorBars < 0 then GlobalColor("Bearish") else GlobalColor("Neutral"));
#// Trend System (First Time Frame)
def ema8 =  vwma(close, 8);
def ema13 = vwma(close, 13);
def ema21 = vwma(close, 21);
def ema34 = vwma(close, 34);
def emaup = ema8 > ema13  and ema13 > ema21 and ema21 > ema34;
def emadn = ema8 < ema13  and ema13 < ema21 and ema21 < ema34;
def Trend = ExpAverage(close, 13);
def TrendColor = if emadn and close <= Trend then -1 else
                 if emaup and close >= Trend then 1 else 0;
plot TrendLine = if !ShowTrend then na else Trend; # "Trend", color = TrendColor
TrendLine.SetLineWeight(2);
TrendLine.AssignValueColor(if TrendColor > 0 then GlobalColor("Bullish") else
                           if TrendColor < 0 then GlobalColor("Bearish") else GlobalColor("Neutral"));
def ATRLength;
switch (TrendMode) {
case "Tight" :
    ATRLength = 60;
case "Normal":
    ATRLength = 80;
case "Loose" :
    ATRLength = 100;
case "FOMC"  :
    ATRLength = 120;
case "Net"   :
    ATRLength = 140;
}
def emaTr8 = ExpAverage(tr , 8);
def ATR = (ATRLength / 100) * emaTr8;
def Up = close > (Trend + ATR);
def Down = close < (Trend - ATR);
def T = if Up then 1 else if Down then -1 else T[1];
def StopLineColor =  T == 1;
plot StopLine = if !ShowStopLine then na else
                 if T == 1  then (Trend - ATR) else
                 if T == -1 then (Trend + ATR) else T[1];     # "StopLine"
StopLine.AssignValueColor(if StopLineColor then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLine.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRA = (ATRLength - 20) / 100 * emaTr8;
def Up11 = close > (Trend + ATRA);
def Down11 = close < (Trend - ATRA);
def T11 = if Up11 then 1 else if Down11 then -1 else T11[1];
def StopLineColor1 = T11 == 1;

plot StopLine2 = if !ShowStopLine then na else
                if T11 == 1 then (Trend - ATRA) else
                if T11 == -1 then (Trend + ATRA) else T11[1]; # "StopLine2"
StopLine2.AssignValueColor(if StopLineColor1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLine2.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRNET = if net then (ATRLength - 40) / 100 * emaTr8 else na;
def UpNET = close > (Trend + ATRNET);
def DownNET = close < (Trend - ATRNET);
def TNET = if UpNET then 1 else if DownNET then -1 else TNET[1];
def StopLineColorNET = TNET == 1;

plot StopLineNET = if !ShowStopLine then na else
                   if TNET == 1 then (Trend - ATRNET) else
                   if TNET == -1 then (Trend + ATRNET) else TNET[1];    # "StopLineNET"
StopLineNET.AssignValueColor(if StopLineColorNET then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNET.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRNET1 = if net then (ATRLength - 60) / 100 * emaTr8 else na;
def UpNET1 = close > (Trend + ATRNET1);
def DownNET1 = close < (Trend - ATRNET1);
def TNET1 = if UpNET1 then 1 else if DownNET1 then -1 else TNET1[1];
def StopLineColorNET1 = TNET1 == 1;

plot StopLineNET1 = if !ShowStopLine then na else
                    if TNET1 == 1 then (Trend - ATRNET1) else
                    if TNET1 == -1 then (Trend + ATRNET1) else TNET1[1]; # "StopLineNET1"
StopLineNET1.AssignValueColor(if StopLineColorNET1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNET1.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATRNET2 = if net then (ATRLength - 80) / 100 * emaTr8 else na;
def UpNET2 = close > (Trend + ATRNET2);
def DownNET2 = close < (Trend - ATRNET2);
def TNET2 = if UpNET2 then 1 else if DownNET2 then -1 else TNET2[1];
def StopLineColorNET2 = TNET2 == 1;

plot StopLineNET2 = if !ShowStopLine then na else
                    if TNET2 == 1 then (Trend - ATRNET2) else
                    if TNET2 == -1 then (Trend + ATRNET2) else TNET2[1]; # "StopLineNET2"
StopLineNET2.AssignValueColor(if StopLineColorNET2 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNET2.SetPaintingStrategy(PaintingStrategy.DASHES);

#// Higher Time Frame Aggregations

def current = GetAggregationPeriod();
def TimeFrameA =
      if current < AggregationPeriod.FIVE_MIN then AggregationPeriod.FIVE_MIN else
      if current < AggregationPeriod.THIRTY_MIN then AggregationPeriod.THIRTY_MIN else
      if current < AggregationPeriod.FOUR_HOURS then AggregationPeriod.FOUR_HOURS else
      if current < AggregationPeriod.DAY then AggregationPeriod.DAY else
      if current < AggregationPeriod.WEEK then AggregationPeriod.WEEK else
      if current < AggregationPeriod.MONTH then AggregationPeriod.MONTH else
      if current < AggregationPeriod.QUARTER then AggregationPeriod.QUARTER else current;
def TimeFrame;
switch (HTFMode) {
case "Auto" :
    TimeFrame = TimeFrameA;
case "Manual" :
    TimeFrame = ManualTimeframe;
}
def HighTf = high(Period = TimeFrame);
def LowTf  = low(Period = TimeFrame);
def CloseTf = close(Period = TimeFrame);
def volTf   = volume(Period = TimeFrame);
def trTf_   = TrueRange(HighTf, CloseTf, LowTf);
def trTf     = if IsNaN(trTf_) then (HighTf-LowTf) else trTf_;
def ematrTf8 = fixnan(ExpAverage(trTf, 8));
def ATRLength2 = ATRLength;

def ema82  = vwma(CloseTf, 8, volTf);
def ema132 = vwma(CloseTf, 13, volTf);
def ema212 = vwma(CloseTf, 21, volTf);
def ema342 = vwma(CloseTf, 34, volTf);
def emaup2 = ema82 > ema132  and ema132 > ema212 and ema212 > ema342;
def emadn2 = ema82 < ema132  and ema132 < ema212 and ema212 < ema342;

def Trend2 = ExpAverage(CloseTf, 13);
def TrendColor2 = if emadn2 and CloseTf <= Trend2 then -1 else
                  if emaup2 and CloseTf >= Trend2 then 1 else 0;

plot Trend2Line = if !ShowHtfTrendLine then na else Trend2;    # "Trend2"
Trend2Line.SetLineWeight(2);
Trend2Line.AssignValueColor(if TrendColor2 > 0 then GlobalColor("Bullish") else
                            if TrendColor2 < 0 then GlobalColor("Bearish") else GlobalColor("Neutral"));

def ATR2 = (ATRLength2 / 100) * ematrTf8;
def Up2 = CloseTf > (Trend2 + ATR2);
def Down2 = CloseTf < (Trend2 - ATR2);
def T2 = if Up2 then 1 else if Down2 then -1 else T2[1];
def StopLineColor2 = T2 == 1;

plot StopLineTf = if !ShowHtfStopLine then na else
                 if T2 == 1 then (Trend2 - ATR2) else
                 if T2 == -1 then (Trend2 + ATR2) else T2[1];    # "StopLine2"
StopLineTf.AssignValueColor(if StopLineColor2 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineTf.SetPaintingStrategy(PaintingStrategy.DASHES);
#ShowStop2

def ATR2A = (ATRLength2 - 20) / 100 * ematrTf8;
def Up2A = CloseTf > (Trend2 + ATR2A);
def Down2A = CloseTf < (Trend2 - ATR2A);
def T2A = if Up2A then 1 else if Down2A[1] then -1 else T2A[1];
def StopLineColor2A = T2A == 1;

plot StopLine2Tf = if !ShowHtfStopLine then na else
                   if T2A == 1 then (Trend2 - ATR2A) else
                   if T2A == -1 then (Trend2 + ATR2A) else T2A[1];    #  "StopLine2"
StopLine2Tf.AssignValueColor(if StopLineColor2A then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLine2Tf.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATR2ANET = if net then (ATRLength2 - 40) / 100 * ematrTf8 else na;
def Up2ANET = CloseTf > (Trend2 + ATR2ANET);
def Down2ANET = CloseTf < (Trend2 - ATR2ANET);
def T2ANET = if Up2ANET then 1 else if Down2ANET[1] then -1 else T2ANET[1];
def StopLineColor2ANET = T2ANET == 1;

plot StopLineNETtf = if !ShowHtfStopLine then na else
                     if T2ANET == 1 then (Trend2 - ATR2ANET) else
                     if T2ANET == -1 then (Trend2 + ATR2ANET) else T2ANET[1];    # StopLineColor2ANET
StopLineNETtf.AssignValueColor(if StopLineColor2ANET then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNETtf.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATR2ANET1 = if Net then (ATRLength2 - 60) /100 * ematrTf8 else na;
def Up2ANET1 = CloseTf > (Trend2 + ATR2ANET1);
def Down2ANET1 = CloseTf < (Trend2 - ATR2ANET1);
def T2ANET1 = if Up2ANET1 then 1 else if Down2ANET1[1] then -1 else T2ANET1[1];
def StopLineColor2ANET1 = T2ANET1 == 1;

plot StopLineNETtf1 = if !ShowHtfStopLine then na else
                      if T2ANET1 == 1 then (Trend2-ATR2ANET1) else
                      if T2ANET1 == -1 then (Trend2+ATR2ANET1) else T2ANET1[1];
StopLineNETtf1.AssignValueColor(if StopLineColor2ANET1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNETtf1.SetPaintingStrategy(PaintingStrategy.DASHES);

def ATR2ANET2 = if Net then (ATRLength2 - 80) /100 * ematrTf8 else na;
def Up2ANET2 = CloseTf > (Trend2 + ATR2ANET2);
def Down2ANET2 = CloseTf < (Trend2 - ATR2ANET2);
def T2ANET2 = if Up2ANET2 then 1 else if Down2ANET2[1] then -1 else T2ANET2[1];
def StopLineColor2ANET2 = T2ANET2 == 1;

plot StopLineNETtf2 = if !ShowHtfStopLine then na else
                      if T2ANET2 == 1 then (Trend2-ATR2ANET2) else
                      if T2ANET2 == -1 then (Trend2+ATR2ANET2) else T2ANET2[1];
StopLineNETtf2.AssignValueColor(if StopLineColor2ANET1 then GlobalColor("Bullish") else GlobalColor("Bearish"));
StopLineNETtf2.SetPaintingStrategy(PaintingStrategy.DASHES);

#// Trend Clouds

def p1 = Trend;
def p2 = if T == 1 then (Trend-ATR) else if T == -1 then (Trend+ATR) else T[1];
AddCloud(if !ShowCloud then na else p1, p2, Color.DARK_GREEN, Color.DARK_RED);

def p3 = Trend2;
def p4 = if T2 == 1 then (Trend2-ATR2) else if T2 == -1 then (Trend2+ATR2) else T2[1];

AddCloud(if !ShowHTFCloud then na else p3 ,p4, Color.DARK_GREEN, Color.DARK_RED);

#--- END of CODE
Hi Samer, I have tried this indicator recently and it worked well. How to set up sound alert and backtesting, such as when price close above / below StopLine and StopLine2? Thanks.
 
Hi Samer, I have tried this indicator recently and it worked well. How to set up sound alert and backtesting, such as when price close above / below StopLine and StopLine2? Thanks.

Append the following to the end of your script:

Alerts For Price Crosses StopLines

# Alerts
Alert(close crosses above StopLineNETtf1, "Price crossing above StopLine1", Alert.Bar, Sound.Chimes);
Alert(close crosses below StopLineNETtf1, "Price crossing below StopLine1", Alert.Bar, Sound.Bell);
Alert(close crosses above StopLineNETtf2, "Price crossing above StopLine2", Alert.Bar, Sound.Chimes);
Alert(close crosses below StopLineNETtf2, "Price crossing below StopLine2", Alert.Bar, Sound.Bell);
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
337 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