SuperTrend Indicator CoMgUnNeR
SuperTrend Indicator CoMgUnNeR
SuperTrend Indicator CoMgUnNeR
0 at
https://mozilla.org/MPL/2.0/
// © NewLifeRipon
//@version=5
VERSION = 'V 1.5'
// Filter Colors
if ThemeUX == "Classic"
psar_longColor := color.rgb(9, 116, 23,0)
psar_longLight := color.rgb(9, 116, 23,65)
psar_shortColor := color.rgb(151, 14, 14,0)
psar_shortLight := color.rgb(151, 14, 14,65)
else if ThemeUX == "Cool"
psar_longColor := color.new(#00DBFF, 0)
psar_longLight := color.new(#00DBFF, 65)
psar_shortColor := color.new(#E91E63, 0)
psar_shortLight := color.new(#E91E63, 65)
// Support/Resistance Inputs
psar_suppRes = input.bool(false, "Support/Resistance?", inline = "UPPORT AND
RESISTANCE",group = groupPSAR)
psar_barsLR = input.int(35, "S/R Looking Period", 1, inline = "UPPORT AND
RESISTANCE",group = groupPSAR)
// Support/Resistance Calculations
psar_pivotHigh = ta.pivothigh(psar_barsLR, psar_barsLR)[1]
psar_pivotLow = ta.pivotlow(psar_barsLR, psar_barsLR)[1]
// Draw Support/Resistance
if (psar_suppRes and not na(psar_pivotHigh))
line.new(x1=bar_index - psar_barsLR, y1=psar_pivotHigh, x2=bar_index,
y2=psar_pivotHigh, color=psar_shortColor, width=3)
if (psar_suppRes and not na(psar_pivotLow))
line.new(x1=bar_index - psar_barsLR, y1=psar_pivotLow, x2=bar_index,
y2=psar_pivotLow, color=psar_longColor, width=3)
//*********************************************************
//** GROUPS **
//*********************************************************
//THE FIRST LINE OF THE MODULE IS COMMENTED AND TRANSFERRED
HERE
//VISUAL ORDER
//POSITION 1
group2 = "======= Module - SUPERTREND ======="
plot(na)
mostrarST = input.bool(true, "Mostrar SUPER-TREND", inline = "SUPER TREND" ,
group=group2, tooltip="Habilita/Deshabilita supertrend")
groupEnTpSl = "======= Module - Signals ======= "
plot(na)
numTP_tip = " Number of Take Profit Levels, min 1 max 10 / Número de niveles de
toma de ganancias, mínimo 1 máximo 10 "
numTP = input.int(10, "Number of Take Profit Levels 💪", minval=1, maxval=10,tooltip
=numTP_tip ,group=groupEnTpSl)
// Cálculos
var fastLength_CHT_VOL = 12 //input(12)
var slowlength_CHT_VOL = 26 //input(26)
var deltaLength_CHT_VOL = 9 //input(9)
// Create inputs
mom_length = slowlength_CHT_VOL
// Define MAs
ema = ta.ema(close, mom_length)
sma = ta.sma(close, mom_length)
combined_ma = sma
// Plot MAs
plot(mostrarSmaCon ? combined_ma :na, title="Combined Momentum MA",
color=combined_ma_color, linewidth=3)
// Condiciones principales
buyConditionF = trend == 1 and trend[1] == -1
sellConditionF = trend == -1 and trend[1] == 1
// Calculamos el RSI
rsi_value = ta.rsi(close, rsi_lengthSPT)
// Filtro de Volumen
if VolumeFilterSelection == "Disable"
buySignalVolume := buyConditionF
sellSignalVolume := sellConditionF
else if VolumeFilterSelection == "Enable"
activeFilter := "Volume"
buySignalVolume := buyConditionF and longVol
sellSignalVolume := sellConditionF and longVol
// Filtro SMA
isLongTrend = close > SMAFILTER
isShortTrend = close < SMAFILTER
if SMAFilterSelection == "Disable"
buySignalSMA := buyConditionF
sellSignalSMA := sellConditionF
else if SMAFilterSelection == "Enable"
activeFilter := "SMA"
buySignalSMA := buyConditionF and isLongTrend
sellSignalSMA := sellConditionF and isShortTrend
if RSIFilterSelection == "Disable"
buySignalRSI := buyConditionF
sellSignalRSI := sellConditionF
else if RSIFilterSelection == "Enable"
activeFilter := "RSI"
buySignalRSI := buyConditionF and long_conditionRSI_SPT
sellSignalRSI := sellConditionF and short_conditionRSI_SPT
if noActiveFilters
buySignal := buyConditionF
sellSignal := sellConditionF
else
if activeFilter == "Volume"
buySignal := buySignalVolume
sellSignal := sellSignalVolume
else if activeFilter == "Whale"
buySignal := buySignalWhale
sellSignal := sellSignalWhale
else if activeFilter == "SMA"
buySignal := buySignalSMA
sellSignal := sellSignalSMA
else if activeFilter == "RSI"
buySignal := buySignalRSI
sellSignal := sellSignalRSI
//numTP_tip = " Number of Take Profit Levels, min 1 max 10 / Número de niveles de
toma de ganancias, mínimo 1 máximo 10 "
//numTP = input.int(3, "Number of Take Profit Levels 💪", minval=1, maxval=10,tooltip
=numTP_tip ,group=groupEnTpSl)
trigger = buySignal ? 1 : 0
atrBand = ta.atr(atrLen) * atrRisk
atrStop = trigger == 1 ? low - atrBand : high + atrBand
lastTrade(src) => ta.valuewhen(changeCond, src, 0 )
if PercentOrATR == "ATR"
atrStop := atrStop
atrSL := atrStop
else
// Lógica para las opciones "PERCENTAGE" y "PREDICTUM"
if PercentOrATR == "PERCENTAGE"
atrStop := Distance_CTp
atrSL := Distance_CSL
else if PercentOrATR == "PREDICTUM"
atrStop := Distance_CTpre // Ajusta según tu lógica específica para
"PREDICTUM"
atrSL := Distance_CSL
//numTP := 8
if trigger
countOfCandles := 0
else
countOfCandles := na(countOfCandles) ? 0 : countOfCandles + 1
//ENTRADA
entry = levels ? label.new(time, close, "ENTRY " + str.tostring(lastTrade(close),
"#.#####"), xloc.bar_time, yloc.price, psar_longColor, label.style_label_left,
color.rgb(0, 0, 0), size.normal) : na
label.set_y(entry, lastTrade(close))
label.delete(entry[1])
stop_y = lastTrade(atrSL)
//STOPLOSS
//################################################################
tf = timeframe.period
miSimbolo = ticker.standard(syminfo.tickerid)
//
================================================================
========
//*********************************************************
// Función para crear TP y líneas by CoMgUnNeR
// ¡Codigo mas simplificado da creditos al autor! me costo bastante.
//*********************************************************
if PercentOrATR == "PREDICTUM"
if level == 1
tp_y := (lastTrade(close) - lastTrade(atrStop)) * level +
lastTrade(close)
else
tp_y := tp_y + (tp_y - lastTrade(close)) * 0.618
tp = label.new(time, tp_y, "TP " + str.tostring(level) + " " + emoji + " " +
str.tostring(tp_y, "#.#####"), xloc.bar_time, yloc.price, color=lineColor,
style=label.style_label_left, textcolor=textColor, size=size.normal)
array.push(tpLabels, tp)
if lvlLines
tpLine = line.new(bar_index - countOfCandles, tp_y, bar_index +
lvlDistance, tp_y, xloc.bar_index, extend.none, lineColor, stylelvl, width=lvlLinesw)
array.push(tpLines, tpLine)
if array.size(tpLines) > numTP
line.delete(array.get(tpLines, 0))
array.shift(tpLines)
if PercentOrATR == "PREDICTUM"
if level_info == 1
tp_y2 := (lastTrade(close) - lastTrade(atrStop)) * level_info +
lastTrade(close)
else
tp_y2 := tp_y2 + (tp_y2 - lastTrade(close)) * 0.618
label.delete(lab_buy[1])
//################################################################
//*********************************************************
// Función para crear TP y líneas by CoMgUnNeR
// ¡Codigo mas simplificado da creditos al autor! me costo bastante.
//*********************************************************
/// TIPS
// LABEL VARIABLES
i_showDOMINANCE = input(false, 'Show DOMINANCE // Mostrar DOMINANCE',
group=groupinfbox, tooltip = DOMINANCE_tip )
i_showMACD = input(true, 'Show MACD // Mostrar MACD', group=groupinfbox,
tooltip = showMACD_tip)
i_showRSI = input(true, 'Show RSI // Mostrar RSI', group=groupinfbox, tooltip =
showRSI_tip)
i_showRSIcross = input(true, 'Show Cross RSI // Mostrar Cruce RSI ',
group=groupinfbox, tooltip=showRSIcross_tip)
i_showEstochastic = input(true, 'Show STOCH // Mostrar STOCH',
group=groupinfbox , tooltip = showEstochastic_tip)
i_showADX = input(true, 'Show ADX // Mostrar ADX', group=groupinfbox , tooltip =
showADX_tip)
i_showSQUEEZE = input(true, 'Show SQUEEZE // Mostrar SQUEEZE',
group=groupinfbox, tooltip = showSQUEEZE_tip)
i_showcredits = input(true, 'Credits', group=groupinfbox, tooltip =showORB_tip)
// ROUNDS
f_round(_val, _decimals) =>
if _decimals == -1
_val
else
_p = math.pow(10, _decimals)
math.round(math.abs(_val) * _p) / _p * math.sign(_val)
// DOMINANCESection
DOMINANCETitle = splitter + nl + nl + 'Crypto Dominance🌐' + nl
BTCDClose = request.security('BTC.D', 'M', close)
BTCD = f_strHelp('BTC ₿ % →', BTCDClose, 1)
ETHDClose = request.security('ETH.D', 'M', close)
ETHD = f_strHelp('ETH ⬨ % →', ETHDClose, 1)
DOMINANCESection = i_showDOMINANCE ? DOMINANCETitle + nl + BTCD +
ETHD : na
// MACDSection
MACDTitle = splitter + nl
[macd, macdsignal, macdhist] = ta.macd(close, fastlen=12, slowlen=26, siglen=9)
trend3 = macdhist > 0 ? '[ Bullish 📈 Alcista ]' : '[ Bearish 📉 Bajista ]'
MACDSection = i_showMACD ? MACDTitle + nl + 'MACD Trend 📊 :' + nl + nl +
trend3 + nl : na
// RSISection
RSITitle = splitter + nl
rsibase2 = ta.rsi(close, 7)
rsibase = ta.rsi(close, 14)
rsibase3 = ta.rsi(close, 21)
Trend1 = rsibase > 80 and rsibase2 > 80 or rsibase2 > 80 and rsibase3 > 80 or
rsibase > 80 and rsibase3 > 80 ? nl + '🚨🚨🚨🚨🚨' + '[ RSI OVERBUY📈' + nl + 'RSI
SOBRECOMPRA]' : na
Trend2 = rsibase < 20 and rsibase2 < 20 or rsibase2 < 20 and rsibase3 < 20 or
rsibase < 20 and rsibase3 < 20 ? nl + '🚨🚨🚨🚨🚨' + '[ RSI OVERSELL📉' + nl + 'RSI
SOBREVENTA]' : na
RSISection = i_showRSI ? RSITitle + nl + f_strHelp('RSI:', rsibase, 1) + Trend1 +
Trend2 + nl : na + nl
// Stoch
EstochasticTitle = splitter + nl
periodK2 = 7
periodD2 = 3
smoothK2 = 3
//TIPO3
periodK3 = 21
periodD3 = 3
smoothK3 = 3
//STD
k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
d = ta.sma(k, periodD)
//tp2
k2 = ta.sma(ta.stoch(close, high, low, periodK2), smoothK2)
d2 = ta.sma(k2, periodD2)
//tp3
k3 = ta.sma(ta.stoch(close, high, low, periodK3), smoothK3)
d3 = ta.sma(k3, periodD3)
Trend1stoch = k > 80 and k2 > 80 or k2 > 80 and k3 > 80 or k > 80 and k3 > 80 ? nl
+ nl + '🚨🚨🚨🚨🚨 ' + nl + nl + '[ STOCH OVERBUY 📈' + nl + 'STOCH
SOBRECOMPRA]' + nl : na + nl
Trend2stoch = k < 20 and k2 < 20 or k2 < 20 and k3 < 20 or k < 20 and k3 < 20 ? nl
+ nl + '🚨🚨🚨🚨🚨 ' + nl + nl + '[ STOCH OVERSELL 📉' + nl + 'STOCH
SOBREVENTA]' + nl : na + nl
EstochasticSection = i_showEstochastic ? nl + EstochasticTitle + nl +
f_strHelp('STOCH K:', k, 1) + f_strHelp('STOCH D:', d, 1) + nl + Trend1stoch +
Trend2stoch + nl : na + nl
//CREDITOS
TelegramTitle = splitter + nl
url = "https://t.me/kakupakat_trading_oficial"
string linkText = "https://t.me/kakupakat_trading_oficial"
displayText = "<a href='" + url + "'>" + linkText + "</a>"
TelegramSection = i_showcredits ?TelegramTitle + nl + 'TELEGRAM' + nl + url +
nl :na
//INICIA ADX
// Inputs ADX
DMIlength = 14
ATRADX = ta.atr(14)
ADXTitle = splitter + nl
Trend1ADX = ADX > 25 ? '💪' + '[ STRONG TREND' + nl + 'TENDENCIA
FUERTE ]' : na + nl
Trend2ADX = ADX < 20 ? '💔' + '[ WEAK TREND' + nl + ' TENDENCIA DEBIL ]' : na
+ nl
ADXSection = i_showADX ? ADXTitle + f_strHelp('ADX Val:', ADX, 1) +
Trend1ADX + Trend2ADX + nl : na
ADXTitle2 = splitter + nl
dirADX = plusDI > minusDI ? '[ Bullish 📈 Alcista ]' : '[ Bearish 📉 Bajista ]'
ADXSection2 = i_showADX ? ADXTitle2 + 'ADX DIR:' + nl + dirADX + nl : na
cruceLongADX = ta.crossover(plusDI, minusDI) ? '🟢🔃' + nl + '[ CROSS + ' + ' ADX
+ ]' : na
cruceShortADX = ta.crossunder(plusDI, minusDI) ? '🔴🔃' + nl + '[ CROSS - ' + ' ADX
- ]' : na
ADXSection3 = i_showADX ? ADXTitle2 + 'ADX CROSS:' + cruceLongADX +
cruceShortADX + nl : na
//TERMINA ADX
// Calculate BB
sourceSqueeze = close
basisSqueeze = ta.sma(sourceSqueeze, lengthSqueeze)
devSqueeze = multKCSqueeze * ta.stdev(sourceSqueeze, lengthSqueeze)
upperBBSqueeze = basisSqueeze + devSqueeze
lowerBBSqueeze = basisSqueeze - devSqueeze
// Calculate KC
maSqueeze = ta.sma(sourceSqueeze, lengthKCSqueeze)
rangeValSqueeze = useTrueRangeSqueeze ? ta.tr : (high - low)
rangemaSqueeze = ta.sma(rangeValSqueeze, lengthKCSqueeze)
upperKCSqueeze = maSqueeze + rangemaSqueeze * multKCSqueeze
lowerKCSqueeze = maSqueeze - rangemaSqueeze * multKCSqueeze
// MACDSection
SqueezeTitle = splitter + nl
SqueezeEndLong = valin < (strengthSqueeze*-1) and valin > nz(valin[1]) ? '🔄🟢' + nl +
'[DIR END ↗️↗️↗️↘️↘️↘️' + nl + ' FIN DIR ↗️↗️↗️↘️↘️↘️ ]' : na
SqueezeEndShort = valin > strengthSqueeze and valin < nz(valin[1]) ? '🔄🔴' + nl +
'[ DIR END ↘️↘️↘️↗️↗️↗️' + nl + ' FIN DIR ↘️↘️↘️↗️↗️↗️]' : na
SqueezeSection = i_showSQUEEZE ? SqueezeTitle + nl + 'DIR CHANGE
SQUEEZE:' + SqueezeEndLong + SqueezeEndShort + nl: na
RSIcrossTitle = splitter + nl
goldenrsiUp = ta.crossover(rsi,rsiMA) and rsiMA < prevrsiMA and rsiMA <
prevrsiMA2 ? '🟢🔼' + nl + '[ Up + ' + nl + 'ARRIBA + ]' : na + nl
goldenrsiDn = ta.crossunder(rsi,rsiMA) and rsiMA > prevrsiMA and rsiMA >
prevrsiMA2 ? '🔴🔽' + nl + '[ Down - ' + nl + 'ABAJO - ]' : na + nl
RSIcrossSection = i_showRSIcross ? RSIcrossTitle +'mRSI GOLD CROSS:' +
goldenrsiUp + goldenrsiDn : na + nl
mRSItrend = rsi > rsiMA ? '[ Bullish 📈 Alcista ]' : '[ Bearish 📉 Bajista ]'
RSIcrossSectionTrend = i_showRSIcross ? RSIcrossTitle + nl + 'mRSI Trend:' + nl
+ nl + mRSItrend + nl : na
//KILLS FIN
// STYLE
label.set_textalign(id, text.align_left)
label.set_color(id, color=color.rgb(0, 0, 50, 50))
label.set_textcolor(id, textcolor=color.new(color.orange, 0))
label.set_style(id, label.style_label_left)
// DynamicText
dynamicText := dynamicText + DOMINANCESection + MACDSection +
ADXSection2 + ADXSection + ADXSection3 + SqueezeSection +
SqueezeSection2 + RSISection + RSIcrossSection + RSIcrossSectionTrend +
EstochasticSection + EstochasticSection2 + TelegramSection
label.set_text(id, text=dynamicText)
//----------//
// END
///////////////////////////////////////////////////////////////////////////////////////////////////
//// VARIABLES
///////////////////////////////////////////////////////////////////////////////////////////////////
float vp_Vmax = 0.0
int vp_VmaxId = 0
int vp_N_BARS = vp_max_bars
///////////////////////////////////////////////////////////////////////////////////////////////////
//// CALCULATIONS
///////////////////////////////////////////////////////////////////////////////////////////////////
float vp_HH = ta.highest(high, vp_lookback)
float vp_LL = ta.lowest(low, vp_lookback)
if barstate.islast
float vp_HL = (vp_HH - vp_LL) / vp_N_BARS
for j = 1 to vp_N_BARS + 1 by 1
array.set(vp_a_P, j - 1, vp_LL + vp_HL * j)
for i = 0 to vp_lookback - 1 by 1
int Dc = 0
array.fill(vp_a_D, 0.0)
for j = 0 to vp_N_BARS - 1 by 1
float Pj = array.get(vp_a_P, j)
if low[i] < Pj and high[i] > Pj and (vp_delta_type == 'Bullish' ? close[i] >=
open[i] : vp_delta_type == 'Bearish' ? close[i] <= open[i] : true)
float Dj = array.get(vp_a_D, j)
float dDj = Dj + nz(volume[i])
array.set(vp_a_D, j, dDj)
Dc += 1
Dc
for j = 0 to vp_N_BARS - 1 by 1
float Vj = array.get(vp_a_V, j)
float Dj = array.get(vp_a_D, j)
float dVj = Vj + (Dc > 0 ? Dj / Dc : 0.0)
array.set(vp_a_V, j, dVj)
vp_Vmax := array.max(vp_a_V)
vp_VmaxId := array.indexof(vp_a_V, vp_Vmax)
for j = 0 to vp_N_BARS - 1 by 1
float Vj = array.get(vp_a_V, j)
int Aj = math.round(vp_bar_mult * Vj / vp_Vmax)
array.set(vp_a_W, j, Aj)
///////////////////////////////////////////////////////////////////////////////////////////////////
//// PLOTING
///////////////////////////////////////////////////////////////////////////////////////////////////
if barstate.isfirst
vp_first := time
vp_first
vp_change = ta.change(time)
vp_x_loc = timenow + math.round(vp_change * vp_bar_offset)
f_setup_bar(n) =>
x1 = vp_VmaxId == n and vp_poc_show ? math.max(time[vp_lookback], vp_first)
: timenow + math.round(vp_change * (vp_bar_offset - array.get(vp_a_W, n)))
ys = array.get(vp_a_P, n)
line.new(x1=x1, y1=ys, x2=vp_x_loc, y2=ys, xloc=xloc.bar_time,
extend=extend.none, color=vp_VmaxId == n ? vp_poc_color : vp_bar_color,
style=line.style_solid, width=vp_bar_width)
if barstate.islast
for i = 0 to vp_N_BARS - 1 by 1
f_setup_bar(i)
///////////////////////////////////////////////////////////////////////////////////////////////////
//// END
///////////////////////////////////////////////////////////////////////////////////////////////////
// Constants
color CLEAR = color.rgb(0,0,0,100)
// Inputs
swingSize = input.int(20, 'Swing length / Longitud del Swing', tooltip='The number of
left and right bars checked when searching for a swing point. Higher value = less
swing points plotted and lower value = more swing points plotted.' ,
group=groupSMC )
bosConfType = input.string('Cierre de Vela', 'BOS Confirmation', ['Cierre de Vela',
'Wicks'], tooltip='Choose whether candle close/wick above previous swing point
counts as a BOS.')
choch = input.bool(true, 'Show CHoCH/ Mostrar CHoCH', tooltip='Renames the first
counter trend BOS to CHoCH' )
showSwing = input.bool(true, ' Show Swin Pivot / Mostrar Puntos de Swing',
tooltip='Show or hide HH, LH, HL, LL')
// Calculations
bool hh = false
bool lh = false
bool hl = false
bool ll = false
//Variable to track the previous swing type, used later on to draw 0.5 Retracement
Levels (HH = 2, LH = 1, HL = -1, LL = -2)
var int prevSwing = 0
if not na(pivHi)
if pivHi >= prevHigh
hh := true
prevSwing := 2
else
lh := true
prevSwing := 1
prevHigh := pivHi
highActive := true
prevHighIndex := bar_index - swingSize
if not na(pivLo)
if pivLo >= prevLow
hl := true
prevSwing := -1
else
ll := true
prevSwing := -2
prevLow := pivLo
lowActive := true
prevLowIndex := bar_index - swingSize
// Visual Output
pss_CHT = 0
Channel_source_CHT = close
var float valtop_CHT = na
var float valbtm_CHT = na
UpperBound_CHT = ta.highest(Channel_source_CHT,channel_length_CHT)
//representa el valor más alto alcanzado por el precio de cierre dentro del canal
LowerBound_CHT = ta.lowest(Channel_source_CHT,channel_length_CHT)
//representa el valor más bajo alcanzado por el precio de cierre dentro del canal
pss_CHT := Channel_source_CHT[channel_length_CHT] > UpperBound_CHT ? 0 :
Channel_source_CHT[channel_length_CHT] < LowerBound_CHT ? 1 : pss_CHT[1]
btm_n_CHT = ta.valuewhen(btm_CHT,bar_index,0)
top_n_CHT = ta.valuewhen(top_CHT,bar_index,0)
len_interval_CHT = math.abs(btm_n_CHT - top_n_CHT)
if btm_CHT
max_diff_up_CHT = 0.
max_diff_dn_CHT = 0.
valbtm_CHT := low[channel_length_CHT]
for i = 0 to len_interval_CHT-1
point_CHT = low[channel_length_CHT] + i/(len_interval_CHT-
1)*(valtop_CHT - low[channel_length_CHT])
max_diff_up_CHT :=
math.max(math.max(Channel_source_CHT[channel_length_CHT+i],open[channel_l
ength_CHT+i]) - point_CHT,max_diff_up_CHT)
max_diff_dn_CHT := math.max(point_CHT -
math.min(Channel_source_CHT[channel_length_CHT+i],open[channel_length_CHT
+i]),max_diff_dn_CHT)
line.new(bar_index[len_interval_CHT+channel_length_CHT],valtop_CHT,bar_index[c
hannel_length_CHT],low[channel_length_CHT],color=#ff5d00)
line.new(bar_index[len_interval_CHT+channel_length_CHT],valtop_CHT+max_diff_
up_CHT,bar_index[channel_length_CHT],low[channel_length_CHT]
+max_diff_up_CHT,color=#ff1100)
line.new(bar_index[len_interval_CHT+channel_length_CHT],valtop_CHT-
max_diff_dn_CHT,bar_index[channel_length_CHT],low[channel_length_CHT]-
max_diff_dn_CHT,color=#ff1100)
label.new(bar_index[channel_length_CHT],low[channel_length_CHT],str.tostring(low
[channel_length_CHT],'#.####'),color=#00000000,style=label.style_label_up,textcolo
r=#2157f3,textalign=text.align_left,size=size.small)
if top_CHT
max_diff_up_CHT = 0.
max_diff_dn_CHT = 0.
valtop_CHT := high[channel_length_CHT]
for i = 0 to len_interval_CHT-1
point_CHT = high[channel_length_CHT] + i/(len_interval_CHT-
1)*(valbtm_CHT - high[channel_length_CHT])
max_diff_up_CHT :=
math.max(math.max(Channel_source_CHT[channel_length_CHT+i],open[channel_l
ength_CHT+i]) - point_CHT,max_diff_up_CHT)
max_diff_dn_CHT := math.max(point_CHT -
math.min(Channel_source_CHT[channel_length_CHT+i],open[channel_length_CHT
+i]),max_diff_dn_CHT)
line.new(bar_index[len_interval_CHT+channel_length_CHT],valbtm_CHT,bar_index[
channel_length_CHT],high[channel_length_CHT],color=#ff5d00)
line.new(bar_index[len_interval_CHT+channel_length_CHT],valbtm_CHT+max_diff_
up_CHT,bar_index[channel_length_CHT],high[channel_length_CHT]
+max_diff_up_CHT,color=#2157f3)
line.new(bar_index[len_interval_CHT+channel_length_CHT],valbtm_CHT-
max_diff_dn_CHT,bar_index[channel_length_CHT],high[channel_length_CHT]-
max_diff_dn_CHT,color=#2157f3)
label.new(bar_index[channel_length_CHT],high[channel_length_CHT],str.tostring(hig
h[channel_length_CHT],'#.####'),color=#00000000,style=label.style_label_down,text
color=#ff1100,textalign=text.align_left,size=size.small)
if barstate.islast
max_diff_up_CHT = 0.
max_diff_dn_CHT = 0.
x1_CHT = 0
y1_CHT = 0.
if pss_CHT == 1
x1_CHT := btm_n_CHT-channel_length_CHT
y1_CHT := valbtm_CHT
for i = 0 to bar_index-btm_n_CHT+channel_length_CHT-1
point_CHT = Channel_source_CHT + i/(bar_index-
btm_n_CHT+channel_length_CHT-1)*(valbtm_CHT - Channel_source_CHT)
max_diff_up_CHT :=
math.max(math.max(Channel_source_CHT[i],open[i]) -
point_CHT,max_diff_up_CHT)
max_diff_dn_CHT := math.max(point_CHT -
math.min(Channel_source_CHT[i],open[i]),max_diff_dn_CHT)
else
x1_CHT := top_n_CHT-channel_length_CHT
y1_CHT := valtop_CHT
for i = 0 to bar_index-top_n_CHT+channel_length_CHT-1
point_CHT = Channel_source_CHT + i/(bar_index-
top_n_CHT+channel_length_CHT-1)*(valtop_CHT - Channel_source_CHT)
max_diff_up_CHT :=
math.max(math.max(Channel_source_CHT[i],open[i]) -
point_CHT,max_diff_up_CHT)
max_diff_dn_CHT := math.max(point_CHT -
math.min(Channel_source_CHT[i],open[i]),max_diff_dn_CHT)
line.delete(line.new(x1_CHT,y1_CHT,bar_index,Channel_source_CHT,color=#ff5d00
,extend=extend.right)[1])
// Draw
line.delete(line.new(x1_CHT,y1_CHT+max_diff_up_CHT,bar_index,Channel_source
_CHT+max_diff_up_CHT,color=#2157f3,extend=extend.right)[1])
line.delete(line.new(x1_CHT,y1_CHT-
max_diff_dn_CHT,bar_index,Channel_source_CHT-
max_diff_dn_CHT,color=#2157f3,extend=extend.right)[1])
//TODAS JUNTAS
automatizacionBot = " Add the UUID or Command for the opening (reemplaza
completamente / completely replaces) / Agrega el UUID o Comando para la apertura
"
automatizacionBot2 = " /BINGX, CORNIX,3 Commas"
//*********************************************************
//*********************************************************
//*** CALCULATIONS FOR SL OR BE TP ***
//*********************************************************
atrLenPNL = atrLen
atrRiskPNL = atrRisk
tpLenPNL = tpLen
tpSLPNL = tpSL
//*********************************************************
//** SHORT AND LONG CONDITIONS ***
//*********************************************************
alertLongPNL = buySignal
alertShortPNL = sellSignal
//********************************************************
//** CHANGE OF CONDITION BETWEEN LONG AND SHORT. ***
//********************************************************
changeCondPNL = nz(alertLongPNL, false) != nz(alertShortPNL, false)
//*********************************************************
triggerPNL = alertLongPNL ? 1 : 0
atrBandPNL = ta.atr(atrLenPNL) * atrRiskPNL
atrStopSTDPNL = triggerPNL == 1 ? low - atrBandPNL : high + atrBandPNL
//*********************************************************
//PercentOrPNL
if PercentOrPNL == "ATR"
atrStopPNL := atrStopSTDPNL
slPNL := lastTradePNL(atrStopPNL)
atrStopPNL := Distance_CTpPnl
slPNL := lastTradePNL(Distance_CSLPnl)
//ENTRADAS
//*********************************************************
//** START CALCULATION TO DETERMINE % PROFIT ***
//*********************************************************
BreakevenPNL = (lastTradePNL(close)-lastTradePNL(breakEven))*1 +
lastTradePNL(close)
TakePNL = (lastTradePNL(close)-lastTradePNL(atrStopPNL))*1 +
lastTradePNL(close)
TakePNL2 = (lastTradePNL(close)-lastTradePNL(atrStopPNL))*2 +
lastTradePNL(close)
TakePNL3 = (lastTradePNL(close)-lastTradePNL(atrStopPNL))*3 +
lastTradePNL(close)
TakePNL4 = (lastTradePNL(close)-lastTradePNL(atrStopPNL))*4 +
lastTradePNL(close)
TakePNL5 = (lastTradePNL(close)-lastTradePNL(atrStopPNL))*5 +
lastTradePNL(close)
TakePNL6 = (lastTradePNL(close)-lastTradePNL(atrStopPNL))*6 +
lastTradePNL(close)
TakePNL7 = (lastTradePNL(close)-lastTradePNL(atrStopPNL))*7 +
lastTradePNL(close)
TakePNL8 = (lastTradePNL(close)-lastTradePNL(atrStopPNL))*8 +
lastTradePNL(close)
TakePNL9 = (lastTradePNL(close)-lastTradePNL(atrStopPNL))*9 +
lastTradePNL(close)
TakePNL10 = (lastTradePNL(close)-lastTradePNL(atrStopPNL))*10 +
lastTradePNL(close)
if alertLongPNL
buylabel = labelsPNL ? label.new(x=bar_index, y=low[0] - low[0]*0.02,
color=psar_longLight, textcolor=color.white, style=label.style_label_up, text='Entry
Long :' + str.tostring(close)) :na
buylabel
if totalPnl == 0.0
hold := close
TakePNL := (lastTradePNL(close)-lastTradePNL(atrStopPNL))*1 +
lastTradePNL(close)
BreakevenPNL := (lastTradePNL(close)-lastTradePNL(breakEven))*1 +
lastTradePNL(close)
tradecloseprice := close
S_sell := true
S_buy := false
buyCondition := 1
if alertShortPNL
buylabel = labelsPNL ? label.new(x=bar_index, y=high[0] + high[0]*0.02,
color=psar_shortLight, textcolor=color.white, style=label.style_label_down,
text='Entry Short :' + str.tostring(close)) :na
buylabel
if totalPnl == 0.0
hold := close
TakePNL := (lastTradePNL(close)-lastTradePNL(atrStopPNL))*1 +
lastTradePNL(close)
BreakevenPNL := (lastTradePNL(close)-lastTradePNL(breakEven))*1 +
lastTradePNL(close)
tradecloseprice := close
S_sell := true
S_buy := false
buyCondition := 2
if buyCondition == 1
sellTPalert := not S_buy and pricesourcePNL >= TakePNL or TakePNL >=
TakePNL2 or TakePNL2 >= TakePNL3 or TakePNL3 >= TakePNL4 or TakePNL4 >=
TakePNL5 or TakePNL5 >= TakePNL6 or TakePNL6 >= TakePNL7 or TakePNL7 >=
TakePNL8 or TakePNL8 >= TakePNL9 or TakePNL9 >= TakePNL10
else if buyCondition == 2
sellTPalert := not S_buy and pricesourcePNL <= TakePNL or TakePNL <=
TakePNL2 or TakePNL2 <= TakePNL3 or TakePNL3 <= TakePNL4 or TakePNL4 <=
TakePNL5 or TakePNL5 <= TakePNL6 or TakePNL6 <= TakePNL7 or TakePNL7 <=
TakePNL8 or TakePNL8 <= TakePNL9 or TakePNL9 <= TakePNL10
if sellTPalert
// Calcular el PnL dependiendo de si la operación es larga o corta
pnl = buyCondition == 1 ? (((close-tradecloseprice)/tradecloseprice)*100) :
buyCondition == 2 ? (((close-tradecloseprice)/tradecloseprice)*100*-1) :na
if sellBEalert
pnl = buyCondition == 1 ? (((close-tradecloseprice)/tradecloseprice)*100) :
buyCondition == 2 ? (((close-tradecloseprice)/tradecloseprice)*100*-1) :na
belabel = labelsPNL ? label.new(x=bar_index, y=high[0] + high[0] * 0.02,
color=color.rgb(255, 153, 0, 60), textcolor=color.white, style=label.style_label_down,
text='BE P/L: ' + str.tostring(pnl, "#.##")+'%') :na
winratio = pnlPos/pnlNeg
//*********************************************************
//** INFORMATION BOARD **
//** STRATEGY TEST **
//*********************************************************
groupStrategyTest = "======= INFOBOX UX STRATEGY TEST ======= "
plot(na)
color kakupakat =color.rgb(0, 0, 50, 50)
if buyCondition < 2
table.cell_set_bgcolor(pnlTable, column = 3, row = 1, bgcolor =#07680a60)
else
table.cell_set_bgcolor(pnlTable, column = 3, row = 1, bgcolor =#92080860)
if winratio > 1
table.cell_set_bgcolor(pnlTable, column = 1, row = 1, bgcolor =#07680a60)
else
table.cell_set_bgcolor(pnlTable, column = 1, row = 1, bgcolor = #92080860)
table.cell(table_id = pnlTable, column = 0, row = 2, bgcolor =kakupakat,
text_color = color.orange, text = 'PNL PROFIT %',text_size=font_sizePNL)
table.merge_cells(pnlTable, 0, 2, 3, 2)
BullColor_fibo = Bull_Color_fibo
BearColor_fibo = Bear_Color_fibo
Fib_x_fibo(n) =>
revfibs_fibo ? (Fhigh_fibo - Flow_fibo) * n + Flow_fibo : Fhigh_fibo - (Fhigh_fibo -
Flow_fibo) * n
Fib_line_fibo(x) =>
var line ln = na
line.delete(ln)
ln := line.new(BB_fibo, x, bar_index, x, color=close > x ? BullColor_fibo :
BearColor_fibo, extend=EXTEND_fibo, style=STYLE_fibo, width=WIDTH_fibo)
ln
Supertrend Indicator