// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.
0
at [Link]
// Join us [Link]
// =================================
//@version=5
//2024
strategy('MM ALGO PREMIUM', overlay=true)
var bool showtagstrategy = true
///////////////////////////////////////////////////////////////////////////////////
///////
//Main Algo Settings
colors = [Link](title='Color Scheme', defval='DARK', options=['DARK',
'LIGHT'] , group = "Color Scheme")
bullcolor = colors == 'DARK' ? #00DBFF : [Link](0, 255, 8)
bearcolor = colors == 'DARK' ? #E91E63 : [Link](255, 0, 0)
bullcolorlight = colors == 'DARK' ? #00DBFF80 : [Link](0, 255, 8,60)
bearcolorlight = colors == 'DARK' ? #E91E6380 : [Link](255, 0, 0,60)
Show_Signals = [Link](true, title="Show Signal", tooltip="Show Long & Short
Signals" , group = "Signal's Settings")
var int length = input(title='Period', defval=1 , group = "Signal's Settings")
var float mult = [Link](title='TBSensitivity', step=0.1, defval=15 , group =
"Signal's Settings") //default 10
var float SFilter = [Link](title='Signal Filter', step=0.1, defval=1.0 , group
= "Signal's Settings")
///////////////////////////////////////////////////////////////////////////////////
///////
t_type = [Link]("Scalping","Strategy",options =
["Default","Scalping","Intraday","Swing"] , group = "Signal's Settings")
if t_type == "Default"
length := length
mult := mult
SFilter := SFilter
if t_type == "Scalping"
length := 10
mult := 10
SFilter := 0.5
if t_type == "Intraday"
length := 2
mult := 15
SFilter := 0.5
if t_type == "Swing"
length := 10
mult := 5
SFilter := 1.2
///////////////////////////////////////////////////////////////////////////////////
///////
// Color Scheme
//Trend Cloud / Theme
ma2On = [Link](true, title="Vortex Cloud", group = "Cloud")
TBSENSIII = [Link](2, title="Vortex Cloud Sensitivity",group = "Cloud")
plotRibsw = input(title='Show Trend Ribbon', defval=true , inline = "RIBBON" ,
group = "Chart Features")
xfixtf = input(title='MTF', defval=false , inline = "RIBBON", group = "Chart
Features")
labelSwitch = input(title='Table', defval=false, inline = "RIBBON", group = "Chart
Features")
plotRibbonPos = [Link](title='Ribbon Position', options=['Top', 'Bottom'],
defval='Bottom', group = "Chart Features")
xtf = [Link](title='Select MTF Ribbon', defval='D', group = "Chart
Features")
//SMC
color CLEAR = [Link](0,0,0,100)
showSMC = [Link](true, 'Show Smart Money Concepts', tooltip='Show Market
Structure', group='Market Structure')
showSwing = [Link](false, 'Show Swing Points', tooltip='Show or hide HH, LH,
HL, LL' , group="Market Structure")
swingSize = [Link](10, 'Swing Length', 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="Market Structure")
bosConfType = [Link]('Candle Close', 'BOS/CHoCH Confirmation', ['Candle
Close', 'Wicks'], tooltip='Choose whether candle close/wick above previous swing
point counts as a BOS/CHoCH.' , group="Market Structure")
choch = true
bosStyle = [Link]('Solid', 'Line Style', ['Solid', 'Dashed', 'Dotted'],
group="Market Structure")
bosWidth = [Link](1, 'Width', minval=1, group="Market Structure")
Show_PR = [Link](true, title="Show Top/Bottom", tooltip="Show's Top/Bottem -
'Don't Buy' = Green/Blue Cross | 'Don't Sell' = Red/Pink Cross " , group = "Top /
Bottom")
TBSensi = [Link](5, title="Top/Bottom Sensitivity", tooltip="The Greater The
Value The Stronger The Top/Bottom" , group = "Top / Bottom")
///////////////////////////////////////////////////////////////////////////////////
///////
//colorSup = input(#00DBFF, "Support Color", group="SR")
//colorRes = input(#E91E63, "Resistance Color", group="SR")
//algo
atr = mult * [Link](length)
longStop = hl2 - atr * SFilter
longStopPrev = nz(longStop[1], longStop)
longStop := close[1] > longStopPrev ? [Link](longStop, longStopPrev) : longStop
shortStop = hl2 + atr * SFilter
shortStopPrev = nz(shortStop[1], shortStop)
shortStop := close[1] < shortStopPrev ? [Link](shortStop, shortStopPrev) :
shortStop
dir = 1
dir := nz(dir[1], dir)
dir := dir == -1 and close > shortStopPrev ? 1 : dir == 1 and close <
longStopPrev ? -1 : dir
longColor = [Link]
shortColor = [Link]
barcolor(dir == 1 ? bullcolor : bearcolor)
///Direccion entrada y salida long
bull = dir == 1 and dir[1] == -1 and Show_Signals ? longStop : na
bear = dir == -1 and dir[1] == 1 and Show_Signals ? shortStop : na
var int direction = 0
// Reglas de entrada y salida
// Trade Time
daysback = input(30, title='Backtest Days, For Defining Best TF, Max: 60 Days')
millisecondinxdays = 1000 * 60 * 60 * 24 * daysback
leftbar = timenow - time < millisecondinxdays
backtest = leftbar
dpa = 8
//
// Reglas de entrada y salida
if bull and backtest
[Link]('Buy', direction=[Link], comment='LONG')
direction := 1
if bear and backtest
[Link]('Sell', direction=[Link], comment='SHORT')
direction := -1
// Update dir when entering a position
y1 = low - ([Link](30) * 2.5)
y2 = high + ([Link](30) * 2.5)
buylabel = bull ? [Link](bar_index, y1, "BUY 🚀", xloc.bar_index, [Link],
bullcolor, label.style_label_up, [Link](0, 0, 0), [Link]) : na
selllabel = bear ? [Link](bar_index, y2, "SELL", xloc.bar_index, [Link],
bearcolor, label.style_label_down, [Link](255, 255, 255), [Link]) : na
///////////////////////////////////////////////////////////////////////////////////
//////
//SMC v2
///////////////////////////////////////////////////////////////////////////////////
//////
// Functions
lineStyle(x) =>
switch x
'Solid' => line.style_solid
'Dashed' => line.style_dashed
'Dotted' => line.style_dotted
// Calculations
//Finding high and low pivots
pivHi = [Link](high, swingSize, swingSize)
pivLo = [Link](low, swingSize, swingSize)
//Tracking the previous swing levels to determine hh lh hl ll
var float prevHigh = na
var float prevLow = na
var int prevHighIndex = na
var int prevLowIndex = na
//Tracking whether previous levels have been breached
var bool highActive = false
var bool lowActive = false
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
//Generating the breakout signals
bool highBroken = false
bool lowBroken = false
//Tracking prev breakout
var int prevBreakoutDir = 0
float highSrc = bosConfType == 'Candle Close' ? close : high
float lowSrc = bosConfType == 'Candle Close' ? close : low
if highSrc > prevHigh and highActive
highBroken := true
highActive := false
if lowSrc < prevLow and lowActive
lowBroken := true
lowActive := false
// Visual Output
//Swing level labels
if hh and showSwing
[Link](bar_index - swingSize, pivHi, 'HH', color=CLEAR,
style=label.style_label_down, textcolor=chart.fg_color)
if lh and showSwing
[Link](bar_index - swingSize, pivHi, 'LH', color=CLEAR,
style=label.style_label_down, textcolor=chart.fg_color)
if hl and showSwing
[Link](bar_index - swingSize, pivLo, 'HL', color=CLEAR,
style=label.style_label_up, textcolor=chart.fg_color)
if ll and showSwing
[Link](bar_index - swingSize, pivLo, 'LL', color=CLEAR,
style=label.style_label_up, textcolor=chart.fg_color)
//Generating the BOS/CHoCH Lines
if highBroken and showSMC
[Link](prevHighIndex, prevHigh, bar_index, prevHigh, color= bullcolor,
style=lineStyle(bosStyle), width=bosWidth)
[Link]([Link](bar_index - (bar_index - prevHighIndex) / 2), prevHigh,
prevBreakoutDir == -1 and choch ? 'CHoCH' : 'BOS', color=CLEAR,
textcolor=bullcolor, size=[Link])
prevBreakoutDir := 1
if lowBroken and showSMC
[Link](prevLowIndex, prevLow, bar_index, prevLow, color=bearcolor,
style=lineStyle(bosStyle), width=bosWidth)
[Link]([Link](bar_index - (bar_index - prevLowIndex) / 2), prevLow,
prevBreakoutDir == 1 and choch ? 'CHoCH' : 'BOS', color=CLEAR, textcolor=bearcolor,
style=label.style_label_up, size=[Link])
prevBreakoutDir := -1
///////////////////////////////////////////////////////////////////////////////////
/////////
//Trend Cloud
///////////////////////////////////////////////////////////////////////////////////
////////
length2 = 10*(TBSENSIII / 2)
source2 = close
aboveColor2 = [Link](70, 219, 255, 100)
belowColor2 = [Link](233, 30, 99, 100)
ma3On = true
length3 = 40*(TBSENSIII / 2)
source3 = close
aboveColor3 = [Link](70, 219, 255, 100)
belowColor3 = [Link](233, 30, 99, 100)
//Combined Moving Averages Calculations
sma2 = [Link](source2, length2)
ema2 = [Link](source2, length2)
wma2 = [Link](source2, length2)
vwma2 = [Link](source2, length2)
hma2 = [Link](source2, length2)
rma2 = [Link](source2, length2)
ma2 = (sma2 + ema2 + wma2 + vwma2 + hma2 + rma2) / 6
sma3 = [Link](source3, length3)
ema3 = [Link](source3, length3)
wma3 = [Link](source3, length3)
vwma3 = [Link](source3, length3)
hma3 = [Link](source3, length3)
rma3 = [Link](source3, length3)
ma3 = (sma3 + ema3 + wma3 + vwma3 + hma3 + rma3) / 6
//Volume Spike Signals
volumeMedian = [Link](volume, 10)
volumeBuy = false
highVolumeBuy = false
if volume > volumeMedian and volume < volumeMedian*2
volumeBuy := true
if volume > volumeMedian*2
highVolumeBuy := true
//Line & Cloud Colors
redCloud = false
greenCloud = false
if ma2 > ma3
greenCloud := true
else
redCloud := true
ma50 = plot(ma2On ? ma2 : na, title="Moving Average #2", color=greenCloud ?
aboveColor2 : belowColor2, style=plot.style_line, linewidth=1 , editable = false)
ma100 = plot(ma3On ? ma3 : na, title="Moving Average #3", color=greenCloud ?
aboveColor3 : belowColor3, style=plot.style_line, linewidth=1 , editable = false)
fill(ma50, ma100, color=greenCloud and highVolumeBuy ? [Link](bullcolor , 10) :
greenCloud and volumeBuy ? [Link](bullcolor , 50) : greenCloud ?
[Link](bullcolor , 80) : redCloud and highVolumeBuy ? [Link](bearcolor ,
10) : redCloud and volumeBuy ? [Link](bearcolor , 50) : redCloud ?
[Link](bearcolor , 80) : na)
/////////////////////////////////////////////////////////
// Trap Detector
////////////////////////////////////////////////////////
// Functions
wavetrend(src, chlLen, avgLen) =>
esa = [Link](src, chlLen)
d = [Link]([Link](src - esa), chlLen)
ci = (src - esa) / (0.015 * d)
wt1 = [Link](ci, avgLen)
wt2 = [Link](wt1, 3)
[wt1, wt2]
f_top_fractal(src) => src[4] < src[2] and src[3] < src[2] and src[2] > src[1] and
src[2] > src[0]
f_bot_fractal(src) => src[4] > src[2] and src[3] > src[2] and src[2] < src[1] and
src[2] < src[0]
f_fractalize (src) => f_top_fractal(src) ? 1 : f_bot_fractal(src) ? -1 : 0
f_findDivs(src, topLimit, botLimit) =>
fractalTop = f_fractalize(src) > 0 and src[2] >= topLimit ? src[2] : na
fractalBot = f_fractalize(src) < 0 and src[2] <= botLimit ? src[2] : na
highPrev = [Link](fractalTop, src[2], 0)[2]
highPrice = [Link](fractalTop, high[2], 0)[2]
lowPrev = [Link](fractalBot, src[2], 0)[2]
lowPrice = [Link](fractalBot, low[2], 0)[2]
bearSignal = fractalTop and high[1] > highPrice and src[1] < highPrev
bullSignal = fractalBot and low[1] < lowPrice and src[1] > lowPrev
[bearSignal, bullSignal]
// Get components
[wt1, wt2] = wavetrend(close, 5*TBSensi, 10*TBSensi)
[wtDivBear1, wtDivBull1] = f_findDivs(wt2, 15, -40)
[wtDivBear2, wtDivBull2] = f_findDivs(wt2, 45, -65)
wtDivBull = wtDivBull1 or wtDivBull2
wtDivBear = wtDivBear1 or wtDivBear2
plotshape([Link](wt1, wt2) and Show_PR and wt2 <= -53, "Don't Sell/Bottom" ,
[Link], [Link], color(bullcolor), size=[Link])
plotshape([Link](wt1, wt2) and Show_PR and wt2 >= 53, "Don't Buy/Top",
[Link], [Link], color(bearcolor), size=[Link])
tst(x)=> [Link](x)
var int dec = [Link]([Link]([Link]))-2
trc(number) =>
factor = [Link](10, dec)
int(number * factor) / factor
trc_(number) =>
factor = [Link](10, 0)
int(number * factor) / factor
xsrc = close
xprd1 = 12
xsrc2 = close
xprd2 = 26
xsmooth = 1
xPrice = [Link](xsrc, xsmooth)
FastMA = xfixtf ? [Link]([Link]([Link], xtf, [Link](xsrc,
xprd1)), xsmooth) : [Link](xPrice, xprd1)
xPrice2 = [Link](xsrc2, xsmooth)
SlowMA = xfixtf ? [Link]([Link]([Link], xtf, [Link](xsrc2,
xprd2)), xsmooth) : [Link](xPrice2, xprd2)
BullTribbon = FastMA > SlowMA
Tribbon = FastMA < SlowMA
//****************************************************************************//
// Define Color Zones
Green = BullTribbon and xPrice > FastMA // Buy
Blue = Tribbon and xPrice > FastMA and xPrice > SlowMA //Pre Buy 2 (Strong dip)
Consider adding long position
LBlue = Tribbon and xPrice > FastMA and xPrice < SlowMA //Pre Buy 1 (Weak Dip)
Red = Tribbon and xPrice < FastMA // Sell
Orange = BullTribbon and xPrice < FastMA and xPrice < SlowMA // Pre Sell 2 (Strong
Rally) Consider adding short position
Yellow = BullTribbon and xPrice < FastMA and xPrice > SlowMA // Pre Sell 1 (Weak
Rally)
//****************************************************************************//
// Define Buy and Sell condition
// This is only for thebasic usage of CDC Actionzone (EMA Crossover)
// ie. Buy on first green bar and sell on first red bar
buycond = Green and Green[1] == 0
sellcond = Red and Red[1] == 0
bullTribbonish = [Link](buycond) < [Link](sellcond)
Tribbonish = [Link](sellcond) < [Link](buycond)
bColor_BullTribbonTribbon = bullTribbonish ? bullcolor : Tribbonish ? bearcolor :
na
plotshape(plotRibsw ? plotRibbonPos == 'Top' ? close : na : na, style=[Link],
title='Buy/Sell Ribbon', location=[Link], color=bColor_BullTribbonTribbon ,
editable = false)
plotshape(plotRibsw ? plotRibbonPos == 'Bottom' ? close : na : na,
style=[Link], title='Buy/Sell Ribbon', location=[Link],
color=bColor_BullTribbonTribbon , editable = false)
len2 = 20 //input(20, minval=1, title="Smooth")
src = close
out = [Link](src, len2)
buy = Tribbonish[1] and buycond
sell = bullTribbonish[1] and sellcond
//****************************************************************************//
// Label
//labelstyle = label.style_label_lower_left
labelstyle = close > SlowMA ? label.style_label_down : label.style_label_up
labelyloc = close > SlowMA ? [Link] : [Link]
labeltcolor = buy ? [Link] : sell ? [Link] : close > close[1] ?
bullcolor : bearcolor
labelbgcolor = buy ? bullcolor : sell ? bearcolor : [Link]
labeltext = buy ? 'Long on next bar\n' : sell ? 'Short on next bar\n' : ' '
trendText = bullTribbonish ? 'Bullish' : Tribbonish ? 'Bearish' : 'Sideways'
l1 = [Link](bar_index, na, text=labeltext + [Link] + ' ' +
[Link](close) + ' ' + [Link] + '\n Currently in a ' + trendText + '
Trend \n', color=labelbgcolor, textcolor=labeltcolor, yloc=labelyloc,
style=labelstyle)
[Link](labelSwitch ? l1[1] : l1)
bool changeCond = na(direction) ? na : bull or bear
// Module - Signals - SL - TPS by @comgunner
//-----------------------------------------
//*********************************************************
//* Module *
//* Signals - SL - TPSEND *
//*********************************************************
// Cálculos
groupEnTpSl = "======= Module - Signals ======="
plot(na)
levels_tip = "Habilita etiquetas compra/venta /SL"
atrLen_tip = "Atr para el Calculo de Stoploss y TakeProfit"
atrRisk_tip = " ATR Risk Multiplier: Recommended 1.5 or 1.9 / Multiplicador de
Riesgo ATR: Recomendado 1.5 o 1.9"
tpLen_tip = "Distance in percentage between TakeProfits / Distancia en porcentaje
entre TakeProfits"
tpSL_tip = "Distance in percentage for SL / Distancia en porcentaje para SL"
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 = [Link](10, "Number of Take Profit Levels 💪", minval=1, maxval=10,tooltip
=numTP_tip ,group=groupEnTpSl)
PercentOrATR_tip="Select the calculation method for TakeProfits / Selecciona el
metodo de calculo para los TakeProfits"
var string PercentOrATR = [Link]("PREDICTUM", "Calculation method for
TakeProfit (% or ATR)", options=["ATR", "PERCENTAGE","PREDICTUM"], inline="TPS",
group=groupEnTpSl,tooltip=PercentOrATR_tip)
levels = input(title='Show Entry Labels/SL/TP /Mostrar Etiquetas de Entrada/SL/TP',
defval=true, group=groupEnTpSl, tooltip=levels_tip)
atrLen = [Link](10, "ATR Length TP / SL ", group=groupEnTpSl,
tooltip=atrLen_tip)
atrRisk = [Link](1.0, "ATR Risk TP / SL",
group=groupEnTpSl,tooltip=atrRisk_tip )
tpLen = [Link](2.0, "TP [%] 💪", step=0.1, group=groupEnTpSl,
tooltip=tpLen_tip)
tpLenpre_tip = "Initial TP for Predictum type calculation / TP inicial para el
cálculo del tipo Predictum"
tpLenpre = [Link](0.5, "TP Initial Predictum [%] 💪", minval=0.3, step=0.1,
group=groupEnTpSl, tooltip=tpLenpre_tip)
tpSL = [Link](5, "SL [%] ", step=0.1, group=groupEnTpSl, tooltip=tpSL_tip)
lvlLines = [Link](true, "Show TP/SL lines ? / Mostart Lineas TP/SL? ",
inline="levels2",group=groupEnTpSl)
linesStyle = [Link]("SOLID", "", ["SOLID", "DASHED", "DOTTED"],
inline="levels2",group=groupEnTpSl)
lvlDistance = [Link](1, "Distance / Distancia", 1,
inline="levels2",group=groupEnTpSl)
stylelvl = linesStyle == "SOLID" ? line.style_solid : linesStyle == "DASHED" ?
line.style_dashed : line.style_dotted
lvlLinesw = [Link](title=' TP/SL Line Thickness / Grosor de línea TP/SL',
defval=2, minval=1,inline="levels2",group=groupEnTpSl)
trigger = bull ? 1 : 0
atrBand = [Link](atrLen) * atrRisk
atrStop = trigger == 1 ? low - atrBand : high + atrBand
lastTrade(src) => [Link](changeCond, src, 0 )
//Nuevo, distancia de TP's
DistanceTp = close * tpLen / 100
Distance_CTp = trigger == 1 ? close - DistanceTp : close + DistanceTp
DistanceSL = close * tpSL / 100
Distance_CSL = trigger == 1 ? low - DistanceSL : high + DistanceSL
DistanceTppre = close * tpLenpre / 100
Distance_CTpre = trigger == 1 ? close - DistanceTppre : close + DistanceTppre
var float atrSL = na
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
//CONTADOR DE VELAS, APARTIR E LA ULTIMA ENTRADA trigger o changeCondPNL =
nz(alertLongPNL, false) != nz(alertShortPNL, false)
var int countOfCandles = 0
if trigger
countOfCandles := 0
else
countOfCandles := na(countOfCandles) ? 0 : countOfCandles + 1
//ENTRADA
entry = levels ? [Link](time, close, "ENTRY " + [Link](lastTrade(close),
"#.#####"), xloc.bar_time, [Link],[Link], label.style_label_left, #000000,
[Link]) : na
label.set_y(entry, lastTrade(close))
[Link](entry[1])
stop_y = lastTrade(atrSL)
lineEntry = levels and lvlLines ? [Link](bar_index - countOfCandles,
lastTrade(close), bar_index + lvlDistance ,lastTrade(close), xloc.bar_index,
[Link],[Link],stylelvl, width=lvlLinesw ) : na
[Link](lineEntry[1])
//STOPLOSS
stop = levels ? [Link](time, close, "STOP LOSS" + [Link](stop_y,
"#.#####"), xloc.bar_time, [Link], bearcolor, label.style_label_left,
[Link](255, 252, 252), [Link]) : na
label.set_y(stop, stop_y)
[Link](stop[1])
linestop = levels and lvlLines ? [Link](bar_index - countOfCandles,
lastTrade(atrSL), bar_index ,lastTrade(atrSL), xloc.bar_index, [Link],
bearcolor,stylelvl, width=lvlLinesw ) : na
[Link](linestop[1])
// Array para almacenar las etiquetas y líneas
var label[] tpLabels = array.new_label(0)
var line[] tpLines = array.new_line(0)
//################################################################
MovingTarget_tip = "Strategy to move StopLoss (BE), when it reaches a TP /
Estrategia para mover StopLoss (BE), cuando alcanza un TP "
showLabel_tip = "Show SIGNAL GENERATOR label / Mostrar etiqueta SIGNAL GENERATOR"
MovingTarget = [Link](1, title="Moving Target (BE)",
minval=1,group=groupEnTpSl,inline="SignalG",tooltip=MovingTarget_tip)
showLabel = input(false, title="Showlabel Signal
Generator",group=groupEnTpSl,inline="SignalG",tooltip=showLabel_tip)
tf = [Link]
miSimbolo = [Link]([Link])
//========================================================================
buy_label = ' =====SIGNAL GENERATOR======\n'
buy_label := buy_label + '=========KAKUPAKAT=========\n'
buy_label := buy_label + ' \n'
buy_label := buy_label + 'COIN 🪙 : ' + '' + [Link](miSimbolo)+ '\n'
buy_label := buy_label + 'TIMEFRAME ⏰ : ' + '' + [Link](tf)+ '\n'
buy_label := buy_label + ' \n'
buy_label := buy_label + 'Dir 🔃: ' + '' + (stop_y < lastTrade(close) ? 'LONG' :
'SHORT') + '\n'
buy_label := buy_label + 'Entry 🚀: ' + '' + [Link](lastTrade(close),
"#.#####") +'\n'
//*********************************************************
// Función para crear TP y líneas by CoMgUnNeR
// ¡Codigo mas simplificado da creditos al autor! me costo bastante.
//*********************************************************
// Función para crear TP y líneas
// Función para calcular potencias
pow(base, exponent) =>
var float result = 1.0
for i = 1 to exponent
result := result * base
result
var float[] tpValues = array.new_float(0)
// Función para crear TP y líneas
createTP(level) =>
if levels
var float tp_y = na
var string emoji = na
var color textColor = na
var color lineColor = na
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
emoji := level == numTP ? "🤲💎" : "💪"
textColor := #000000
lineColor := bullcolor
else
tp_y := (lastTrade(close) - lastTrade(atrStop)) * level +
lastTrade(close)
emoji := level == numTP ? "🤲💎" : "💪"
textColor := #000000
lineColor := bullcolor
tp = [Link](time, tp_y, "TP " + [Link](level) + " " + emoji + " "
+ [Link](tp_y, "#.#####"), xloc.bar_time, [Link], color=lineColor,
style=label.style_label_left, textcolor=textColor, size=[Link])
[Link](tpLabels, tp)
if lvlLines
tpLine = [Link](bar_index - countOfCandles, tp_y, bar_index +
lvlDistance, tp_y, xloc.bar_index, [Link], lineColor, stylelvl,
width=lvlLinesw)
[Link](tpLines, tpLine)
if [Link](tpLines) > numTP
[Link]([Link](tpLines, 0))
[Link](tpLines)
if [Link](tpLabels) > numTP
[Link]([Link](tpLabels, 0))
[Link](tpLabels)
tp_y
// Crear TP y líneas basado en el input del usuario
if (bar_index > 10) // Asegurarse de que hay suficientes barras para calcular
for i = 1 to numTP
createTP(i)
// Función para crear TP y líneas
createTP2(level_info) =>
if showLabel
var float tp_y2 = na
var string emoji = na
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
emoji := level_info == numTP ? "🤲💎" : "💪"
else
tp_y2 := (lastTrade(close) - lastTrade(atrStop)) * level_info +
lastTrade(close)
emoji := level_info == numTP ? "🤲💎" : "💪"
// Agregar el resultado al texto de la etiqueta
'TP ' + [Link](level_info) + ': ' + emoji + [Link](tp_y2,
"#.#####") + '\n'
if (bar_index > 10)
for i = 1 to numTP
// Llamar a la función y agregar el resultado a buy_label
buy_label := buy_label + createTP2(i)
buy_label := buy_label + 'StopLoss 🛑: ' + '' + [Link](stop_y, "#.#####") +'\
n'
buy_label := buy_label + ' \n'
buy_label := buy_label + '=====Strategy======\n'
buy_label := buy_label + ' \n'
buy_label := buy_label + 'Stop: Moving Target -\n'
buy_label := buy_label + ' Trigger: Target ' + [Link]((MovingTarget))+ '\n'
lab_buy = [Link](bar_index - 15, showLabel ? close : na, buy_label,
color=[Link]([Link], 40), textcolor=[Link],
style=label.style_label_down, yloc=[Link], textalign=text.align_left)
// Mueve la etiqueta fuera del gráfico cuando no se muestra
//label.set_x(lab_buy, bar_index - 500)
if not showLabel
[Link](lab_buy)
[Link](lab_buy[1])
//################################################################
//*********************************************************
// Función para crear TP y líneas by CoMgUnNeR
// ¡Codigo mas simplificado da creditos al autor! me costo bastante.
//################################################################
// Define variables for strategy exit
// Define variables for strategy exit
var int qty_percent = na
var int limit_price = na
var int exit_message = na
// Variable de script para qtytps
var int qtytps = na
// Calcular qtytps fuera de la función
qtytps := na(qtytps) ? (numTP == 1 ? 100 : 100 / (numTP - 1 + (numTP == 1 ? 1 :
0))) : qtytps
createTP3(level_stg) =>
if bar_index > 10
var float tp_y3 = na
var string emoji = na
if PercentOrATR == "PREDICTUM"
if level_stg == 1
tp_y3 := (lastTrade(close) - lastTrade(atrStop)) * level_stg +
lastTrade(close)
else
tp_y3 := tp_y3 + (tp_y3 - lastTrade(close)) * 0.618
emoji := level_stg == numTP ? "🤲💎" : "💪"
else
tp_y3 := (lastTrade(close) - lastTrade(atrStop)) * level_stg +
lastTrade(close)
emoji := level_stg == numTP ? "🤲💎" : "💪"
if showtagstrategy
[Link]('TP ' + [Link](level_stg), limit=tp_y3, comment='TP
' + [Link](level_stg) + ' Close: ' + [Link](close), alert_message='Take
Profit ' + [Link](level_stg), qty_percent=qtytps)
//[Link]('TP' + [Link](level_stg), 'Buy', qty_percent=qtytps,
limit=tp_y3)
// Usar la función sin verificar showLabel
for i = 1 to numTP
createTP3(i)
//
===================================================================================
=======
// === Dashboard with Telegram Link ===
var table myTable = [Link](position.top_center, 1, 1, border_width=1,
frame_color=[Link], bgcolor=[Link])
// Add Telegram Message to Dashboard
[Link](myTable, 0, 0, "Join Telegram @simpleforextools", bgcolor=[Link],
text_color=[Link], text_size=[Link])