PROTECTED SOURCE SCRIPT
Killshotcopy

// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
//version=5
indicator("Killshot", overlay=true, format = format.price, max_labels_count=500, max_lines_count=500)
max_bars_back(time, 5000)
////////////////////////////////////////////////////////////////////////////
///// /////
///// Input Block /////
///// /////
////////////////////////////////////////////////////////////////////////////
// Color inputs for EMAs
short_color = input.color(defval=color.blue, title="Fast EMA Color", group="EMA Settings")
medium_color = input.color(defval=color.orange, title="Slow EMA Color", group="EMA Settings")
long_color = input.color(defval=color.red, title="Long EMA Color", group="EMA Settings")
// EMA period inputs
fastEMA = input.int(defval=20, title="Fast EMA", group="EMA Settings")
slowEMA = input.int(defval=50, title="Slow EMA", group="EMA Settings")
longEMA = input.int(defval=238, title="Long EMA", group="EMA Settings")
//Support & Resistance
showSR = input.bool(title="Display Support and Resistance", defval=true, group="S&R Settings")
atrMovement = input.float(title="ATR Movement Required", defval=1.0, step=0.5, tooltip="Minimum ATR distance price must move to consider a pivot zone to be 'major'")
lookback = input.int(title="High/Low Lookback", defval=25, step=5, tooltip="Lookback period for detecting swing highs/lows")
maxZoneSize = input.float(title="Max Zone Size (Compared to ATR)", defval=2.5, step=0.5, tooltip="If a zone is larger than the current ATR multiplied by this, it is considered too large and ignored")
newStructureReset = input.int(title="Zone Update Count Before Reset", defval=25, step=5, tooltip="The script draws two zones until they're violated - if the first zone is updated this many times, the second zone is reset")
drawPreviousStructure = input.bool(title="Draw Previous Structure", defval=true, tooltip="This turns on/off drawing 'support-turned-resistance' and 'resistance-turned-support'")
displayStars = input.bool(title="Display Stars", defval=true, group="Star Settings")
////////////////////////////////////////////////////////////////////////////
///// /////
///// EMA Cross Plot Block /////
///// /////
////////////////////////////////////////////////////////////////////////////
short = ta.ema(close, fastEMA)
medium = ta.ema(close, slowEMA)
long = ta.ema(close, longEMA)
plot(short, color=short_color, linewidth=1)
plot(medium, color=medium_color, linewidth=1)
plot(long, color=long_color, linewidth=1)
//Show the directional arrows
plotshape(ta.cross(short,medium) and short>medium ? short : na, style=shape.triangleup, color=color.blue, size=size.small, location=location.belowbar)
plotshape(ta.cross(short,medium) and short<medium ? short : na, style=shape.triangledown, color=color.new(#ff0000, 0), size=size.small, location=location.abovebar)
//Plot columns for a histogram
color bullColor = color.new(#3179f5, 80)
color bearColor = color.new(color.red, 80)
color c_ma = short>medium ? bullColor : bearColor
plot(series=low, style=plot.style_columns, color=c_ma)
////////////////////////////////////////////////////////////////////////////
///// /////
///// Support & Resistance Code Block /////
///// /////
////////////////////////////////////////////////////////////////////////////
// Get current ATR value
atr = ta.atr(14)
// Get highest body and lowest body for the current candle
highestBody = open > close ? open : close
lowestBody = open > close ? close : open
// Set up our persistent S&R variables (1 = the wick and 2 = the body)
var res1 = 0.0
var res2 = 0.0
var sup1 = 0.0
var sup2 = 0.0
var lookForNewResistance = true
var lookForNewSupport = true
// Set up our *previous* support & resistance variables (for drawing support-turned-resistance etc)
var previousRes1 = 0.0
var previousRes2 = 0.0
var previousSup1 = 0.0
var previousSup2 = 0.0
// Set up our ATR variables (for identifying significant declines/rallies to validate S&R zones)
var atrSaved = 0.0
var potentialR1 = 0.0
var potentialR2 = 0.0
var potentialS1 = 0.0
var potentialS2 = 0.0
// Detect fractal swing highs for resistance
// We're looking for this pattern: .|.
if high[1] == ta.highest(high, lookback) and high < high[1] and lookForNewResistance
r1 = high[1]
r2 = highestBody[2] > highestBody[1] ? highestBody[2] : highestBody > highestBody[1] ? highestBody : highestBody[1]
if (r1 - r2) / atr <= maxZoneSize
lookForNewResistance := false
potentialR1 := r1
potentialR2 := r2
atrSaved := atr
// Detect fractal swing lows for support
// We're looking for this pattern: *|*
if low[1] == ta.lowest(low, lookback) and low > low[1] and lookForNewSupport
s1 = low[1]
s2 = lowestBody[2] < lowestBody[1] ? lowestBody[2] : lowestBody < lowestBody[1] ? lowestBody : lowestBody[1]
if (s2 - s1) / atr <= maxZoneSize
lookForNewSupport := false
potentialS1 := s1
potentialS2 := s2
atrSaved := atr
// Check if potential resistance zone has already been violated. If it has, reset our potential R1 & R2
if close > potentialR1 and barstate.isconfirmed
potentialR1 := na
potentialR2 := na
// Check if potential support zone has already been violated. If it has, reset our potential S1 & S2
if close < potentialS1 and barstate.isconfirmed
potentialS1 := na
potentialS2 := na
// Check if we've had a significant decline since detecting swing high
if potentialR1 - low >= (atrSaved * atrMovement)
previousRes1 := na(previousRes1) ? potentialR1 : previousRes1 // Store previous resistance if we're not already drawing it
previousRes2 := na(previousRes2) ? potentialR2 : previousRes2
res1 := potentialR1
res2 := potentialR2
potentialR1 := na
potentialR2 := na
// Check if we've had a significant rally since detecting swing low
if high - potentialS1 >= (atrSaved * atrMovement)
previousSup1 := na(previousSup1) ? potentialS1 : previousSup1 // Store previous support if we're not already drawing it
previousSup2 := na(previousSup2) ? potentialS2 : previousSup2
sup1 := potentialS1
sup2 := potentialS2
potentialS1 := na
potentialS2 := na
// Declare support & resistance update counters
// This is used for forcing a zone reset if a zone is not violated within a reasonable period of time
var supCount = 0
var resCount = 0
// If the previous resistance high has been violated then begin searching for a new resistance zone
if close >= res1 and barstate.isconfirmed
lookForNewResistance := true
lookForNewSupport := true
resCount := resCount + 1
// If the previous support low has been violated then begin searching for a new support zone
if close <= sup1 and barstate.isconfirmed
lookForNewSupport := true
lookForNewResistance := true
supCount := supCount + 1
// If our current resistance zone has been violated, store its values to draw new *potential* support zone
// The idea being that once a major resistance zone is violated it often becomes future support
// But we only save previous S&R if we don't already have one saved (or our zone update count exceeds newStructureReset)
if (close > res1 and na(previousRes1) and barstate.isconfirmed) or previousRes1 == 0.0 or supCount >= newStructureReset
previousRes1 := res1
previousRes2 := res2
supCount := 0
// If our current support zone has been violated, store its values to draw new *potential* resistance zone
// The idea being that once a major support zone is violated it often becomes future resistance
// But we only save previous S&R if we don't already have one saved (or our zone update count exceeds newStructureReset)
if (close < sup1 and na(previousSup1) and barstate.isconfirmed) or previousSup1 == 0.0 or resCount >= newStructureReset
previousSup1 := sup1
previousSup2 := sup2
resCount := 0
// If our resistance-turned-support zone has been violated, reset our saved resistance variables
if close < previousRes2 and barstate.isconfirmed
previousRes1 := na
previousRes2 := na
// If our support-turned-resistance zone has been violated, reset our saved support variables
if close > previousSup2 and barstate.isconfirmed
previousSup1 := na
previousSup2 := na
// Draw our current resistance zone
r1 = plot(res1 == res1[1] ? res1 : na, color=close >= res1 ? color.green : color.red, style=plot.style_linebr, title="R1")
r2 = plot(res1 == res1[1] ? res2 : na, color=close >= res1 ? color.green : color.red, style=plot.style_linebr, title="R2")
fill(r1, r2, color=close > res1 ? color.green : color.new(color.red, 50), title="Resistance Zone")
// Draw our current support zone
s1 = plot(sup1 == sup1[1] ? sup1 : na, color=close < sup1 ? color.red : color.green, style=plot.style_linebr, title="S1")
s2 = plot(sup1 == sup1[1] ? sup2 : na, color=close < sup1 ? color.red : color.green, style=plot.style_linebr, title="S2")
fill(s1, s2, color=close < sup1 ? color.red : color.new(color.green, 50), title="Support Zone")
// Draw our previous support zone (turned potential resistance)
ps1 = plot(previousSup1 == previousSup1[1] and previousSup1 != sup1 and drawPreviousStructure ? previousSup1 : na, color=color.red, style=plot.style_linebr, title="PS1")
ps2 = plot(previousSup1 == previousSup1[1] and previousSup1 != sup1 and drawPreviousStructure ? previousSup2 : na, color=color.red, style=plot.style_linebr, title="PS2")
fill(ps1, ps2, color=color.new(color.red, 10), title="Previous Support Zone")
// Draw our previous resistance zone (turned potential support)
pr1 = plot(previousRes1 == previousRes1[1] and previousRes1 != res1 and drawPreviousStructure ? previousRes1 : na, color=color.green, style=plot.style_linebr, title="PR1")
pr2 = plot(previousRes1 == previousRes1[1] and previousRes1 != res1 and drawPreviousStructure ? previousRes2 : na, color=color.green, style=plot.style_linebr, title="PR2")
fill(pr1, pr2, color=color.new(color.green, 10), title="Previous Resistance Zone")
////////////////////////////////////////////////////////////////////////////
///// /////
///// STARS Code Block /////
///// /////
////////////////////////////////////////////////////////////////////////////
//calculation variables. Hardcoded for now.
Depth1 = 5
Depth2 = 13
Depth3 = 34
Deviation1 = 1
Deviation2 = 8
Deviation3 = 13
Backstep1 = 3
Backstep2 = 5
Backstep3 = 8
// STAR Color settings - MEDIUM NOW BLUE
color1 = input(title = "Small Stars Color", defval = color.yellow)
color2 = color1
color3 = input(title = "Medium Stars Color", defval = color.aqua)
color4 = color3
color5 = input(title = "Large Sell Stars Color", defval = color.red)
color6 = input(title = "Large Buy Stars Color", defval = color.lime)
repaint = true
// CHATGPT FIX #1: Add useStar parameter
zigzag(Depth0, Deviation0, Backstep0, color0, color00, size0, useStar) =>
var last_h = 1
last_h += 1
var last_l = 1
last_l += 1
var lw = 1
var hg = 1
lw += 1
hg += 1
p_lw = -ta.lowestbars(Depth0)
p_hg = -ta.highestbars(Depth0)
lowing = lw == p_lw or low - low[p_lw] > Deviation0 * syminfo.mintick
highing = hg == p_hg or high[p_hg] - high > Deviation0 * syminfo.mintick
lh = ta.barssince(not highing[1])
ll = ta.barssince(not lowing[1])
down = ta.barssince(not(lh > ll)) >= Backstep0
lower = low[lw] > low[p_lw]
higher = high[hg] < high[p_hg]
if lw != p_lw and (not down[1] or lower)
lw := p_lw < hg ? p_lw : 0
lw
if hg != p_hg and (down[1] or higher)
hg := p_hg < lw ? p_hg : 0
hg
label point = na
x1 = down ? lw : hg
y1 = down ? low[lw]-3 : high[hg]
if down == down[1]
if repaint
label.delete(point[1])
down
if down != down[1]
if down
last_h := hg
last_h
else
last_l := lw
last_l
if not repaint
nx = down ? last_h : last_l
point := label.new(bar_index-nx, down ? high[nx] : low[nx]-6, text = "🟡", style=down?label.style_label_down:label.style_label_up)
down
if repaint
// FINAL FIX: Use red/green circle emojis for Depth3, yellow circles for Depth1/2
txt = useStar ? (down ? "🟢" : "🔴") : "🟡"
point := label.new(bar_index - x1, y1, txt, style=label.style_none, size=size0, textcolor=down ? color00 : color0, xloc=xloc.bar_index, yloc=yloc.price, force_overlay=true)
if displayStars
// CHATGPT FIX #3: Pass false for Depth1/2, true for Depth3
zigzag(Depth1, Deviation1, Backstep1, color1, color2, size.normal, false)
zigzag(Depth2, Deviation2, Backstep2, color3, color4, size.large, false)
zigzag(Depth3, Deviation3, Backstep3, color5, color6, size.huge, true)
////////////////////////////////////////////////////////////////////////////
///// /////
///// Trigger Alerts /////
///// /////
////////////////////////////////////////////////////////////////////////////
// Code Alerts
alert_message = ""
if ta.cross(short,medium) and short>medium
alert_message := "EMA Cross Buy alert for " + syminfo.description + "\nprice: " + str.tostring(math.round(open, 2))
alert(alert_message, freq=alert.freq_once_per_bar)
if ta.cross(short,medium) and short<medium
alert_message := "EMA Cross Sell alert for " + syminfo.description + "\nprice: " + str.tostring(math.round(open, 2))
alert(alert_message, freq=alert.freq_once_per_bar)
//version=5
indicator("Killshot", overlay=true, format = format.price, max_labels_count=500, max_lines_count=500)
max_bars_back(time, 5000)
////////////////////////////////////////////////////////////////////////////
///// /////
///// Input Block /////
///// /////
////////////////////////////////////////////////////////////////////////////
// Color inputs for EMAs
short_color = input.color(defval=color.blue, title="Fast EMA Color", group="EMA Settings")
medium_color = input.color(defval=color.orange, title="Slow EMA Color", group="EMA Settings")
long_color = input.color(defval=color.red, title="Long EMA Color", group="EMA Settings")
// EMA period inputs
fastEMA = input.int(defval=20, title="Fast EMA", group="EMA Settings")
slowEMA = input.int(defval=50, title="Slow EMA", group="EMA Settings")
longEMA = input.int(defval=238, title="Long EMA", group="EMA Settings")
//Support & Resistance
showSR = input.bool(title="Display Support and Resistance", defval=true, group="S&R Settings")
atrMovement = input.float(title="ATR Movement Required", defval=1.0, step=0.5, tooltip="Minimum ATR distance price must move to consider a pivot zone to be 'major'")
lookback = input.int(title="High/Low Lookback", defval=25, step=5, tooltip="Lookback period for detecting swing highs/lows")
maxZoneSize = input.float(title="Max Zone Size (Compared to ATR)", defval=2.5, step=0.5, tooltip="If a zone is larger than the current ATR multiplied by this, it is considered too large and ignored")
newStructureReset = input.int(title="Zone Update Count Before Reset", defval=25, step=5, tooltip="The script draws two zones until they're violated - if the first zone is updated this many times, the second zone is reset")
drawPreviousStructure = input.bool(title="Draw Previous Structure", defval=true, tooltip="This turns on/off drawing 'support-turned-resistance' and 'resistance-turned-support'")
displayStars = input.bool(title="Display Stars", defval=true, group="Star Settings")
////////////////////////////////////////////////////////////////////////////
///// /////
///// EMA Cross Plot Block /////
///// /////
////////////////////////////////////////////////////////////////////////////
short = ta.ema(close, fastEMA)
medium = ta.ema(close, slowEMA)
long = ta.ema(close, longEMA)
plot(short, color=short_color, linewidth=1)
plot(medium, color=medium_color, linewidth=1)
plot(long, color=long_color, linewidth=1)
//Show the directional arrows
plotshape(ta.cross(short,medium) and short>medium ? short : na, style=shape.triangleup, color=color.blue, size=size.small, location=location.belowbar)
plotshape(ta.cross(short,medium) and short<medium ? short : na, style=shape.triangledown, color=color.new(#ff0000, 0), size=size.small, location=location.abovebar)
//Plot columns for a histogram
color bullColor = color.new(#3179f5, 80)
color bearColor = color.new(color.red, 80)
color c_ma = short>medium ? bullColor : bearColor
plot(series=low, style=plot.style_columns, color=c_ma)
////////////////////////////////////////////////////////////////////////////
///// /////
///// Support & Resistance Code Block /////
///// /////
////////////////////////////////////////////////////////////////////////////
// Get current ATR value
atr = ta.atr(14)
// Get highest body and lowest body for the current candle
highestBody = open > close ? open : close
lowestBody = open > close ? close : open
// Set up our persistent S&R variables (1 = the wick and 2 = the body)
var res1 = 0.0
var res2 = 0.0
var sup1 = 0.0
var sup2 = 0.0
var lookForNewResistance = true
var lookForNewSupport = true
// Set up our *previous* support & resistance variables (for drawing support-turned-resistance etc)
var previousRes1 = 0.0
var previousRes2 = 0.0
var previousSup1 = 0.0
var previousSup2 = 0.0
// Set up our ATR variables (for identifying significant declines/rallies to validate S&R zones)
var atrSaved = 0.0
var potentialR1 = 0.0
var potentialR2 = 0.0
var potentialS1 = 0.0
var potentialS2 = 0.0
// Detect fractal swing highs for resistance
// We're looking for this pattern: .|.
if high[1] == ta.highest(high, lookback) and high < high[1] and lookForNewResistance
r1 = high[1]
r2 = highestBody[2] > highestBody[1] ? highestBody[2] : highestBody > highestBody[1] ? highestBody : highestBody[1]
if (r1 - r2) / atr <= maxZoneSize
lookForNewResistance := false
potentialR1 := r1
potentialR2 := r2
atrSaved := atr
// Detect fractal swing lows for support
// We're looking for this pattern: *|*
if low[1] == ta.lowest(low, lookback) and low > low[1] and lookForNewSupport
s1 = low[1]
s2 = lowestBody[2] < lowestBody[1] ? lowestBody[2] : lowestBody < lowestBody[1] ? lowestBody : lowestBody[1]
if (s2 - s1) / atr <= maxZoneSize
lookForNewSupport := false
potentialS1 := s1
potentialS2 := s2
atrSaved := atr
// Check if potential resistance zone has already been violated. If it has, reset our potential R1 & R2
if close > potentialR1 and barstate.isconfirmed
potentialR1 := na
potentialR2 := na
// Check if potential support zone has already been violated. If it has, reset our potential S1 & S2
if close < potentialS1 and barstate.isconfirmed
potentialS1 := na
potentialS2 := na
// Check if we've had a significant decline since detecting swing high
if potentialR1 - low >= (atrSaved * atrMovement)
previousRes1 := na(previousRes1) ? potentialR1 : previousRes1 // Store previous resistance if we're not already drawing it
previousRes2 := na(previousRes2) ? potentialR2 : previousRes2
res1 := potentialR1
res2 := potentialR2
potentialR1 := na
potentialR2 := na
// Check if we've had a significant rally since detecting swing low
if high - potentialS1 >= (atrSaved * atrMovement)
previousSup1 := na(previousSup1) ? potentialS1 : previousSup1 // Store previous support if we're not already drawing it
previousSup2 := na(previousSup2) ? potentialS2 : previousSup2
sup1 := potentialS1
sup2 := potentialS2
potentialS1 := na
potentialS2 := na
// Declare support & resistance update counters
// This is used for forcing a zone reset if a zone is not violated within a reasonable period of time
var supCount = 0
var resCount = 0
// If the previous resistance high has been violated then begin searching for a new resistance zone
if close >= res1 and barstate.isconfirmed
lookForNewResistance := true
lookForNewSupport := true
resCount := resCount + 1
// If the previous support low has been violated then begin searching for a new support zone
if close <= sup1 and barstate.isconfirmed
lookForNewSupport := true
lookForNewResistance := true
supCount := supCount + 1
// If our current resistance zone has been violated, store its values to draw new *potential* support zone
// The idea being that once a major resistance zone is violated it often becomes future support
// But we only save previous S&R if we don't already have one saved (or our zone update count exceeds newStructureReset)
if (close > res1 and na(previousRes1) and barstate.isconfirmed) or previousRes1 == 0.0 or supCount >= newStructureReset
previousRes1 := res1
previousRes2 := res2
supCount := 0
// If our current support zone has been violated, store its values to draw new *potential* resistance zone
// The idea being that once a major support zone is violated it often becomes future resistance
// But we only save previous S&R if we don't already have one saved (or our zone update count exceeds newStructureReset)
if (close < sup1 and na(previousSup1) and barstate.isconfirmed) or previousSup1 == 0.0 or resCount >= newStructureReset
previousSup1 := sup1
previousSup2 := sup2
resCount := 0
// If our resistance-turned-support zone has been violated, reset our saved resistance variables
if close < previousRes2 and barstate.isconfirmed
previousRes1 := na
previousRes2 := na
// If our support-turned-resistance zone has been violated, reset our saved support variables
if close > previousSup2 and barstate.isconfirmed
previousSup1 := na
previousSup2 := na
// Draw our current resistance zone
r1 = plot(res1 == res1[1] ? res1 : na, color=close >= res1 ? color.green : color.red, style=plot.style_linebr, title="R1")
r2 = plot(res1 == res1[1] ? res2 : na, color=close >= res1 ? color.green : color.red, style=plot.style_linebr, title="R2")
fill(r1, r2, color=close > res1 ? color.green : color.new(color.red, 50), title="Resistance Zone")
// Draw our current support zone
s1 = plot(sup1 == sup1[1] ? sup1 : na, color=close < sup1 ? color.red : color.green, style=plot.style_linebr, title="S1")
s2 = plot(sup1 == sup1[1] ? sup2 : na, color=close < sup1 ? color.red : color.green, style=plot.style_linebr, title="S2")
fill(s1, s2, color=close < sup1 ? color.red : color.new(color.green, 50), title="Support Zone")
// Draw our previous support zone (turned potential resistance)
ps1 = plot(previousSup1 == previousSup1[1] and previousSup1 != sup1 and drawPreviousStructure ? previousSup1 : na, color=color.red, style=plot.style_linebr, title="PS1")
ps2 = plot(previousSup1 == previousSup1[1] and previousSup1 != sup1 and drawPreviousStructure ? previousSup2 : na, color=color.red, style=plot.style_linebr, title="PS2")
fill(ps1, ps2, color=color.new(color.red, 10), title="Previous Support Zone")
// Draw our previous resistance zone (turned potential support)
pr1 = plot(previousRes1 == previousRes1[1] and previousRes1 != res1 and drawPreviousStructure ? previousRes1 : na, color=color.green, style=plot.style_linebr, title="PR1")
pr2 = plot(previousRes1 == previousRes1[1] and previousRes1 != res1 and drawPreviousStructure ? previousRes2 : na, color=color.green, style=plot.style_linebr, title="PR2")
fill(pr1, pr2, color=color.new(color.green, 10), title="Previous Resistance Zone")
////////////////////////////////////////////////////////////////////////////
///// /////
///// STARS Code Block /////
///// /////
////////////////////////////////////////////////////////////////////////////
//calculation variables. Hardcoded for now.
Depth1 = 5
Depth2 = 13
Depth3 = 34
Deviation1 = 1
Deviation2 = 8
Deviation3 = 13
Backstep1 = 3
Backstep2 = 5
Backstep3 = 8
// STAR Color settings - MEDIUM NOW BLUE
color1 = input(title = "Small Stars Color", defval = color.yellow)
color2 = color1
color3 = input(title = "Medium Stars Color", defval = color.aqua)
color4 = color3
color5 = input(title = "Large Sell Stars Color", defval = color.red)
color6 = input(title = "Large Buy Stars Color", defval = color.lime)
repaint = true
// CHATGPT FIX #1: Add useStar parameter
zigzag(Depth0, Deviation0, Backstep0, color0, color00, size0, useStar) =>
var last_h = 1
last_h += 1
var last_l = 1
last_l += 1
var lw = 1
var hg = 1
lw += 1
hg += 1
p_lw = -ta.lowestbars(Depth0)
p_hg = -ta.highestbars(Depth0)
lowing = lw == p_lw or low - low[p_lw] > Deviation0 * syminfo.mintick
highing = hg == p_hg or high[p_hg] - high > Deviation0 * syminfo.mintick
lh = ta.barssince(not highing[1])
ll = ta.barssince(not lowing[1])
down = ta.barssince(not(lh > ll)) >= Backstep0
lower = low[lw] > low[p_lw]
higher = high[hg] < high[p_hg]
if lw != p_lw and (not down[1] or lower)
lw := p_lw < hg ? p_lw : 0
lw
if hg != p_hg and (down[1] or higher)
hg := p_hg < lw ? p_hg : 0
hg
label point = na
x1 = down ? lw : hg
y1 = down ? low[lw]-3 : high[hg]
if down == down[1]
if repaint
label.delete(point[1])
down
if down != down[1]
if down
last_h := hg
last_h
else
last_l := lw
last_l
if not repaint
nx = down ? last_h : last_l
point := label.new(bar_index-nx, down ? high[nx] : low[nx]-6, text = "🟡", style=down?label.style_label_down:label.style_label_up)
down
if repaint
// FINAL FIX: Use red/green circle emojis for Depth3, yellow circles for Depth1/2
txt = useStar ? (down ? "🟢" : "🔴") : "🟡"
point := label.new(bar_index - x1, y1, txt, style=label.style_none, size=size0, textcolor=down ? color00 : color0, xloc=xloc.bar_index, yloc=yloc.price, force_overlay=true)
if displayStars
// CHATGPT FIX #3: Pass false for Depth1/2, true for Depth3
zigzag(Depth1, Deviation1, Backstep1, color1, color2, size.normal, false)
zigzag(Depth2, Deviation2, Backstep2, color3, color4, size.large, false)
zigzag(Depth3, Deviation3, Backstep3, color5, color6, size.huge, true)
////////////////////////////////////////////////////////////////////////////
///// /////
///// Trigger Alerts /////
///// /////
////////////////////////////////////////////////////////////////////////////
// Code Alerts
alert_message = ""
if ta.cross(short,medium) and short>medium
alert_message := "EMA Cross Buy alert for " + syminfo.description + "\nprice: " + str.tostring(math.round(open, 2))
alert(alert_message, freq=alert.freq_once_per_bar)
if ta.cross(short,medium) and short<medium
alert_message := "EMA Cross Sell alert for " + syminfo.description + "\nprice: " + str.tostring(math.round(open, 2))
alert(alert_message, freq=alert.freq_once_per_bar)
Protected script
This script is published as closed-source. However, you can use it freely and without any limitations – learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Protected script
This script is published as closed-source. However, you can use it freely and without any limitations – learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.