Explore //@version=5 indicator("SMC Lite + Masterpiece + Market Structure CHoCH/BOS",… Save Share Download ▾ Report//@version=5
indicator("SMC Lite + Masterpiece + Market Structure CHoCH/BOS", overlay=true, max_labels_count=500, max_boxes_count=500, max_lines_count=500, max_bars_back=1000)
// ========================================
// SMC Lite Settings
// ========================================
// INDICATOR SETTINGS
swing_length = input.int(10, title='Swing High/Low Length', group='SMC Lite Settings', minval=1, maxval=50)
history_of_demand_to_keep = input.int(20, title='History To Keep', group='SMC Lite Settings', minval=5, maxval=50)
box_width = input.float(2.5, title='Supply/Demand Box Width', group='SMC Lite Settings', minval=1, maxval=10, step=0.5)
// INDICATOR VISUAL SETTINGS
show_zigzag = input.bool(false, title='Show Zig Zag', group='SMC Lite Visual', inline='1')
show_price_action_labels = input.bool(false, title='Show Price Action Labels', group='SMC Lite Visual', inline='2')
supply_color = input.color(color.new(#EDEDED,70), title='Supply', group='SMC Lite Visual', inline='3')
supply_outline_color = input.color(color.new(color.white,75), title='Outline', group='SMC Lite Visual', inline='3')
demand_color = input.color(color.new(#00FFFF,70), title='Demand', group='SMC Lite Visual', inline='4')
demand_outline_color = input.color(color.new(color.white,75), title='Outline', group='SMC Lite Visual', inline='4')
poi_label_color = input.color(color.white, title='POI Label', group='SMC Lite Visual', inline='7')
swing_type_color = input.color(color.black, title='Price Action Label', group='SMC Lite Visual', inline='8')
zigzag_color = input.color(color.new(#000000,0), title='Zig Zag', group='SMC Lite Visual', inline='9')
// ========================================
// Masterpiece Indicator Settings
// ========================================
// Define Colors
GreenColorCandle = color.green
RedColorCandle = color.red
GreenColor = color.rgb(0, 128, 0)
RedColor = color.rgb(222, 23, 56)
GreenFluroscent = color.rgb(0, 255, 0)
RedFluroscent = color.rgb(255, 0, 0)
YellowFluroscent = color.rgb(255, 255, 0)
NotInterested = color.new(#ffffff, 90)
OverlayBarColor = input.bool(true, title='Overlay - Master Candle Color', group='Masterpiece Settings')
OverlayIndicator = input.bool(true, title='Overlay - MA20 and VWAP', group='Masterpiece Settings')
Overlay_Supertrend = input.bool(false, title='Overlay: Supertrend', group='Masterpiece Settings')
Overlay_HalfTrend = input.bool(false, title='Overlay: HalfTrend', group='Masterpiece Settings')
Overlay_Ichimoku_Cloud = input.bool(false, title='Overlay: Ichimoku Cloud', group='Masterpiece Settings')
Overlay_P_SAR = input.bool(false, title='Overlay: Parabolic SAR', group='Masterpiece Settings')
// Supertrend Settings
ST_AtrPeriod = input.int(10, 'ATR Length', minval=1, group='Supertrend')
ST_Factor = input.float(3.0, 'Factor', minval=0.01, step=0.01, group='Supertrend')
Show full message · 815 lines AssistantCopy response Mismatched input "end of line without line continuation" expecting ")"- line 2. The shorttitle is too long (25 characters). It should be 10 characters or less.(SHORT_TITLE_TOO_LONG) - line 4. fix these errors in Assisstant B.
AssistantCopy response Copy first prompt
Other models, same or similar prompt Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Details Provider DeepSeek
Model provenance As recorded by source dataset
Turns 2 (4 messages)
Language en
Added to archive Nov 19, 2026
ID 01m7tp8dzr6wwt3rkx9g92jrrkSource & license Imported from Arena Expert 5K (source ). Imported records earn no Research Points.
Upstream record: 63cbb3fd-ed6d-4e27-ba48-81ffd02e0561:a
LMArena, Arena Expert (2025). https://news.lmarena.ai/arena-expert/
License: Prompts CC-BY-4.0; outputs governed by provider terms
Dataset releases Not yet included in a published release.
// HalfTrend Settings
HT_Amplitude = input.int(2, title='Amplitude', group='HalfTrend')
HT_ChannelDeviation = input.int(2, title='Channel Deviation', group='HalfTrend')
// Ichimoku Cloud Settings
IC_ConversionPeriods = input.int(5, minval=1, title='Conversion Periods', group='Ichimoku Cloud')
IC_BasePeriods = input.int(26, minval=1, title='Base Periods', group='Ichimoku Cloud')
IC_LaggingSpan2Periods = input.int(52, minval=1, title='Lagging Span 2 Periods', group='Ichimoku Cloud')
IC_Displacement = input.int(26, minval=1, title='Displacement', group='Ichimoku Cloud')
// Parabolic SAR Settings
PS_Start = input.float(0.02, group='Parabolic SAR')
PS_Increment = input.float(0.02, group='Parabolic SAR')
PS_Maximum = input.float(0.2, 'Max Value', group='Parabolic SAR')
// ========================================
// Market Structure Settings
// ========================================
ms_length = input.int(5, minval = 3, title='Fractal Length', group='Market Structure')
//Colors
showBull = input(true, 'Bullish Structures', inline = 'bull', group = 'Market Structure Style')
bullCss = input.color(#089981, '', inline = 'bull', group = 'Market Structure Style')
showBear = input(true, 'Bearish Structures', inline = 'bear', group = 'Market Structure Style')
bearCss = input.color(#f23645, '', inline = 'bear', group = 'Market Structure Style')
showSupport = input(false, 'Support', inline = 's', group = 'Market Structure Style')
supCss = input.color(#089981, '', inline = 's', group = 'Market Structure Style')
showResistance = input(false, 'Resistance', inline = 'r', group = 'Market Structure Style')
resCss = input.color(#f23645, '', inline = 'r', group = 'Market Structure Style')
//Dashboard
showDash = input(false, 'Show Dashboard', group = 'Dashboard')
dashLoc = input.string('Top Right', 'Location', options = ['Top Right', 'Bottom Right', 'Bottom Left'], group = 'Dashboard')
textSize = input.string('Small', 'Size' , options = ['Tiny', 'Small', 'Normal'] , group = 'Dashboard')
// ========================================
// SMC Lite Functions
// ========================================
// FUNCTION TO ADD NEW AND REMOVE LAST IN ARRAY
f_array_add_pop(array_var, new_value_to_add) =>
array.unshift(array_var, new_value_to_add)
array.pop(array_var)
// FUNCTION SWING H & L LABELS
f_sh_sl_labels(array_var, swing_type) =>
var string label_text = na
if swing_type == 1
if array.get(array_var, 0) >= array.get(array_var, 1)
label_text := 'HH'
else
label_text := 'LH'
label.new(bar_index - swing_length, array.get(array_var,0), text=label_text, style=label.style_label_down, textcolor=swing_type_color, color=color.new(swing_type_color, 100), size=size.tiny)
code Copy code
else if swing_type == -1
if array.get(array_var, 0) >= array.get(array_var, 1)
label_text := 'HL'
else
label_text := 'LL'
label.new(bar_index - swing_length, array.get(array_var,0), text=label_text, style=label.style_label_up, textcolor=swing_type_color, color=color.new(swing_type_color, 100), size=size.tiny)
// FUNCTION MAKE SURE SUPPLY ISNT OVERLAPPING
f_check_overlapping(new_poi, box_array, atr) =>
atr_threshold = atr * 2
okay_to_draw = true
code Copy code
for i = 0 to array.size(box_array) - 1
if array.size(box_array) > i
top = box.get_top(array.get(box_array, i))
bottom = box.get_bottom(array.get(box_array, i))
poi = (top + bottom) / 2
upper_boundary = poi + atr_threshold
lower_boundary = poi - atr_threshold
if new_poi >= lower_boundary and new_poi <= upper_boundary
okay_to_draw := false
break
else
okay_to_draw := true
okay_to_draw
// FUNCTION TO DRAW SUPPLY OR DEMAND ZONE
f_supply_demand(value_array, bn_array, box_array, label_array, box_type, atr) =>
atr_buffer = atr * (box_width / 10)
box_left = array.get(bn_array, 0)
box_right = bar_index
code Copy code
var float box_top = 0.00
var float box_bottom = 0.00
var float poi = 0.00
if box_type == 1
box_top := array.get(value_array, 0)
box_bottom := box_top - atr_buffer
poi := (box_top + box_bottom) / 2
else if box_type == -1
box_bottom := array.get(value_array, 0)
box_top := box_bottom + atr_buffer
poi := (box_top + box_bottom) / 2
okay_to_draw = f_check_overlapping(poi, box_array, atr)
//delete oldest box, and then create a new box and add it to the array
if box_type == 1 and okay_to_draw
if array.size(box_array) > 0
box.delete(array.get(box_array, array.size(box_array) - 1))
f_array_add_pop(box_array, box.new(left=box_left, top=box_top, right=box_right, bottom=box_bottom, border_color=supply_outline_color,
bgcolor=supply_color, extend=extend.right, text='SUPPLY', text_halign=text.align_center, text_valign=text.align_center, text_color=poi_label_color, text_size=size.small, xloc=xloc.bar_index))
if array.size(label_array) > 0
box.delete(array.get(label_array, array.size(label_array) - 1))
f_array_add_pop(label_array, box.new(left=box_left, top=poi, right=box_right, bottom=poi, border_color=color.new(poi_label_color,90),
bgcolor=color.new(poi_label_color,90), extend=extend.right, text='POI', text_halign=text.align_left, text_valign=text.align_center, text_color=poi_label_color, text_size=size.small, xloc=xloc.bar_index))
else if box_type == -1 and okay_to_draw
if array.size(box_array) > 0
box.delete(array.get(box_array, array.size(box_array) - 1))
f_array_add_pop(box_array, box.new(left=box_left, top=box_top, right=box_right, bottom=box_bottom, border_color=demand_outline_color,
bgcolor=demand_color, extend=extend.right, text='DEMAND', text_halign=text.align_center, text_valign=text.align_center, text_color=poi_label_color, text_size=size.small, xloc=xloc.bar_index))
if array.size(label_array) > 0
box.delete(array.get(label_array, array.size(label_array) - 1))
f_array_add_pop(label_array, box.new(left=box_left, top=poi, right=box_right, bottom=poi, border_color=color.new(poi_label_color,90),
bgcolor=color.new(poi_label_color,90), extend=extend.right, text='POI', text_halign=text.align_left, text_valign=text.align_center, text_color=poi_label_color, text_size=size.small, xloc=xloc.bar_index))
// FUNCTION MANAGE CURRENT BOXES BY CHANGING ENDPOINT
f_extend_box_endpoint(box_array) =>
for i = 0 to array.size(box_array) - 1
box.set_right(array.get(box_array, i), bar_index + 100)
// ========================================
// Masterpiece Indicator Functions
// ========================================
// Function to Calculate Donchian Channel Average
donchian(len) =>
math.avg(ta.lowest(len), ta.highest(len))
// ========================================
// Market Structure Types
// ========================================
type fractal
float value
int loc
bool iscrossed
// ========================================
// Calculations
// ========================================
// SMC Lite Calculations
atr = ta.atr(50)
swing_high = ta.pivothigh(high, swing_length, swing_length)
swing_low = ta.pivotlow(low, swing_length, swing_length)
// Arrays for SMC Lite
var swing_high_values = array.new_float(5,0.00)
var swing_low_values = array.new_float(5,0.00)
var swing_high_bns = array.new_int(5,0)
var swing_low_bns = array.new_int(5,0)
var current_supply_box = array.new_box(history_of_demand_to_keep, na)
var current_demand_box = array.new_box(history_of_demand_to_keep, na)
var current_supply_poi = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi = array.new_box(history_of_demand_to_keep, na)
// Masterpiece Indicator Calculations
// Supertrend
[ST_Supertrend, ST_Direction] = ta.supertrend(ST_Factor, ST_AtrPeriod)
ST_Supertrend := barstate.isfirst ? na : ST_Supertrend
// HalfTrend
var int HT_Trend = 0
var int HT_NextTrend = 0
var float HT_MaxLowPrice = nz(low[1], low)
var float HT_MinHighPrice = nz(high[1], high)
var float HT_Up = 0.0
var float HT_Down = 0.0
float HT_AtrHigh = 0.0
float HT_AtrLow = 0.0
float HT_ArrowUp = na
float HT_ArrowDown = na
HT_Atr2 = ta.atr(100) / 2
HT_Dev = HT_ChannelDeviation * HT_Atr2
HT_HighPrice = high[math.abs(ta.highestbars(HT_Amplitude))]
HT_LowPrice = low[math.abs(ta.lowestbars(HT_Amplitude))]
HT_HighMa = ta.sma(high, HT_Amplitude)
HT_LowMa = ta.sma(low, HT_Amplitude)
if HT_NextTrend == 1
HT_MaxLowPrice := math.max(HT_LowPrice, HT_MaxLowPrice)
if HT_HighMa < HT_MaxLowPrice and close < nz(low[1], low)
HT_Trend := 1
HT_NextTrend := 0
HT_MinHighPrice := HT_HighPrice
else
HT_MinHighPrice := math.min(HT_HighPrice, HT_MinHighPrice)
if HT_LowMa > HT_MinHighPrice and close > nz(high[1], high)
HT_Trend := 0
HT_NextTrend := 1
HT_MaxLowPrice := HT_LowPrice
if HT_Trend == 0
if HT_Trend[1] != 0
HT_Up := nz(HT_Down[1], HT_Down)
HT_ArrowUp := HT_Up - HT_Atr2
else
HT_Up := math.max(HT_MaxLowPrice, nz(HT_Up[1], HT_MaxLowPrice))
HT_AtrHigh := HT_Up + HT_Dev
HT_AtrLow := HT_Up - HT_Dev
else
if HT_Trend[1] != 1
HT_Down := nz(HT_Up[1], HT_Up)
HT_ArrowDown := HT_Down + HT_Atr2
else
HT_Down := math.min(HT_MinHighPrice, nz(HT_Down[1], HT_MinHighPrice))
HT_AtrHigh := HT_Down + HT_Dev
HT_AtrLow := HT_Down - HT_Dev
HT_Ht = HT_Trend == 0 ? HT_Up : HT_Down
// Ichimoku Cloud
IC_ConversionLine = donchian(IC_ConversionPeriods)
IC_BaseLine = donchian(IC_BasePeriods)
kjuncol = IC_ConversionLine > IC_BaseLine ? color.green : IC_ConversionLine < IC_BaseLine ? color.red : color.orange
// Parabolic SAR
PS_Out = ta.sar(PS_Start, PS_Increment, PS_Maximum)
// Master Candle Calculations
MA20_bull = close > ta.ema(close, 20)
Supertrend_bull = close > ST_Supertrend
HalfTrend_bull = close > HT_Ht
Ichimoku_Cloud_bull = close > IC_ConversionLine and close > IC_BaseLine or IC_ConversionLine > IC_BaseLine
Parabolic_SAR_bull = close > PS_Out
Master_Candle_bull = (MA20_bull ? 1 : 0) + (Supertrend_bull ? 1 : 0) + (HalfTrend_bull ? 1 : 0) + (Ichimoku_Cloud_bull ? 1 : 0) + (Parabolic_SAR_bull ? 1 : 0)
MA20_bear = close < ta.ema(close, 20)
Supertrend_bear = close < ST_Supertrend
HalfTrend_bear = close < HT_Ht
Ichimoku_Cloud_bear = close < IC_ConversionLine and close < IC_BaseLine or IC_ConversionLine < IC_BaseLine
Parabolic_SAR_bear = close < PS_Out
Master_Candle_bear = (MA20_bear ? 1 : 0) + (Supertrend_bear ? 1 : 0) + (HalfTrend_bear ? 1 : 0) + (Ichimoku_Cloud_bear ? 1 : 0) + (Parabolic_SAR_bear ? 1 : 0)
Master_Candle_Scalp_bull = (Master_Candle_bull > Master_Candle_bear) and ((Master_Candle_bull > Master_Candle_bull[1]) or (Master_Candle_bear < Master_Candle_bear[1]) or Master_Candle_bear == 0)
Master_Candle_Scalp_bear = (Master_Candle_bear > Master_Candle_bull) and ((Master_Candle_bear > Master_Candle_bear[1]) or (Master_Candle_bull < Master_Candle_bull[1]) or Master_Candle_bull == 0)
// Set color conditions for plotting based on various indicators
NOC_MA20 = MA20_bull ? color.new(GreenFluroscent, 50) : MA20_bear ? color.new(RedFluroscent, 50) : NotInterested
NOC_Supertrend = Supertrend_bull ? color.new(GreenFluroscent, 50) : Supertrend_bear ? color.new(RedFluroscent, 50) : NotInterested
NOC_HalfTrend = HalfTrend_bull ? color.new(GreenFluroscent, 50) : HalfTrend_bear ? color.new(RedFluroscent, 50) : NotInterested
NOC_Ichimoku_Cloud = Ichimoku_Cloud_bull ? color.new(GreenFluroscent, 50) : Ichimoku_Cloud_bear ? color.new(RedFluroscent, 50) : NotInterested
NOC_P_SAR = Parabolic_SAR_bull ? color.new(GreenFluroscent, 50) : Parabolic_SAR_bear ? color.new(RedFluroscent, 50) : NotInterested
NOC_Master_Candle = Master_Candle_bull > Master_Candle_bear ? GreenFluroscent : Master_Candle_bear > Master_Candle_bull ? RedFluroscent : NotInterested
NOC_Master_Scalp_Candle = Master_Candle_Scalp_bull ? GreenFluroscent : Master_Candle_Scalp_bear ? RedFluroscent : NotInterested
// ========================================
// Market Structure Fractal Detection
// ========================================
var p = int(ms_length/2)
n = bar_index
dh = math.sum(math.sign(high - high[1]), p)
dl = math.sum(math.sign(low - low[1]), p)
bullf = dh == -p and dh[p] == p and high[p] == ta.highest(ms_length)
bearf = dl == p and dl[p] == -p and low[p] == ta.lowest(ms_length)
bullf_count = ta.cum(bullf ? 1 : 0)
bearf_count = ta.cum(bearf ? 1 : 0)
// ========================================
// Market Structure - Bullish
// ========================================
var upper = fractal.new()
var line lower_lvl = na
var label ms_lbl = na
var bull_ms_count = 0
var broken_sup = false
var os = 0
if bullf
upper.value := high[p]
upper.loc := n-p
upper.iscrossed := false
if ta.crossover(close, upper.value) and not upper.iscrossed
line.new(upper.loc, upper.value, n, upper.value, color = showBull ? bullCss : na)
code Copy code
ms_lbl := label.new(int(math.avg(n, upper.loc)), upper.value, os == -1 ? 'ChoCH' : 'BOS'
, color = color(na)
, textcolor = showBull ? bullCss : na
, style = label.style_label_down
, size = size.tiny)
//Set support
k = 2
min = low[1]
for i = 2 to (n - upper.loc)-1
min := math.min(low[i], min)
k := low[i] == min ? i : k
if showSupport
lower_lvl := line.new(n-k, min, n, min, color = bullCss, style = line.style_dashed)
broken_sup := false
upper.iscrossed := true
bull_ms_count += 1
os := 1
else if showSupport and not broken_sup
lower_lvl.set_x2(n)
code Copy code
if close < lower_lvl.get_y2()
broken_sup := true
// ========================================
// Market Structure - Bearish
// ========================================
var lower = fractal.new()
var line upper_lvl = na
var broken_res = false
var bear_ms_count = 0
if bearf
lower.value := low[p]
lower.loc := n-p
lower.iscrossed := false
if ta.crossunder(close, lower.value) and not lower.iscrossed
line.new(lower.loc, lower.value, n, lower.value, color = showBear ? bearCss : na)
code Copy code
label.new(int(math.avg(n, lower.loc)), lower.value, os == 1 ? 'ChoCH' : 'BOS'
, color = color(na)
, textcolor = showBear ? bearCss : na
, style = label.style_label_up
, size = size.tiny)
//Set resistance
k = 2
max = high[1]
for i = 2 to (n - lower.loc)-1
max := math.max(high[i], max)
k := high[i] == max ? i : k
if showResistance
upper_lvl := line.new(n-k, max, n, max, color = bearCss, style = line.style_dashed)
broken_res := false
lower.iscrossed := true
bear_ms_count += 1
os := -1
else if showResistance and not broken_res
upper_lvl.set_x2(n)
code Copy code
if close > upper_lvl.get_y2()
broken_res := true
// ========================================
// Plotting
// ========================================
// SMC Lite Plotting
if not na(swing_high)
// Manage swing high values
f_array_add_pop(swing_high_values, swing_high)
f_array_add_pop(swing_high_bns, bar_index[swing_length])
if show_price_action_labels
f_sh_sl_labels(swing_high_values, 1)
code Copy code
f_supply_demand(swing_high_values, swing_high_bns, current_supply_box, current_supply_poi, 1, atr)
else if not na(swing_low)
// Manage swing low values
f_array_add_pop(swing_low_values, swing_low)
f_array_add_pop(swing_low_bns, bar_index[swing_length])
if show_price_action_labels
f_sh_sl_labels(swing_low_values, -1)
code Copy code
f_supply_demand(swing_low_values, swing_low_bns, current_demand_box, current_demand_poi, -1, atr)
f_extend_box_endpoint(current_supply_box)
f_extend_box_endpoint(current_demand_box)
// SMC Lite Zig Zag
h = ta.highest(high, swing_length * 2 + 1)
l = ta.lowest(low, swing_length * 2 + 1)
f_isMin(len) =>
l == low[len]
f_isMax(len) =>
h == high[len]
var dirUp = false
var lastLow = high * 100
var lastHigh = 0.0
var timeLow = bar_index
var timeHigh = bar_index
var line li = na
f_drawLine() =>
_li_color = show_zigzag ? zigzag_color : color.new(#ffffff,100)
line.new(timeHigh - swing_length, lastHigh, timeLow - swing_length, lastLow, xloc.bar_index, color=_li_color, width=2)
if dirUp
if f_isMin(swing_length) and low[swing_length] < lastLow
lastLow := low[swing_length]
timeLow := bar_index
line.delete(li)
li := f_drawLine()
li
code Copy code
if f_isMax(swing_length) and high[swing_length] > lastLow
lastHigh := high[swing_length]
timeHigh := bar_index
dirUp := false
li := f_drawLine()
li
if not dirUp
if f_isMax(swing_length) and high[swing_length] > lastHigh
lastHigh := high[swing_length]
timeHigh := bar_index
line.delete(li)
li := f_drawLine()
li
if f_isMin(swing_length) and low[swing_length] < lastHigh
lastLow := low[swing_length]
timeLow := bar_index
dirUp := true
li := f_drawLine()
if f_isMax(swing_length) and high[swing_length] > lastLow
lastHigh := high[swing_length]
timeHigh := bar_index
dirUp := false
li := f_drawLine()
li
// Masterpiece Indicator Plotting
// Supertrend
plot(Overlay_Supertrend ? ST_Direction < 0 ? ST_Supertrend : na : na, 'Up Trend', color=color.green, style=plot.style_linebr, force_overlay=true)
plot(Overlay_Supertrend ? ST_Direction < 0 ? na : ST_Supertrend : na, title='Down Trend', color=RedColor, style=plot.style_linebr, force_overlay=true)
// HalfTrend
var color HT_BuyColor = color.blue
var color HT_SellColor = color.red
HT_HtColor = HT_Trend == 0 ? HT_BuyColor : HT_SellColor
plot(Overlay_HalfTrend ? HT_Ht : na, title='HalfTrend', linewidth=2, color=HT_HtColor, force_overlay=true)
plot(Overlay_HalfTrend ? HT_AtrHigh : na, title='ATR High', style=plot.style_circles, color=color.new(HT_SellColor, 0), force_overlay=true)
plot(Overlay_HalfTrend ? HT_AtrLow : na, title='ATR Low', style=plot.style_circles, color=color.new(HT_BuyColor, 0), force_overlay=true)
// Ichimoku Cloud
plot(Overlay_Ichimoku_Cloud ? IC_BaseLine : na, color=kjuncol, linewidth=2, title='Base Line', force_overlay=true)
// Parabolic SAR
plot(Overlay_P_SAR ? PS_Out : na, 'ParabolicSAR', style=plot.style_cross, color=#2962FF, force_overlay=true)
// Master Candle Plots
plotcandle(0, 20, 0, 20, color=NOC_Supertrend, bordercolor=NOC_Supertrend, wickcolor=NOC_Supertrend)
plotcandle(20, 40, 20, 40, color=NOC_HalfTrend, bordercolor=NOC_HalfTrend, wickcolor=NOC_HalfTrend)
plotcandle(40, 60, 40, 60, color=NOC_Ichimoku_Cloud, bordercolor=NOC_Ichimoku_Cloud, wickcolor=NOC_Ichimoku_Cloud)
plotcandle(60, 80, 60, 80, color=NOC_P_SAR, bordercolor=NOC_P_SAR, wickcolor=NOC_P_SAR)
plotcandle(90, 110, 90, 110, color=NOC_Master_Candle, bordercolor=NOC_Master_Candle, wickcolor=NOC_Master_Candle)
plotcandle(110, 130, 110, 130, color=NOC_Master_Scalp_Candle, bordercolor=NOC_Master_Scalp_Candle, wickcolor=NOC_Master_Scalp_Candle)
plotcandle(OverlayBarColor ? open : na, OverlayBarColor ? high : na, OverlayBarColor ? low : na, OverlayBarColor ? close : na, title='candles', color=NOC_Master_Candle, bordercolor=NOC_Master_Candle, wickcolor=NOC_Master_Candle, force_overlay=true)
plot(OverlayIndicator ? ta.vwap(hlc3) : na, color=#00a2ff, linewidth=2, force_overlay=true)
plot(OverlayIndicator ? ta.ema(close, 20) : na, color=color.rgb(255, 145, 0), linewidth=1, force_overlay=true)
// Add labels for each condition at the last bar
if barstate.islast
var Label_1 = label.new(na, na, style=label.style_label_left, textcolor=color.white, color=color.black, size=size.small)
label.set_xy(Label_1, bar_index + 1, 10)
label.set_text(Label_1, 'Supertrend')
code Copy code
var Label_2 = label.new(na, na, style=label.style_label_left, textcolor=color.white, color=color.black, size=size.small)
label.set_xy(Label_2, bar_index + 1, 30)
label.set_text(Label_2, 'HalfTrend')
var Label_3 = label.new(na, na, style=label.style_label_left, textcolor=color.white, color=color.black, size=size.small)
label.set_xy(Label_3, bar_index + 1, 50)
label.set_text(Label_3, 'Ichimoku Cloud')
var Label_4 = label.new(na, na, style=label.style_label_left, textcolor=color.white, color=color.black, size=size.small)
label.set_xy(Label_4, bar_index + 1, 70)
label.set_text(Label_4, 'Parabolic SAR')
var Label_5 = label.new(na, na, style=label.style_label_left, textcolor=color.white, color=color.black, size=size.small)
label.set_xy(Label_5, bar_index + 1, 100)
label.set_text(Label_5, 'Master Candle')
var Label_6 = label.new(na, na, style=label.style_label_left, textcolor=color.white, color=color.black, size=size.small)
label.set_xy(Label_6, bar_index + 1, 120)
label.set_text(Label_6, 'Scalping')
// ========================================
// Dashboard
// ========================================
var table_position = dashLoc == 'Bottom Left' ? position.bottom_left
: dashLoc == 'Top Right' ? position.top_right
: position.bottom_right
var table_size = textSize == 'Tiny' ? size.tiny
: textSize == 'Small' ? size.small
: size.normal
var tb = table.new(table_position, 2, 3
, bgcolor = #1e222d
, border_color = #373a46
, border_width = 1
, frame_color = #373a46
, frame_width = 1)
if showDash
if barstate.isfirst
tb.cell(0, 0, 'Structure To Fractal %', text_color = color.white, text_size = table_size)
tb.merge_cells(0,0,1,0)
code Copy code
tb.cell(0, 1, 'Bullish', text_color = #089981, text_size = table_size)
tb.cell(1, 1, 'Bearish', text_color = #f23645, text_size = table_size)
if barstate.islast
tb.cell(0, 2, str.tostring(bull_ms_count / bullf_count * 100, format.percent), text_color = #089981, text_size = table_size)
tb.cell(1, 2, str.tostring(bear_ms_count / bearf_count * 100, format.percent), text_color = #f23645, text_size = table_size)
// ========================================
// Market Structure Plots
// ========================================
plot(broken_res and not broken_res[1] ? low : na, 'Resistance Breakout', #089981, 2, plot.style_circles)
plot(broken_sup and not broken_sup[1] ? high : na, 'Support Breakout', #f23645, 2, plot.style_circles)
//@version=5
indicator("Integrated Auto Fibonacci & Golden Wave", shorttitle="Auto Fib + Golden Wave", overlay=true, max_boxes_count=500, max_labels_count=500, max_lines_count=500, max_bars_back=5000)
// ═══════════════════════════════════════════════════════════════════
// AUTO FIBONACCI RETRACEMENT SETTINGS
// ═══════════════════════════════════════════════════════════════════
G_AutoFibo = '██████ Auto Fibonacci Retracement ██████'
// Main Switch
AFBswitch = input.bool(true, title="Enable Auto Fibonacci", group=G_AutoFibo)
// Level Controls
FibHighLow = input.bool(false, title='Show High/Low Labels', group=G_AutoFibo, inline='AFB')
AFB0 = input.bool(false, title='Level 0%', group=G_AutoFibo, inline='AFB')
AFB1 = input.bool(false, title='Level 23.6%', group=G_AutoFibo, inline='AFB1')
AFB2 = input.bool(true, title='Level 38.2%', group=G_AutoFibo, inline='AFB1')
AFB3 = input.bool(true, title='Level 50%', group=G_AutoFibo, inline='AFB1')
AFB4 = input.bool(true, title='Level 61.8%', group=G_AutoFibo, inline='AFB2')
AFB5 = input.bool(false, title='Level 78.6%', group=G_AutoFibo, inline='AFB2')
AFB6 = input.bool(false, title='Level 100%', group=G_AutoFibo, inline='AFB2')
// Period Input
FPeriod = input.int(100, title='Lookback Period', minval=10, maxval=500, group=G_AutoFibo)
// Color and Style Inputs
F0color = input.color(#ff0000, title="0% Level Color", group=G_AutoFibo, inline="colors1")
F236color = input.color(#aacf92, title="23.6% Level Color", group=G_AutoFibo, inline="colors1")
F382color = input.color(#aacf92, title="38.2% Level Color", group=G_AutoFibo, inline="colors2")
F500color = input.color(#aacf92, title="50% Level Color", group=G_AutoFibo, inline="colors2")
F618color = input.color(#5a9afb, title="61.8% Level Color", group=G_AutoFibo, inline="colors3")
F786color = input.color(#aacf92, title="78.6% Level Color", group=G_AutoFibo, inline="colors3")
F1000color = input.color(#00ff0d, title="100% Level Color", group=G_AutoFibo, inline="colors4")
HighLowColor = input.color(#ff6600, title="High/Low Color", group=G_AutoFibo, inline="colors4")
// Line Style Settings
G_LineStyle = '██████ Line Styles ██████'
F0style = input.string("Solid", title="0% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style1")
F236style = input.string("Solid", title="23.6% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style1")
F382style = input.string("Solid", title="38.2% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style2")
F500style = input.string("Solid", title="50% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style2")
F618style = input.string("Solid", title="61.8% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style3")
F786style = input.string("Solid", title="78.6% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style3")
F1000style = input.string("Solid", title="100% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style4")
// Line Thickness Settings
G_LineThickness = '██████ Line Thickness ██████'
F0thickness = input.int(2, title="0% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick1")
F236thickness = input.int(1, title="23.6% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick1")
F382thickness = input.int(1, title="38.2% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick2")
F500thickness = input.int(2, title="50% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick2")
F618thickness = input.int(2, title="61.8% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick3")
F786thickness = input.int(1, title="78.6% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick3")
F1000thickness = input.int(2, title="100% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick4")
// ═══════════════════════════════════════════════════════════════════
// FIBONACCI GOLDEN WAVE SETTINGS
// ═══════════════════════════════════════════════════════════════════
G_GoldenWave = '██████ Fibonacci Golden Wave ██████'
// Golden Wave Settings
enableGoldenWave = input.bool(true, "Enable Golden Wave", group=G_GoldenWave)
pivotRange = input.int(20, "Swing Range", group=G_GoldenWave)
fibArea1 = input.float(0.5, "Golden Zone Level 1", options=[0.236, 0.382, 0.5, 0.618, 0.786], group=G_GoldenWave, inline="zone")
fibArea2 = input.float(0.618, "Golden Zone Level 2", options=[0.236, 0.382, 0.5, 0.618, 0.786], group=G_GoldenWave, inline="zone")
gzLineColor = input.color(color.new(color.yellow, 60), "Golden Zone Lines", group=G_GoldenWave)
showArea = input.bool(true, "Show Golden Zone Area", group=G_GoldenWave, inline="gzarea")
gzAreaColor = input.color(color.new(color.yellow, 90), "", group=G_GoldenWave, inline="gzarea")
textSize = input.string("Normal", "Text Size", options=["Auto", "Small", "Normal"], group=G_GoldenWave, inline="text")
textColor = input.color(color.new(color.white, 30), "", group=G_GoldenWave, inline="text")
// ═══════════════════════════════════════════════════════════════════
// HELPER FUNCTIONS
// ═══════════════════════════════════════════════════════════════════
// ═══════════════════════════════════════════════════════════════════
// AUTO FIBONACCI CALCULATIONS
// ═══════════════════════════════════════════════════════════════════
// Function to convert style string to Pine Script style
getLineStyle(styleStr) =>
switch styleStr
"Dashed" => plot.style_linebr
"Dotted" => plot.style_stepline
=> plot.style_line
// Calculate highest and lowest values within the period
Fhigh = ta.highest(high, FPeriod)
Flow = ta.lowest(low, FPeriod)
// Get the bar index of highest and lowest points
FH = ta.highestbars(high, FPeriod)
FL = ta.lowestbars(low, FPeriod)
// Determine trend direction (true = uptrend, false = downtrend)
AutoFibo = FH > FL
// Calculate Fibonacci levels based on trend direction
F0 = AutoFibo ? Fhigh : Flow
F236 = AutoFibo ? Fhigh - (Fhigh - Flow) * 0.236 : Flow + (Fhigh - Flow) * 0.236
F382 = AutoFibo ? Fhigh - (Fhigh - Flow) * 0.382 : Flow + (Fhigh - Flow) * 0.382
F500 = AutoFibo ? Fhigh - (Fhigh - Flow) * 0.500 : Flow + (Fhigh - Flow) * 0.500
F618 = AutoFibo ? Fhigh - (Fhigh - Flow) * 0.618 : Flow + (Fhigh - Flow) * 0.618
F786 = AutoFibo ? Fhigh - (Fhigh - Flow) * 0.786 : Flow + (Fhigh - Flow) * 0.786
F1000 = AutoFibo ? Flow : Fhigh
// ═══════════════════════════════════════════════════════════════════
// GOLDEN WAVE CALCULATIONS
// ═══════════════════════════════════════════════════════════════════
// Simple approach using highest/lowest for Golden Wave
gwHigh = ta.highest(high, pivotRange)
gwLow = ta.lowest(low, pivotRange)
// Calculate Golden Wave Fibonacci levels
gwRange = gwHigh - gwLow
gwFib1 = gwHigh - (gwRange * fibArea1)
gwFib2 = gwHigh - (gwRange * fibArea2)
// Ensure correct order (fib05 should be higher than fib061 for proper fill)
fib05 = math.max(gwFib1, gwFib2)
fib061 = math.min(gwFib1, gwFib2)
// ═══════════════════════════════════════════════════════════════════
// PLOTTING AUTO FIBONACCI LEVELS
// ═══════════════════════════════════════════════════════════════════
// Plot Fibonacci levels with custom colors, thickness, and styles
plot(AFB0 and AFBswitch ? F0 : na,
color=F0color, linewidth=F0thickness, style=getLineStyle(F0style), trackprice=true, show_last=1, title='Auto Fib 0%')
plot(AFB1 and AFBswitch ? F236 : na,
color=F236color, linewidth=F236thickness, style=getLineStyle(F236style), trackprice=true, show_last=1, title='Auto Fib 23.6%')
plot(AFB2 and AFBswitch ? F382 : na,
color=F382color, linewidth=F382thickness, style=getLineStyle(F382style), trackprice=true, show_last=1, title='Auto Fib 38.2%')
plot(AFB3 and AFBswitch ? F500 : na,
color=F500color, linewidth=F500thickness, style=getLineStyle(F500style), trackprice=true, show_last=1, title='Auto Fib 50%')
plot(AFB4 and AFBswitch ? F618 : na,
color=F618color, linewidth=F618thickness, style=getLineStyle(F618style), trackprice=true, show_last=1, title='Auto Fib 61.8%')
plot(AFB5 and AFBswitch ? F786 : na,
color=F786color, linewidth=F786thickness, style=getLineStyle(F786style), trackprice=true, show_last=1, title='Auto Fib 78.6%')
plot(AFB6 and AFBswitch ? F1000 : na,
color=F1000color, linewidth=F1000thickness, style=getLineStyle(F1000style), trackprice=true, show_last=1, title='Auto Fib 100%')
// Plot level labels for Auto Fibonacci with matching colors
plotshape(AFB0 and AFBswitch ? F0 : na,
style=shape.diamond, location=location.absolute, color=color.new(color.white, 100),
textcolor=color.new(F0color, 20), show_last=1, text='0%', offset=15)
plotshape(AFB1 and AFBswitch ? F236 : na,
style=shape.diamond, location=location.absolute, color=color.new(color.white, 100),
textcolor=color.new(F236color, 20), show_last=1, text='23.6%', offset=15)
plotshape(AFB2 and AFBswitch ? F382 : na,
style=shape.diamond, location=location.absolute, color=color.new(color.white, 100),
textcolor=color.new(F382color, 20), show_last=1, text='38.2%', offset=15)
plotshape(AFB3 and AFBswitch ? F500 : na,
style=shape.diamond, location=location.absolute, color=color.new(color.white, 100),
textcolor=color.new(F500color, 20), show_last=1, text='50%', offset=15)
plotshape(AFB4 and AFBswitch ? F618 : na,
style=shape.diamond, location=location.absolute, color=color.new(color.white, 100),
textcolor=color.new(F618color, 20), show_last=1, text='61.8%', offset=15)
plotshape(AFB5 and AFBswitch ? F786 : na,
style=shape.diamond, location=location.absolute, color=color.new(color.white, 100),
textcolor=color.new(F786color, 20), show_last=1, text='78.6%', offset=15)
plotshape(AFB6 and AFBswitch ? F1000 : na,
style=shape.diamond, location=location.absolute, color=color.new(color.white, 100),
textcolor=color.new(F1000color, 20), show_last=1, text='100%', offset=15)
// Plot high and low markers
plotshape(FibHighLow and AFBswitch ? Flow : na,
style=shape.labelup, location=location.absolute, size=size.small,
color=HighLowColor, textcolor=color.black, show_last=1, text='Low', offset=FL)
plotshape(FibHighLow and AFBswitch ? Fhigh : na,
style=shape.labeldown, location=location.absolute, size=size.small,
color=HighLowColor, textcolor=color.black, show_last=1, text='High', offset=FH)
// ═══════════════════════════════════════════════════════════════════
// PLOTTING GOLDEN WAVE
// ═══════════════════════════════════════════════════════════════════
// Plot Golden Wave levels
line05 = plot(enableGoldenWave ? fib05 : na, color=gzLineColor, linewidth=2, style=plot.style_line, title="Golden Zone Upper")
line061 = plot(enableGoldenWave ? fib061 : na, color=gzLineColor, linewidth=2, style=plot.style_line, title="Golden Zone Lower")
// Fill the golden zone area
fill(line05, line061, color=enableGoldenWave and showArea ? gzAreaColor : na, title="Golden Zone Area")
// ═══════════════════════════════════════════════════════════════════
// INFO TABLE
// ═══════════════════════════════════════════════════════════════════
// Add trend direction indicator in top-right corner
var table infoTable = table.new(position.top_right, 2, 3, bgcolor=color.new(color.white, 80), border_width=1)
if barstate.islast and (AFBswitch or enableGoldenWave)
table.cell(infoTable, 0, 0, "Auto Fib Direction", text_color=color.black, text_size=size.small)
table.cell(infoTable, 1, 0, AutoFibo ? "↓ Retracement" : "↑ Extension",
text_color=AutoFibo ? color.red : color.green, text_size=size.small)
code Copy code
table.cell(infoTable, 0, 1, "Golden Zone", text_color=color.black, text_size=size.small)
table.cell(infoTable, 1, 1, str.tostring(fibArea1 * 100, "#.#") + "% - " + str.tostring(fibArea2 * 100, "#.#") + "%",
text_color=color.new(color.orange, 0), text_size=size.small)
table.cell(infoTable, 0, 2, "Lookback", text_color=color.black, text_size=size.small)
table.cell(infoTable, 1, 2, "AF: " + str.tostring(FPeriod) + " | GW: " + str.tostring(pivotRange),
text_color=color.blue, text_size=size.small)
// ═══════════════════════════════════════════════════════════════════
// ALERTS
// ═══════════════════════════════════════════════════════════════════
// Alert conditions for when price enters golden zone
goldenZoneEntry = enableGoldenWave and not na(fib05) and not na(fib061) and
close >= fib061 and close <= fib05 and
(close[1] < fib061 or close[1] > fib05)
alertcondition(goldenZoneEntry, title="Golden Zone Entry", message="Price has entered the Fibonacci Golden Zone")
// Alert for Auto Fibonacci level touches
fib618Touch = AFB4 and AFBswitch and (ta.crossover(close, F618) or ta.crossunder(close, F618))
alertcondition(fib618Touch, title="Auto Fib 61.8% Touch", message="Price touched the Auto Fibonacci 61.8% level")
Integrate these two indicators and make an error free 100% working pinescript codes in version 6.
Here's the integrated and error-free Pine Script v6 code combining both indicators:
pinescript Copy code
//@version=6
indicator("SMC Lite + Masterpiece + Market Structure + Auto Fibonacci", overlay=true, max_labels_count=500, max_boxes_count=500, max_lines_count=500, max_bars_back=5000)
// ========================================
// SMC Lite Settings
// ========================================
// INDICATOR SETTINGS
swing_length = input.int(10, title='Swing High/Low Length', group='SMC Lite Settings', minval=1, maxval=50)
history_of_demand_to_keep = input.int(20, title='History To Keep', group='SMC Lite Settings', minval=5, maxval=50)
box_width = input.float(2.5, title='Supply/Demand Box Width', group='SMC Lite Settings', minval=1, maxval=10, step=0.5)
// INDICATOR VISUAL SETTINGS
show_zigzag = input.bool(false, title='Show Zig Zag', group='SMC Lite Visual', inline='1')
show_price_action_labels = input.bool(false, title='Show Price Action Labels', group='SMC Lite Visual', inline='2')
supply_color = input.color(color.new(#EDEDED,70), title='Supply', group='SMC Lite Visual', inline='3')
supply_outline_color = input.color(color.new(color.white,75), title='Outline', group='SMC Lite Visual', inline='3')
demand_color = input.color(color.new(#00FFFF,70), title='Demand', group='SMC Lite Visual', inline='4')
demand_outline_color = input.color(color.new(color.white,75), title='Outline', group='SMC Lite Visual', inline='4')
poi_label_color = input.color(color.white, title='POI Label', group='SMC Lite Visual', inline='7')
swing_type_color = input.color(color.black, title='Price Action Label', group='SMC Lite Visual', inline='8')
zigzag_color = input.color(color.new(#000000,0), title='Zig Zag', group='SMC Lite Visual', inline='9')
// ========================================
// Masterpiece Indicator Settings
// ========================================
// Define Colors
GreenColorCandle = color.green
RedColorCandle = color.red
GreenColor = color.rgb(0, 128, 0)
RedColor = color.rgb(222, 23, 56)
GreenFluroscent = color.rgb(0, 255, 0)
RedFluroscent = color.rgb(255, 0, 0)
YellowFluroscent = color.rgb(255, 255, 0)
NotInterested = color.new(#ffffff, 90)
OverlayBarColor = input.bool(true, title='Overlay - Master Candle Color', group='Masterpiece Settings')
OverlayIndicator = input.bool(true, title='Overlay - MA20 and VWAP', group='Masterpiece Settings')
Overlay_Supertrend = input.bool(false, title='Overlay: Supertrend', group='Masterpiece Settings')
Overlay_HalfTrend = input.bool(false, title='Overlay: HalfTrend', group='Masterpiece Settings')
Overlay_Ichimoku_Cloud = input.bool(false, title='Overlay: Ichimoku Cloud', group='Masterpiece Settings')
Overlay_P_SAR = input.bool(false, title='Overlay: Parabolic SAR', group='Masterpiece Settings')
// Supertrend Settings
ST_AtrPeriod = input.int(10, 'ATR Length', minval=1, group='Supertrend')
ST_Factor = input.float(3.0, 'Factor', minval=0.01, step=0.01, group='Supertrend')
// HalfTrend Settings
HT_Amplitude = input.int(2, title='Amplitude', group='HalfTrend')
HT_ChannelDeviation = input.int(2, title='Channel Deviation', group='HalfTrend')
// Ichimoku Cloud Settings
IC_ConversionPeriods = input.int(5, minval=1, title='Conversion Periods', group='Ichimoku Cloud')
IC_BasePeriods = input.int(26, minval=1, title='Base Periods', group='Ichimoku Cloud')
IC_LaggingSpan2Periods = input.int(52, minval=1, title='Lagging Span 2 Periods', group='Ichimoku Cloud')
IC_Displacement = input.int(26, minval=1, title='Displacement', group='Ichimoku Cloud')
// Parabolic SAR Settings
PS_Start = input.float(0.02, group='Parabolic SAR')
PS_Increment = input.float(0.02, group='Parabolic SAR')
PS_Maximum = input.float(0.2, 'Max Value', group='Parabolic SAR')
// ========================================
// Market Structure Settings
// ========================================
ms_length = input.int(5, minval = 3, title='Fractal Length', group='Market Structure')
//Colors
showBull = input(true, 'Bullish Structures', inline = 'bull', group = 'Market Structure Style')
bullCss = input.color(#089981, '', inline = 'bull', group = 'Market Structure Style')
showBear = input(true, 'Bearish Structures', inline = 'bear', group = 'Market Structure Style')
bearCss = input.color(#f23645, '', inline = 'bear', group = 'Market Structure Style')
showSupport = input(false, 'Support', inline = 's', group = 'Market Structure Style')
supCss = input.color(#089981, '', inline = 's', group = 'Market Structure Style')
showResistance = input(false, 'Resistance', inline = 'r', group = 'Market Structure Style')
resCss = input.color(#f23645, '', inline = 'r', group = 'Market Structure Style')
//Dashboard
showDash = input(false, 'Show Dashboard', group = 'Dashboard')
dashLoc = input.string('Top Right', 'Location', options = ['Top Right', 'Bottom Right', 'Bottom Left'], group = 'Dashboard')
textSize = input.string('Small', 'Size' , options = ['Tiny', 'Small', 'Normal'] , group = 'Dashboard')
// ========================================
// Auto Fibonacci Settings
// ========================================
G_AutoFibo = '██████ Auto Fibonacci Retracement ██████'
// Main Switch
AFBswitch = input.bool(true, title="Enable Auto Fibonacci", group=G_AutoFibo)
// Level Controls
FibHighLow = input.bool(false, title='Show High/Low Labels', group=G_AutoFibo, inline='AFB')
AFB0 = input.bool(false, title='Level 0%', group=G_AutoFibo, inline='AFB')
AFB1 = input.bool(false, title='Level 23.6%', group=G_AutoFibo, inline='AFB1')
AFB2 = input.bool(true, title='Level 38.2%', group=G_AutoFibo, inline='AFB1')
AFB3 = input.bool(true, title='Level 50%', group=G_AutoFibo, inline='AFB1')
AFB4 = input.bool(true, title='Level 61.8%', group=G_AutoFibo, inline='AFB2')
AFB5 = input.bool(false, title='Level 78.6%', group=G_AutoFibo, inline='AFB2')
AFB6 = input.bool(false, title='Level 100%', group=G_AutoFibo, inline='AFB2')
// Period Input
FPeriod = input.int(100, title='Lookback Period', minval=10, maxval=500, group=G_AutoFibo)
// Color and Style Inputs
F0color = input.color(#ff0000, title="0% Level Color", group=G_AutoFibo, inline="colors1")
F236color = input.color(#aacf92, title="23.6% Level Color", group=G_AutoFibo, inline="colors1")
F382color = input.color(#aacf92, title="38.2% Level Color", group=G_AutoFibo, inline="colors2")
F500color = input.color(#aacf92, title="50% Level Color", group=G_AutoFibo, inline="colors2")
F618color = input.color(#5a9afb, title="61.8% Level Color", group=G_AutoFibo, inline="colors3")
F786color = input.color(#aacf92, title="78.6% Level Color", group=G_AutoFibo, inline="colors3")
F1000color = input.color(#00ff0d, title="100% Level Color", group=G_AutoFibo, inline="colors4")
HighLowColor = input.color(#ff6600, title="High/Low Color", group=G_AutoFibo, inline="colors4")
// Line Style Settings
G_LineStyle = '██████ Line Styles ██████'
F0style = input.string("Solid", title="0% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style1")
F236style = input.string("Solid", title="23.6% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style1")
F382style = input.string("Solid", title="38.2% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style2")
F500style = input.string("Solid", title="50% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style2")
F618style = input.string("Solid", title="61.8% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style3")
F786style = input.string("Solid", title="78.6% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style3")
F1000style = input.string("Solid", title="100% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style4")
// Line Thickness Settings
G_LineThickness = '██████ Line Thickness ██████'
F0thickness = input.int(2, title="0% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick1")
F236thickness = input.int(1, title="23.6% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick1")
F382thickness = input.int(1, title="38.2% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick2")
F500thickness = input.int(2, title="50% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick2")
F618thickness = input.int(2, title="61.8% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick3")
F786thickness = input.int(1, title="78.6% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick3")
F1000thickness = input.int(2, title="100% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick4")
// ========================================
// Fibonacci Golden Wave Settings
// ========================================
G_GoldenWave = '██████ Fibonacci Golden Wave ██████'
// Golden Wave Settings
enableGoldenWave = input.bool(true, "Enable Golden Wave", group=G_GoldenWave)
pivotRange = input.int(20, "Swing Range", group=G_GoldenWave)
fibArea1 = input.float(0.5, "Golden Zone Level 1", options=[0.236, 0.382, 0.5, 0.618, 0.786], group=G_GoldenWave, inline="zone")
fibArea2 = input.float(0.618, "Golden Zone Level 2", options=[0.236, 0.382, 0.5, 0.618, 0.786], group=G_GoldenWave, inline="zone")
gzLineColor = input.color(color.new(color.yellow, 60), "Golden Zone Lines", group=G_GoldenWave)
showArea = input.bool(true, "Show Golden Zone Area", group=G_GoldenWave, inline="gzarea")
gzAreaColor = input.color(color.new(color.yellow, 90), "", group=G_GoldenWave, inline="gzarea")
textSizeGW = input.string("Normal", "Text Size", options=["Auto", "Small", "Normal"], group=G_GoldenWave, inline="text")
textColor = input.color(color.new(color.white, 30), "", group=G_GoldenWave, inline="text")
// ========================================
// SMC Lite Functions
// ========================================
// FUNCTION TO ADD NEW AND REMOVE LAST IN ARRAY
f_array_add_pop(array_var, new_value_to_add) =>
array.unshift(array_var, new_value_to_add)
array.pop(array_var)
// FUNCTION SWING H & L LABELS
f_sh_sl_labels(array_var, swing_type) =>
var string label_text = na
if swing_type == 1
if array.get(array_var, 0) >= array.get(array_var, 1)
label_text := 'HH'
else
label_text := 'LH'
label.new(bar_index - swing_length, array.get(array_var,0), text=label_text, style=label.style_label_down, textcolor=swing_type_color, color=color.new(swing_type_color, 100), size=size.tiny)
else if swing_type == -1
if array.get(array_var, 0) >= array.get(array_var, 1)
label_text := 'HL'
else
label_text := 'LL'
label.new(bar_index - swing_length, array.get(array_var,0), text=label_text, style=label.style_label_up, textcolor=swing_type_color, color=color.new(swing_type_color, 100), size=size.tiny)
// FUNCTION MAKE SURE SUPPLY ISNT OVERLAPPING
f_check_overlapping(new_poi, box_array, atr) =>
atr_threshold = atr * 2
okay_to_draw = true
for i = 0 to array.size(box_array) - 1
if array.size(box_array) > i
top = box.get_top(array.get(box_array, i))
bottom = box.get_bottom(array.get(box_array, i))
poi = (top + bottom) / 2
upper_boundary = poi + atr_threshold
lower_boundary = poi - atr_threshold
if new_poi >= lower_boundary and new_poi <= upper_boundary
okay_to_draw := false
break
else
okay_to_draw := true
okay_to_draw
// FUNCTION TO DRAW SUPPLY OR DEMAND ZONE
f_supply_demand(value_array, bn_array, box_array, label_array, box_type, atr) =>
atr_buffer = atr * (box_width / 10)
box_left = array.get(bn_array, 0)
box_right = bar_index
var float box_top = 0.00
var float box_bottom = 0.00
var float poi = 0.00
if box_type == 1
box_top := array.get(value_array, 0)
box_bottom := box_top - atr_buffer
poi := (box_top + box_bottom) / 2
else if box_type == -1
box_bottom := array.get(value_array, 0)
box_top := box_bottom + atr_buffer
poi := (box_top + box_bottom) / 2
okay_to_draw = f_check_overlapping(poi, box_array, atr)
//delete oldest box, and then create a new box and add it to the array
if box_type == 1 and okay_to_draw
if array.size(box_array) > 0
box.delete(array.get(box_array, array.size(box_array) - 1))
f_array_add_pop(box_array, box.new(box_left, box_top, box_right, box_bottom, border_color=supply_outline_color,
bgcolor=supply_color, extend=extend.right, text='SUPPLY', text_halign=text.align_center, text_valign=text.align_center, text_color=poi_label_color, text_size=size.small))
if array.size(label_array) > 0
box.delete(array.get(label_array, array.size(label_array) - 1))
f_array_add_pop(label_array, box.new(box_left, poi, box_right, poi, border_color=color.new(poi_label_color,90),
bgcolor=color.new(poi_label_color,90), extend=extend.right, text='POI', text_halign=text.align_left, text_valign=text.align_center, text_color=poi_label_color, text_size=size.small))
else if box_type == -1 and okay_to_draw
if array.size(box_array) > 0
box.delete(array.get(box_array, array.size(box_array) - 1))
f_array_add_pop(box_array, box.new(box_left, box_top, box_right, box_bottom, border_color=demand_outline_color,
bgcolor=demand_color, extend=extend.right, text='DEMAND', text_halign=text.align_center, text_valign=text.align_center, text
Show full message · 250 lines Here's the corrected Pine Script v6 code with the errors fixed:
pinescript Copy code
//@version=6
indicator("SMC Master Fib Pro", shorttitle="SMC Fib Pro", overlay=true, max_labels_count=500, max_boxes_count=500, max_lines_count=500, max_bars_back=5000)
// ========================================
// SMC Lite Settings
// ========================================
// INDICATOR SETTINGS
swing_length = input.int(10, title='Swing High/Low Length', group='SMC Lite Settings', minval=1, maxval=50)
history_of_demand_to_keep = input.int(20, title='History To Keep', group='SMC Lite Settings', minval=5, maxval=50)
box_width = input.float(2.5, title='Supply/Demand Box Width', group='SMC Lite Settings', minval=1, maxval=10, step=0.5)
// INDICATOR VISUAL SETTINGS
show_zigzag = input.bool(false, title='Show Zig Zag', group='SMC Lite Visual', inline='1')
show_price_action_labels = input.bool(false, title='Show Price Action Labels', group='SMC Lite Visual', inline='2')
supply_color = input.color(color.new(#EDEDED,70), title='Supply', group='SMC Lite Visual', inline='3')
supply_outline_color = input.color(color.new(color.white,75), title='Outline', group='SMC Lite Visual', inline='3')
demand_color = input.color(color.new(#00FFFF,70), title='Demand', group='SMC Lite Visual', inline='4')
demand_outline_color = input.color(color.new(color.white,75), title='Outline', group='SMC Lite Visual', inline='4')
poi_label_color = input.color(color.white, title='POI Label', group='SMC Lite Visual', inline='7')
swing_type_color = input.color(color.black, title='Price Action Label', group='SMC Lite Visual', inline='8')
zigzag_color = input.color(color.new(#000000,0), title='Zig Zag', group='SMC Lite Visual', inline='9')
// ========================================
// Masterpiece Indicator Settings
// ========================================
// Define Colors
GreenColorCandle = color.green
RedColorCandle = color.red
GreenColor = color.rgb(0, 128, 0)
RedColor = color.rgb(222, 23, 56)
GreenFluroscent = color.rgb(0, 255, 0)
RedFluroscent = color.rgb(255, 0, 0)
YellowFluroscent = color.rgb(255, 255, 0)
NotInterested = color.new(#ffffff, 90)
OverlayBarColor = input.bool(true, title='Overlay - Master Candle Color', group='Masterpiece Settings')
OverlayIndicator = input.bool(true, title='Overlay - MA20 and VWAP', group='Masterpiece Settings')
Overlay_Supertrend = input.bool(false, title='Overlay: Supertrend', group='Masterpiece Settings')
Overlay_HalfTrend = input.bool(false, title='Overlay: HalfTrend', group='Masterpiece Settings')
Overlay_Ichimoku_Cloud = input.bool(false, title='Overlay: Ichimoku Cloud', group='Masterpiece Settings')
Overlay_P_SAR = input.bool(false, title='Overlay: Parabolic SAR', group='Masterpiece Settings')
// Supertrend Settings
ST_AtrPeriod = input.int(10, 'ATR Length', minval=1, group='Supertrend')
ST_Factor = input.float(3.0, 'Factor', minval=0.01, step=0.01, group='Supertrend')
// HalfTrend Settings
HT_Amplitude = input.int(2, title='Amplitude', group='HalfTrend')
HT_ChannelDeviation = input.int(2, title='Channel Deviation', group='HalfTrend')
// Ichimoku Cloud Settings
IC_ConversionPeriods = input.int(5, minval=1, title='Conversion Periods', group='Ichimoku Cloud')
IC_BasePeriods = input.int(26, minval=1, title='Base Periods', group='Ichimoku Cloud')
IC_LaggingSpan2Periods = input.int(52, minval=1, title='Lagging Span 2 Periods', group='Ichimoku Cloud')
IC_Displacement = input.int(26, minval=1, title='Displacement', group='Ichimoku Cloud')
// Parabolic SAR Settings
PS_Start = input.float(0.02, group='Parabolic SAR')
PS_Increment = input.float(0.02, group='Parabolic SAR')
PS_Maximum = input.float(0.2, 'Max Value', group='Parabolic SAR')
// ========================================
// Market Structure Settings
// ========================================
ms_length = input.int(5, minval = 3, title='Fractal Length', group='Market Structure')
//Colors
showBull = input(true, 'Bullish Structures', inline = 'bull', group = 'Market Structure Style')
bullCss = input.color(#089981, '', inline = 'bull', group = 'Market Structure Style')
showBear = input(true, 'Bearish Structures', inline = 'bear', group = 'Market Structure Style')
bearCss = input.color(#f23645, '', inline = 'bear', group = 'Market Structure Style')
showSupport = input(false, 'Support', inline = 's', group = 'Market Structure Style')
supCss = input.color(#089981, '', inline = 's', group = 'Market Structure Style')
showResistance = input(false, 'Resistance', inline = 'r', group = 'Market Structure Style')
resCss = input.color(#f23645, '', inline = 'r', group = 'Market Structure Style')
//Dashboard
showDash = input(false, 'Show Dashboard', group = 'Dashboard')
dashLoc = input.string('Top Right', 'Location', options = ['Top Right', 'Bottom Right', 'Bottom Left'], group = 'Dashboard')
textSize = input.string('Small', 'Size' , options = ['Tiny', 'Small', 'Normal'] , group = 'Dashboard')
// ========================================
// Auto Fibonacci Settings
// ========================================
G_AutoFibo = 'Auto Fibonacci Retracement'
// Main Switch
AFBswitch = input.bool(true, title="Enable Auto Fibonacci", group=G_AutoFibo)
// Level Controls
FibHighLow = input.bool(false, title='Show High/Low Labels', group=G_AutoFibo, inline='AFB')
AFB0 = input.bool(false, title='Level 0%', group=G_AutoFibo, inline='AFB')
AFB1 = input.bool(false, title='Level 23.6%', group=G_AutoFibo, inline='AFB1')
AFB2 = input.bool(true, title='Level 38.2%', group=G_AutoFibo, inline='AFB1')
AFB3 = input.bool(true, title='Level 50%', group=G_AutoFibo, inline='AFB1')
AFB4 = input.bool(true, title='Level 61.8%', group=G_AutoFibo, inline='AFB2')
AFB5 = input.bool(false, title='Level 78.6%', group=G_AutoFibo, inline='AFB2')
AFB6 = input.bool(false, title='Level 100%', group=G_AutoFibo, inline='AFB2')
// Period Input
FPeriod = input.int(100, title='Lookback Period', minval=10, maxval=500, group=G_AutoFibo)
// Color and Style Inputs
F0color = input.color(#ff0000, title="0% Level Color", group=G_AutoFibo, inline="colors1")
F236color = input.color(#aacf92, title="23.6% Level Color", group=G_AutoFibo, inline="colors1")
F382color = input.color(#aacf92, title="38.2% Level Color", group=G_AutoFibo, inline="colors2")
F500color = input.color(#aacf92, title="50% Level Color", group=G_AutoFibo, inline="colors2")
F618color = input.color(#5a9afb, title="61.8% Level Color", group=G_AutoFibo, inline="colors3")
F786color = input.color(#aacf92, title="78.6% Level Color", group=G_AutoFibo, inline="colors3")
F1000color = input.color(#00ff0d, title="100% Level Color", group=G_AutoFibo, inline="colors4")
HighLowColor = input.color(#ff6600, title="High/Low Color", group=G_AutoFibo, inline="colors4")
// Line Style Settings
G_LineStyle = 'Line Styles'
F0style = input.string("Solid", title="0% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style1")
F236style = input.string("Solid", title="23.6% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style1")
F382style = input.string("Solid", title="38.2% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style2")
F500style = input.string("Solid", title="50% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style2")
F618style = input.string("Solid", title="61.8% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style3")
F786style = input.string("Solid", title="78.6% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style3")
F1000style = input.string("Solid", title="100% Line Style", options=["Solid", "Dashed", "Dotted"], group=G_LineStyle, inline="style4")
// Line Thickness Settings
G_LineThickness = 'Line Thickness'
F0thickness = input.int(2, title="0% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick1")
F236thickness = input.int(1, title="23.6% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick1")
F382thickness = input.int(1, title="38.2% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick2")
F500thickness = input.int(2, title="50% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick2")
F618thickness = input.int(2, title="61.8% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick3")
F786thickness = input.int(1, title="78.6% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick3")
F1000thickness = input.int(2, title="100% Line Thickness", minval=1, maxval=5, group=G_LineThickness, inline="thick4")
// ========================================
// Fibonacci Golden Wave Settings
// ========================================
G_GoldenWave = 'Fibonacci Golden Wave'
// Golden Wave Settings
enableGoldenWave = input.bool(true, "Enable Golden Wave", group=G_GoldenWave)
pivotRange = input.int(20, "Swing Range", group=G_GoldenWave)
fibArea1 = input.float(0.5, "Golden Zone Level 1", options=[0.236, 0.382, 0.5, 0.618, 0.786], group=G_GoldenWave, inline="zone")
fibArea2 = input.float(0.618, "Golden Zone Level 2", options=[0.236, 0.382, 0.5, 0.618, 0.786], group=G_GoldenWave, inline="zone")
gzLineColor = input.color(color.new(color.yellow, 60), "Golden Zone Lines", group=G_GoldenWave)
showArea = input.bool(true, "Show Golden Zone Area", group=G_GoldenWave, inline="gzarea")
gzAreaColor = input.color(color.new(color.yellow, 90), "", group=G_GoldenWave, inline="gzarea")
textSizeGW = input.string("Normal", "Text Size", options=["Auto", "Small", "Normal"], group=G_GoldenWave, inline="text")
textColor = input.color(color.new(color.white, 30), "", group=G_GoldenWave, inline="text")
// ========================================
// SMC Lite Functions
// ========================================
// FUNCTION TO ADD NEW AND REMOVE LAST IN ARRAY
f_array_add_pop(array_var, new_value_to_add) =>
array.unshift(array_var, new_value_to_add)
array.pop(array_var)
// FUNCTION SWING H & L LABELS
f_sh_sl_labels(array_var, swing_type) =>
var string label_text = na
if swing_type == 1
if array.get(array_var, 0) >= array.get(array_var, 1)
label_text := 'HH'
else
label_text := 'LH'
label.new(bar_index - swing_length, array.get(array_var,0), text=label_text, style=label.style_label_down, textcolor=swing_type_color, color=color.new(swing_type_color, 100), size=size.tiny)
else if swing_type == -1
if array.get(array_var, 0) >= array.get(array_var, 1)
label_text := 'HL'
else
label_text := 'LL'
label.new(bar_index - swing_length, array.get(array_var,0), text=label_text, style=label.style_label_up, textcolor=swing_type_color, color=color.new(swing_type_color, 100), size=size.tiny)
// FUNCTION MAKE SURE SUPPLY ISNT OVERLAPPING
f_check_overlapping(new_poi, box_array, atr) =>
atr_threshold = atr * 2
okay_to_draw = true
for i = 0 to array.size(box_array) - 1
if array.size(box_array) > i
top = box.get_top(array.get(box_array, i))
bottom = box.get_bottom(array.get(box_array, i))
poi = (top + bottom) / 2
upper_boundary = poi + atr_threshold
lower_boundary = poi - atr_threshold
if new_poi >= lower_boundary and new_poi <= upper_boundary
okay_to_draw := false
break
else
okay_to_draw := true
okay_to_draw
// FUNCTION TO DRAW SUPPLY OR DEMAND ZONE
f_supply_demand(value_array, bn_array, box_array, label_array, box_type, atr) =>
atr_buffer = atr * (box_width / 10)
box_left = array.get(bn_array, 0)
box_right = bar_index
var float box_top = 0.00
var float box_bottom = 0.00
var float poi = 0.00
if box_type == 1
box_top := array.get(value_array, 0)
box_bottom := box_top - atr_buffer
poi := (box_top + box_bottom) / 2
else if box_type == -1
box_bottom := array.get(value_array, 0)
box_top := box_bottom + atr_buffer
poi := (box_top + box_bottom) / 2
okay_to_draw = f_check_overlapping(poi, box_array, atr)
//delete oldest box, and then create a new box and add it to the array
if box_type == 1 and okay_to_draw
if array.size(box_array) > 0
box.delete(array.get(box_array, array.size(box_array) - 1))
f_array_add_pop(box_array, box.new(box_left, box_top, box_right, box_bottom, border_color=supply_outline_color,
bgcolor=supply_color, extend=extend.right, text='SUPPLY', text_halign=text.align_center, text_valign=text.align_center, text_color=poi_label_color, text_size=size.small))
if array.size(label_array) > 0
box.delete(array.get(label_array, array.size(label_array) - 1))
f_array_add_pop(label_array, box.new(box_left, poi, box_right, poi, border_color=color.new(poi_label_color,90),
bgcolor=color.new(poi_label_color,90), extend=extend.right, text='POI', text_halign=text.align_left, text_valign=text.align_center, text_color=poi_label_color, text_size=size.small))
else if box_type == -1 and okay_to_draw
if array.size(box_array) > 0
box.delete(array.get(box_array, array.size(box_array) - 1))
f_array_add_pop(box_array, box.new(box_left, box_top, box_right, box_bottom, border_color=demand_outline_color,
bgcolor=demand_color, extend=extend.right, text='DEMAND', text_halign=text.align_center, text_valign=text.align_center, text_color=poi_label_color, text_size=size.small))
if array.size(label_array) > 0
Show full message · 252 lines Copy first response