ADX Di+ Di- For ThinkOrSwim

Request any expert to convert the following ADX which seems to have unique calculations; just the calculation piece of the TV code below. I will try to figure out the color changes and alerts. This TV ADX indicator give different info than the ToS one and it appears to me that the calculations may be different.

Thank you in advance.

https://my.tradingview.com/script/RNcqYq6w-ADX-Di-Di-Gu5/

Code:
// This source code is subject to these terms:
// Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
// [URL]https://creativecommons.org/licenses/by-nc-sa/4.0/[/URL]
// You are free to:
// Share, copy and redistribute this script
// Adapt, transform and build on this script.
// Under the following terms:
// NonCommercial: You may not use the material for commercial purposes.
// Attribution: You must give appropriate credit
// [URL]https://www.safecreative.org/work/2302153511401-adx-di-di-gu5-[/URL]
// © gu5tavo71 (Gustavo Cardelle)
//@version=5
indicator(title = 'ADX Di+ Di- [Gu5]', shorttitle = 'ADX', overlay = false,
  format = format.price, precision = 2, timeframe = '')
// Indicator to helps determine the strength of a trend
// Average Directional movement indeX (ADX) Developed by J. Welles
// v1.6.23, 2023.02.15
// Project #694
// This script reuses open source code from another authors:
// @PineCoders, Built-in Library, and Community Scripts
// Disclaimer: I am not a financial advisor.
//             For purpose educate only. Use at your own risk.
// ——————————— <constant_declarations> {
//<my colors>
C_GREEN      = #006400  //Green
C_GREENLIGHT = #388e3c  //Green Light
C_RED        = #8B0000  //Red
C_REDLIGHT   = #b71c1c  //Red Light
//}
// ——————————— <inputs> {
//           |                  |           |                               |         |
i_sigLen     = input.int        (14,        'ADX Smoothing'                 )
i_diLen      = input.int        (14,        'DI Length'                     )
i_hlRange    = input.int        (20,        'Level Range'                   )
i_hlTrend    = input.int        (35,        'Level Trend'                   )
i_alertOn    = input.bool       (true,      "■ Alert On/Off"                )
i_barColOn   = input.bool       (true,      "■ Bar Color On/Off"            )
//}
// ——————————— <function_declarations> {
f_dirMov(_len) =>
    _up        =  ta.change(high)
    _down      = -ta.change(low)
    _plusDM    = na(_up)   ? na : _up   > _down and _up   > 0 ? _up   : 0
    _minusDM   = na(_down) ? na : _down > _up   and _down > 0 ? _down : 0
    _trueRange = ta.rma(ta.tr, _len)
    _plus      = fixnan(100 * ta.rma(_plusDM,  _len) / _trueRange)
    _minus     = fixnan(100 * ta.rma(_minusDM, _len) / _trueRange)
    [_plus, _minus]
f_sig(_diLen, _sigLen) =>
    [_plus, _minus] = f_dirMov(_diLen)
    _sum       = _plus + _minus
    _sig       = 100 * ta.rma(math.abs(_plus - _minus) / (_sum == 0 ? 1 : _sum), _sigLen)
    [_sig]
//}
// ——————————— <calculations> {
//<set initial values>
condition    = 0.0
[sig]        = f_sig   (i_diLen, i_sigLen)
[diPlus, _]  = f_dirMov(i_diLen)
[_, diMinus] = f_dirMov(i_diLen)
hlRange     = sig     <= i_hlRange
diUp        = diPlus  >= diMinus
diUpUp      = diPlus  >= i_hlTrend
diDn        = diMinus >  diPlus
diDnDn      = diMinus >  i_hlTrend
crossDi     = ta.cross(diPlus, diMinus)
sigUp       = sig > sig[1]
sigDir      = sig > sig[1] and diUp and not hlRange ?  1 :
              sig > sig[1] and diDn and not hlRange ? -1 : 0
//Rules
entryLong    = not hlRange and diUp and sigUp and not diUp[1] or
               not hlRange and diUp and sigUp and sig > i_hlRange and hlRange[1]
entryShort   = not hlRange and diDn and sigUp and not diDn[1] or
               not hlRange and diDn and sigUp and sig > i_hlRange and hlRange[1]
entryLongStr = not hlRange and diUp and sigUp and diUpUp
entryShortSt = not hlRange and diDn and sigUp and diDnDn
exitLong     = crossDi and diUp[1] or hlRange and not hlRange[1]
exitShort    = crossDi and diDn[1] or hlRange and not hlRange[1]
condition   := condition[1] !=  1   and entryLongStr ?  1   :
               condition[1] != -1   and entryShortSt ? -1   :
               condition[1] !=  0.5 and entryLong    ?  0.5 :
               condition[1] != -0.5 and entryShort   ? -0.5 :
               condition[1] !=  0   and exitLong     ?  0   :
               condition[1] !=  0   and exitShort    ?  0   : nz(condition[1])
longE        = barstate.isconfirmed and
               condition[1] !=  0.5 and condition ==    0.5
shortE       = barstate.isconfirmed and
               condition[1] != -0.5 and condition ==   -0.5
longEStr     = barstate.isconfirmed and
               condition[1] !=  1   and condition ==    1
shortEStr    = barstate.isconfirmed and
               condition[1] != -1   and condition ==   -1
longX        = barstate.isconfirmed and
             ((condition[1] ==  0.5 and condition ==    0) or
              (condition[1] ==  1   and condition ==    0))
shortX       = barstate.isconfirmed and
             ((condition[1] == -0.5 and condition ==    0) or
              (condition[1] == -1   and condition ==    0))
//<color>
c_sig        = hlRange                             ?           color.orange      :
                   sigUp   and diUp                ? color.new(C_GREEN,       0) :
               not sigUp   and diUp                ? color.new(C_GREENLIGHT,  0) :
                   sigUp   and diDn                ? color.new(C_RED,         0) :
               not sigUp   and diDn                ? color.new(C_REDLIGHT,    0) : na
c_fillAdx    =     hlRange                         ? color.new(color.orange, 90) :
               not hlRange and diUp and diUpUp     ? color.new(C_GREEN     , 90) :
               not hlRange and diUp and not diUpUp ? color.new(C_GREENLIGHT, 90) :
               not hlRange and diDn and diDnDn     ? color.new(C_RED       , 90) :
               not hlRange and diDn and not diDnDn ? color.new(C_REDLIGHT  , 90) : na
//}
// ——————————— <plots> {
plot(
  sig,
  title      = 'ADX',
  color      = c_sig,
  linewidth  = 3)
p_diPlus     = plot(
  diPlus,
  title      = '+DI',
  color      = C_GREEN)
p_diMinus    = plot(
  diMinus,
  title      = '-DI',
  color      = C_RED)
fill(
  p_diPlus, p_diMinus,
  title      = 'Fill ADX ',
  color      = c_fillAdx)
plot(
  crossDi ? diPlus : na,
  title      = 'Cross Di',
  color      = #00000000,
  style      = plot.style_circles,
  linewidth  = 2)
hline(
  i_hlRange,
  title      = 'Level Range',
  color      = color.gray,
  linestyle  = hline.style_dotted,
  linewidth  = 1)
hline(
  i_hlTrend,
  title      = 'Level Trend',
  color      = color.gray,
  linestyle  = hline.style_dotted,
  linewidth  = 1)
barcolor(i_barColOn ? c_sig : na)
//}
// ——————————— <alerts> {
plotshape(
  i_alertOn and longE ? i_hlTrend + 10 : na,
  title      = 'Bullish\nTrend',
  color      = C_GREEN,
  style      = shape.triangleup,
  size       = size.tiny,
  location   = location.absolute)
plotshape(
  i_alertOn and shortE ? i_hlTrend + 10 : na,
  title      = 'Bearish\nTrend',
  color      = C_RED,
  style      = shape.triangledown,
  size       = size.tiny,
  location   = location.absolute)
plotshape(
  i_alertOn and longEStr ? i_hlTrend + 10 : na,
  title      = 'Strong\nBullish\nTrend',
  color      = C_GREEN,
  style      = shape.triangleup,
  size       = size.small,
  location   = location.absolute)
plotshape(
  i_alertOn and shortEStr ? i_hlTrend + 10 : na,
  title      = 'Strong\nBearish\nTrend',
  color      = C_RED,
  style      = shape.triangledown,
  size       = size.small,
  location   = location.absolute)
plotshape(
  i_alertOn and (longX or shortX) ? i_hlTrend + 10 : na,
  title      = 'End\nTrend',
  color      = color.new(color.orange, 0),
  style      = shape.xcross,
  size       = size.small,
  location   = location.absolute)
alertcondition(
  longE or shortE or longEStr or shortEStr or longX or shortX,
  title      = 'Any Alert',
  message    = 'Any Alert')
alertcondition(
  longE,
  title      = 'Buy Weak Alert',
  message    = 'Buy Weak Alert')
alertcondition(
  shortE,
  title      = 'Sell Weak Alert',
  message    = 'Sell Weak Alert')
alertcondition(
  longEStr,
  title      = 'Buy Strong Alert',
  message    = 'Buy Strong Alert')
alertcondition(
  shortEStr,
  title      = 'Sell Strong Alert',
  message    = 'Sell Strong Alert')
alertcondition(
  longX,
  title      = 'Buy Close Alert',
  message    = 'Buy Close Alert')
alertcondition(
  shortX,
  title      = 'Sell Close Alert',
  message    = 'Sell Close Alert')
//}
find below

CSS:
# https://my.tradingview.com/script/RNcqYq6w-ADX-Di-Di-Gu5/
# This source code is subject to these terms:
#// You are free to:
#// Share, copy and redistribute this script
#// Adapt, transform and build on this script.
#// Under the following terms:
#// NonCommercial: You may not use the material for commercial purposes.
#// Attribution: You must give appropriate credit
#// https://www.safecreative.org/work/2302153511401-adx-di-di-gu5-
#// © gu5tavo71 (Gustavo Cardelle)
#indicator(title = 'ADX Di+ Di- [Gu5]', shorttitle = 'ADX', overlay = false,
#// Indicator to helps determine the strength of a trend
#// Average Directional movement indeX (ADX) Developed by J. Welles
#// This script reuses open source code from another authors:
#// @PineCoders, Built-in Library, and Community Scripts
#// Disclaimer: I am not a financial advisor.
#//             For purpose educate only. Use at your own risk.
# Converted by Sam4Cok@Samer800        - 03/2023
declare lower;
#// ——————————— <inputs> {
input adxSmoothing = 14;#        'ADX Smoothing'
input diLength     = 14;#        'DI Length'
input Level_Range  = 20;#        'Level Range'
input Level_Trend  = 35;#        'Level Trend'
input alertOn      = yes;#      "Alert On/Off"
input barColor     = yes;#      "Bar Color On/Off"

def na = Double.NaN;
def last = isNaN(close);
def isconfirmed = !IsNaN(close);
#--- Color---
DefineGlobalColor("green"  , CreateColor(0, 100, 0));
DefineGlobalColor("lgreen" , CreateColor(56,142,60));
DefineGlobalColor("red"    , CreateColor(139,0,0));
DefineGlobalColor("lred"   , CreateColor(183,28,28));
DefineGlobalColor("orange" , CreateColor(255,152,0));

DefineGlobalColor("cgreen"  , CreateColor(0,61,0));
DefineGlobalColor("clgreen" , CreateColor(39,100,42));
DefineGlobalColor("cred"    , CreateColor(61,0,0));
DefineGlobalColor("clred"   , CreateColor(149,23,23));
DefineGlobalColor("corange" , CreateColor(118, 70, 0));

# function_declarations> {
script nz {
    input data  = close;
    def ret_val = if !isNaN(data) then data else 0;
    plot return = ret_val;
}
script fixnan {
    input source = close;
    def fix = if !IsNaN(source) then source else fix[1];
    plot result = fix;
}
#f_dirMov(_len) =>
script f_dirMov {
    input _len = 14;
    def _up        = (high - high[1]);
    def _down      = -(low - low[1]);
    def _plusDM    = if IsNaN(_up) then Double.NaN else if _up > _down and _up   > 0 then _up else 0;
    def _minusDM   = if IsNaN(_down) then Double.NaN else if _down > _up and _down > 0 then _down else 0;
    def tr = TrueRange(high, close, low);
    def _trueRange = WildersAverage(tr, _len);
    def _plus      = (100 * WildersAverage(_plusDM,  _len) / _trueRange);
    def _minus     = (100 * WildersAverage(_minusDM, _len) / _trueRange);
    def plus_      = if isNaN(_plus) then plus_[1] else _plus;
    def minus_     = if isNaN(_minus) then minus_[1] else _minus;
    plot plus = plus_;
    plot min  = minus_;
}
#f_sig(_diLen, _sigLen) =>
script f_sig {
    input _diLen = 14;
    input _sigLen = 14;
    def _plus = f_dirMov(_diLen).plus;
    def _minus = f_dirMov(_diLen).min;
    def _sum = _plus + _minus;
    def _sig = 100 * WildersAverage(AbsValue(_plus - _minus) / (if _sum == 0 then 1 else _sum), _sigLen);
    plot out = _sig;
}
#— <calculations> {
#//<set initial values>
def condition;#    = 0.0

def sig = f_sig(diLength, adxSmoothing);
def diPlus = f_dirMov(diLength).plus;
def diMinus = f_dirMov(diLength).min;

def hlRange     = sig     <= Level_Range;
def diUp        = diPlus  >= diMinus;
def diUpUp      = diPlus  >= Level_Trend;
def diDn        = diMinus >  diPlus;
def diDnDn      = diMinus >  Level_Trend;
def crossDi     = (diPlus>diMinus and diPlus[1]<=diMinus[1]) or (diPlus<diMinus and diPlus[1]>=diMinus[1]);
def sigUp       = sig > sig[1];
def sigDir      = if sig > sig[1] and diUp and !hlRange then 1 else
                  if sig > sig[1] and diDn and !hlRange then -1 else 0;
#//Rules
def entryLong    = !hlRange and diUp and sigUp and !diUp[1] or
                   !hlRange and diUp and sigUp and sig > Level_Range and hlRange[1];
def entryShort   = !hlRange and diDn and sigUp and !diDn[1] or
                   !hlRange and diDn and sigUp and sig > Level_Range and hlRange[1];
def entryLongStr = !hlRange and diUp and sigUp and diUpUp;
def entryShortSt = !hlRange and diDn and sigUp and diDnDn;
def exitLong     = crossDi and diUp[1] or hlRange and !hlRange[1];
def exitShort    = crossDi and diDn[1] or hlRange and !hlRange[1];
condition   = if condition[1] !=  1   and entryLongStr then 1 else
              if condition[1] != -1   and entryShortSt then -1 else
              if condition[1] != 0.5 and entryLong    then 0.5 else
              if condition[1] != -0.5 and entryShort  then -0.5 else
              if condition[1] !=  0   and exitLong    then 0  else
              if condition[1] !=  0   and exitShort   then 0  else nz(condition[1]);
def longE     = isconfirmed and
               condition[1] !=  0.5 and condition ==    0.5;
def shortE    = isconfirmed and
               condition[1] != -0.5 and condition ==   -0.5;
def longEStr  = isconfirmed and
               condition[1] !=  1   and condition ==    1;
def shortEStr = isconfirmed and
               condition[1] != -1   and condition ==   -1;
def longX     = isconfirmed and
             ((condition[1] ==  0.5 and condition ==    0) or
              (condition[1] ==  1   and condition ==    0));
def shortX    = isconfirmed and
             ((condition[1] == -0.5 and condition ==    0) or
              (condition[1] == -1   and condition ==    0));
#//<color>
def c_sig    = if hlRange then 0 else
               if sigUp   and diUp then 2 else
               if !sigUp  and diUp then 1 else
               if sigUp   and diDn then -2 else
               if !sigUp  and diDn then -1 else na;
def c_Adx    = if hlRange then 0 else
               if !hlRange and diUp and diUpUp  then 2 else
               if !hlRange and diUp and !diUpUp then 1 else
               if !hlRange and diDn and diDnDn then -2 else
               if !hlRange and diDn and !diDnDn then -1 else na;

#// ——————————— <plots> {
plot adx = if last or isNaN(c_sig) then na else sig;
adx.SetLineWeight(3);
adx.AssignValueColor(if c_sig==0 then GlobalColor("orange") else
                     if c_sig==2 then GlobalColor("green") else
                     if c_sig==1 then GlobalColor("lgreen") else
                     if c_sig==-2 then GlobalColor("red") else GlobalColor("lred"));

plot p_diPlus     = if last then na else diPlus;
p_diPlus.SetDefaultColor(GlobalColor("green"));

plot p_diMinus    = if last then na else diMinus;
p_diMinus.SetDefaultColor(GlobalColor("red"));

AddCloud(if isNaN(c_Adx) then na else if c_Adx==0 then p_diPlus else na, p_diMinus, GlobalColor("corange"),GlobalColor("corange"));
AddCloud(if isNaN(c_Adx) then na else if c_Adx==2 then p_diPlus else na, p_diMinus, GlobalColor("cgreen"),GlobalColor("cgreen"));
AddCloud(if isNaN(c_Adx) then na else if c_Adx==1 then p_diPlus else na, p_diMinus, GlobalColor("clgreen"),GlobalColor("clgreen"));
AddCloud(if isNaN(c_Adx) then na else if c_Adx==-2 then p_diPlus else na, p_diMinus, GlobalColor("cred"),GlobalColor("cred"));
AddCloud(if isNaN(c_Adx) then na else if c_Adx==-1 then p_diPlus else na, p_diMinus, GlobalColor("clred"),GlobalColor("clred"));

plot LevelRange = if last then na else Level_Range;
LevelRange.SetDefaultColor(Color.GRAY);
LevelRange.SetPaintingStrategy(PaintingStrategy.DASHES);

plot LevelTrend = if last then na else Level_Trend;
LevelTrend.SetDefaultColor(Color.GRAY);
LevelTrend.SetPaintingStrategy(PaintingStrategy.DASHES);

AssignPriceColor(if !barColor or isNaN(c_sig) then Color.CURRENT else
                 if c_sig==0 then GlobalColor("orange") else
                 if c_sig==2 then GlobalColor("green") else
                 if c_sig==1 then GlobalColor("lgreen") else
                 if c_sig==-2 then GlobalColor("red") else GlobalColor("lred"));

#// ——————————— <alerts> {
plot Bullish = if alertOn and longE then Level_Trend + 10 else na;
Bullish.SetDefaultColor(GlobalColor("green"));
Bullish.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
#  style      = shape.triangleup,
#  size       = size.tiny,
#  location   = location.absolute)
plot Bearish = if alertOn and shortE then Level_Trend + 10 else na;
Bearish.SetDefaultColor(GlobalColor("red"));
Bearish.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
#  style      = shape.triangledown,
#  size       = size.tiny,
#  location   = location.absolute)
plot StrongBull = if alertOn and longEStr then Level_Trend + 10 else na;
StrongBull.SetDefaultColor(GlobalColor("green"));
StrongBull.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
StrongBull.SetLineWeight(3);
#  style      = shape.triangleup,
#  size       = size.small,
#  location   = location.absolute)
plot StrongBear = if alertOn and shortEStr then Level_Trend + 10 else na;
StrongBear.SetDefaultColor(GlobalColor("red"));
StrongBear.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
StrongBear.SetLineWeight(3);
#  style      = shape.triangledown,
#  size       = size.small,
#  location   = location.absolute)
plot EndTrend = if alertOn and (longX or shortX) then Level_Trend + 10 else na;
EndTrend.SetDefaultColor(GlobalColor("orange"));
EndTrend.SetPaintingStrategy(PaintingStrategy.SQUARES);
EndTrend.SetLineWeight(3);
#  style      = shape.xcross,
#  size       = size.small,
#  location   = location.absolute)



#-- END of Code
 
@samer800. Thanks for the conversion. Perfect! This is what I have used in TV and it's ADX is a bit different than the one TOS has. Appreciate it. I validated with five charts and the results are the same with what I get from TV. If I have any questions, I hope you are ok if I come back to you. Thank you.
 
find below

CSS:
# https://my.tradingview.com/script/RNcqYq6w-ADX-Di-Di-Gu5/
# This source code is subject to these terms:
#// You are free to:
#// Share, copy and redistribute this script
#// Adapt, transform and build on this script.
#// Under the following terms:
#// NonCommercial: You may not use the material for commercial purposes.
#// Attribution: You must give appropriate credit
#// https://www.safecreative.org/work/2302153511401-adx-di-di-gu5-
#// © gu5tavo71 (Gustavo Cardelle)
#indicator(title = 'ADX Di+ Di- [Gu5]', shorttitle = 'ADX', overlay = false,
#// Indicator to helps determine the strength of a trend
#// Average Directional movement indeX (ADX) Developed by J. Welles
#// This script reuses open source code from another authors:
#// @PineCoders, Built-in Library, and Community Scripts
#// Disclaimer: I am not a financial advisor.
#//             For purpose educate only. Use at your own risk.
# Converted by Sam4Cok@Samer800        - 03/2023
declare lower;
#// ——————————— <inputs> {
input adxSmoothing = 14;#        'ADX Smoothing'
input diLength     = 14;#        'DI Length'
input Level_Range  = 20;#        'Level Range'
input Level_Trend  = 35;#        'Level Trend'
input alertOn      = yes;#      "Alert On/Off"
input barColor     = yes;#      "Bar Color On/Off"

def na = Double.NaN;
def last = isNaN(close);
def isconfirmed = !IsNaN(close);
#--- Color---
DefineGlobalColor("green"  , CreateColor(0, 100, 0));
DefineGlobalColor("lgreen" , CreateColor(56,142,60));
DefineGlobalColor("red"    , CreateColor(139,0,0));
DefineGlobalColor("lred"   , CreateColor(183,28,28));
DefineGlobalColor("orange" , CreateColor(255,152,0));

DefineGlobalColor("cgreen"  , CreateColor(0,61,0));
DefineGlobalColor("clgreen" , CreateColor(39,100,42));
DefineGlobalColor("cred"    , CreateColor(61,0,0));
DefineGlobalColor("clred"   , CreateColor(149,23,23));
DefineGlobalColor("corange" , CreateColor(118, 70, 0));

# function_declarations> {
script nz {
    input data  = close;
    def ret_val = if !isNaN(data) then data else 0;
    plot return = ret_val;
}
script fixnan {
    input source = close;
    def fix = if !IsNaN(source) then source else fix[1];
    plot result = fix;
}
#f_dirMov(_len) =>
script f_dirMov {
    input _len = 14;
    def _up        = (high - high[1]);
    def _down      = -(low - low[1]);
    def _plusDM    = if IsNaN(_up) then Double.NaN else if _up > _down and _up   > 0 then _up else 0;
    def _minusDM   = if IsNaN(_down) then Double.NaN else if _down > _up and _down > 0 then _down else 0;
    def tr = TrueRange(high, close, low);
    def _trueRange = WildersAverage(tr, _len);
    def _plus      = (100 * WildersAverage(_plusDM,  _len) / _trueRange);
    def _minus     = (100 * WildersAverage(_minusDM, _len) / _trueRange);
    def plus_      = if isNaN(_plus) then plus_[1] else _plus;
    def minus_     = if isNaN(_minus) then minus_[1] else _minus;
    plot plus = plus_;
    plot min  = minus_;
}
#f_sig(_diLen, _sigLen) =>
script f_sig {
    input _diLen = 14;
    input _sigLen = 14;
    def _plus = f_dirMov(_diLen).plus;
    def _minus = f_dirMov(_diLen).min;
    def _sum = _plus + _minus;
    def _sig = 100 * WildersAverage(AbsValue(_plus - _minus) / (if _sum == 0 then 1 else _sum), _sigLen);
    plot out = _sig;
}
#— <calculations> {
#//<set initial values>
def condition;#    = 0.0

def sig = f_sig(diLength, adxSmoothing);
def diPlus = f_dirMov(diLength).plus;
def diMinus = f_dirMov(diLength).min;

def hlRange     = sig     <= Level_Range;
def diUp        = diPlus  >= diMinus;
def diUpUp      = diPlus  >= Level_Trend;
def diDn        = diMinus >  diPlus;
def diDnDn      = diMinus >  Level_Trend;
def crossDi     = (diPlus>diMinus and diPlus[1]<=diMinus[1]) or (diPlus<diMinus and diPlus[1]>=diMinus[1]);
def sigUp       = sig > sig[1];
def sigDir      = if sig > sig[1] and diUp and !hlRange then 1 else
                  if sig > sig[1] and diDn and !hlRange then -1 else 0;
#//Rules
def entryLong    = !hlRange and diUp and sigUp and !diUp[1] or
                   !hlRange and diUp and sigUp and sig > Level_Range and hlRange[1];
def entryShort   = !hlRange and diDn and sigUp and !diDn[1] or
                   !hlRange and diDn and sigUp and sig > Level_Range and hlRange[1];
def entryLongStr = !hlRange and diUp and sigUp and diUpUp;
def entryShortSt = !hlRange and diDn and sigUp and diDnDn;
def exitLong     = crossDi and diUp[1] or hlRange and !hlRange[1];
def exitShort    = crossDi and diDn[1] or hlRange and !hlRange[1];
condition   = if condition[1] !=  1   and entryLongStr then 1 else
              if condition[1] != -1   and entryShortSt then -1 else
              if condition[1] != 0.5 and entryLong    then 0.5 else
              if condition[1] != -0.5 and entryShort  then -0.5 else
              if condition[1] !=  0   and exitLong    then 0  else
              if condition[1] !=  0   and exitShort   then 0  else nz(condition[1]);
def longE     = isconfirmed and
               condition[1] !=  0.5 and condition ==    0.5;
def shortE    = isconfirmed and
               condition[1] != -0.5 and condition ==   -0.5;
def longEStr  = isconfirmed and
               condition[1] !=  1   and condition ==    1;
def shortEStr = isconfirmed and
               condition[1] != -1   and condition ==   -1;
def longX     = isconfirmed and
             ((condition[1] ==  0.5 and condition ==    0) or
              (condition[1] ==  1   and condition ==    0));
def shortX    = isconfirmed and
             ((condition[1] == -0.5 and condition ==    0) or
              (condition[1] == -1   and condition ==    0));
#//<color>
def c_sig    = if hlRange then 0 else
               if sigUp   and diUp then 2 else
               if !sigUp  and diUp then 1 else
               if sigUp   and diDn then -2 else
               if !sigUp  and diDn then -1 else na;
def c_Adx    = if hlRange then 0 else
               if !hlRange and diUp and diUpUp  then 2 else
               if !hlRange and diUp and !diUpUp then 1 else
               if !hlRange and diDn and diDnDn then -2 else
               if !hlRange and diDn and !diDnDn then -1 else na;

#// ——————————— <plots> {
plot adx = if last or isNaN(c_sig) then na else sig;
adx.SetLineWeight(3);
adx.AssignValueColor(if c_sig==0 then GlobalColor("orange") else
                     if c_sig==2 then GlobalColor("green") else
                     if c_sig==1 then GlobalColor("lgreen") else
                     if c_sig==-2 then GlobalColor("red") else GlobalColor("lred"));

plot p_diPlus     = if last then na else diPlus;
p_diPlus.SetDefaultColor(GlobalColor("green"));

plot p_diMinus    = if last then na else diMinus;
p_diMinus.SetDefaultColor(GlobalColor("red"));

AddCloud(if isNaN(c_Adx) then na else if c_Adx==0 then p_diPlus else na, p_diMinus, GlobalColor("corange"),GlobalColor("corange"));
AddCloud(if isNaN(c_Adx) then na else if c_Adx==2 then p_diPlus else na, p_diMinus, GlobalColor("cgreen"),GlobalColor("cgreen"));
AddCloud(if isNaN(c_Adx) then na else if c_Adx==1 then p_diPlus else na, p_diMinus, GlobalColor("clgreen"),GlobalColor("clgreen"));
AddCloud(if isNaN(c_Adx) then na else if c_Adx==-2 then p_diPlus else na, p_diMinus, GlobalColor("cred"),GlobalColor("cred"));
AddCloud(if isNaN(c_Adx) then na else if c_Adx==-1 then p_diPlus else na, p_diMinus, GlobalColor("clred"),GlobalColor("clred"));

plot LevelRange = if last then na else Level_Range;
LevelRange.SetDefaultColor(Color.GRAY);
LevelRange.SetPaintingStrategy(PaintingStrategy.DASHES);

plot LevelTrend = if last then na else Level_Trend;
LevelTrend.SetDefaultColor(Color.GRAY);
LevelTrend.SetPaintingStrategy(PaintingStrategy.DASHES);

AssignPriceColor(if !barColor or isNaN(c_sig) then Color.CURRENT else
                 if c_sig==0 then GlobalColor("orange") else
                 if c_sig==2 then GlobalColor("green") else
                 if c_sig==1 then GlobalColor("lgreen") else
                 if c_sig==-2 then GlobalColor("red") else GlobalColor("lred"));

#// ——————————— <alerts> {
plot Bullish = if alertOn and longE then Level_Trend + 10 else na;
Bullish.SetDefaultColor(GlobalColor("green"));
Bullish.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
#  style      = shape.triangleup,
#  size       = size.tiny,
#  location   = location.absolute)
plot Bearish = if alertOn and shortE then Level_Trend + 10 else na;
Bearish.SetDefaultColor(GlobalColor("red"));
Bearish.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
#  style      = shape.triangledown,
#  size       = size.tiny,
#  location   = location.absolute)
plot StrongBull = if alertOn and longEStr then Level_Trend + 10 else na;
StrongBull.SetDefaultColor(GlobalColor("green"));
StrongBull.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
StrongBull.SetLineWeight(3);
#  style      = shape.triangleup,
#  size       = size.small,
#  location   = location.absolute)
plot StrongBear = if alertOn and shortEStr then Level_Trend + 10 else na;
StrongBear.SetDefaultColor(GlobalColor("red"));
StrongBear.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
StrongBear.SetLineWeight(3);
#  style      = shape.triangledown,
#  size       = size.small,
#  location   = location.absolute)
plot EndTrend = if alertOn and (longX or shortX) then Level_Trend + 10 else na;
EndTrend.SetDefaultColor(GlobalColor("orange"));
EndTrend.SetPaintingStrategy(PaintingStrategy.SQUARES);
EndTrend.SetLineWeight(3);
#  style      = shape.xcross,
#  size       = size.small,
#  location   = location.absolute)



#-- END of Code
the arrows is too far away could plz u fix it
 
Last edited:

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
455 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