Harmonic V9.2 - 2024 - Fixed + Filter
Harmonic V9.2 - 2024 - Fixed + Filter
///////////////////////////////////////////////////////////////////////////////////
///////
//Main Algo Settings
colors = input.string(title='Color Scheme', defval='DARK', options=['DARK',
'LIGHT'] , group = "Color Scheme")
bullcolor = colors == 'DARK' ? #00DBFF : color.rgb(0, 255, 8)
bearcolor = colors == 'DARK' ? #E91E63 : color.rgb(255, 0, 0)
bullcolorlight = colors == 'DARK' ? #00DBFF80 : color.rgb(0, 255, 8,60)
bearcolorlight = colors == 'DARK' ? #E91E6380 : color.rgb(255, 0, 0,60)
///////////////////////////////////////////////////////////////////////////////////
///////
t_type = input.string("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
//SMC
color CLEAR = color.rgb(0,0,0,100)
showSMC = input.bool(true, 'Show Smart Money Concepts', tooltip='Show Market
Structure', group='Market Structure')
showSwing = input.bool(false, 'Show Swing Points', tooltip='Show or hide HH, LH,
HL, LL' , group="Market Structure")
swingSize = input.int(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 = input.string('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 = input.string('Solid', 'Line Style', ['Solid', 'Dashed', 'Dotted'],
group="Market Structure")
bosWidth = input.int(1, 'Width', minval=1, group="Market Structure")
///////////////////////////////////////////////////////////////////////////////////
///////
longColor = color.blue
shortColor = color.blue
// 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
//
///////////////////////////////////////////////////////////////////////////////////
//////
//SMC v2
///////////////////////////////////////////////////////////////////////////////////
//////
// Functions
lineStyle(x) =>
switch x
'Solid' => line.style_solid
'Dashed' => line.style_dashed
'Dotted' => line.style_dotted
// 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
//Generating the breakout signals
bool highBroken = false
bool lowBroken = false
// Visual Output
///////////////////////////////////////////////////////////////////////////////////
/////////
//Trend Cloud
///////////////////////////////////////////////////////////////////////////////////
////////
length2 = 10*(TBSENSIII / 2)
source2 = close
aboveColor2 = color.rgb(70, 219, 255, 100)
belowColor2 = color.rgb(233, 30, 99, 100)
ma3On = true
length3 = 40*(TBSENSIII / 2)
source3 = close
aboveColor3 = color.rgb(70, 219, 255, 100)
belowColor3 = color.rgb(233, 30, 99, 100)
// 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(ta.crossover(wt1, wt2) and Show_PR and wt2 <= -53, "Don't Sell/Bottom" ,
shape.xcross, location.belowbar, color(bullcolor), size=size.tiny)
plotshape(ta.crossunder(wt1, wt2) and Show_PR and wt2 >= 53, "Don't Buy/Top",
shape.xcross, location.abovebar, color(bearcolor), size=size.tiny)
tst(x)=> str.tostring(x)
var int dec = str.length(str.tostring(syminfo.mintick))-2
trc(number) =>
factor = math.pow(10, dec)
int(number * factor) / factor
trc_(number) =>
factor = math.pow(10, 0)
int(number * factor) / factor
xsrc = close
xprd1 = 12
xsrc2 = close
xprd2 = 26
xsmooth = 1
//****************************************************************************//
// Define Color Zones
//****************************************************************************//
// 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
//****************************************************************************//
// Label
//labelstyle = label.style_label_lower_left
labelstyle = close > SlowMA ? label.style_label_down : label.style_label_up
labelyloc = close > SlowMA ? yloc.abovebar : yloc.belowbar
labeltcolor = buy ? color.gray : sell ? color.white : close > close[1] ?
bullcolor : bearcolor
labelbgcolor = buy ? bullcolor : sell ? bearcolor : color.silver
labeltext = buy ? 'Long on next bar\n' : sell ? 'Short on next bar\n' : ' '
trendText = bullTribbonish ? 'Bullish' : Tribbonish ? 'Bearish' : 'Sideways'
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)
trigger = bull ? 1 : 0
atrBand = ta.atr(atrLen) * atrRisk
atrStop = trigger == 1 ? low - atrBand : high + atrBand
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,color.gray, label.style_label_left, #000000,
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
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 = 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.