커뮤니티
지표 부탁 드립니다
//@version=5
indicator("7/19 EMA Crossover Alerts", overlay=true)
// ==================== INPUTS ====================
fastLen = input.int(7, "Fast EMA")
slowLen = input.int(19, "Slow EMA")
slCandles = input.int(4, "SL Candles Lookback", options=[3, 4])
skipSaturday = input.bool(true, "Skip Saturday")
showSLLevels = input.bool(true, "Show SL Levels on Signal")
// ==================== EMAs ====================
ema7 = ta.ema(close, fastLen)
ema19 = ta.ema(close, slowLen)
// ==================== SIGNALS ====================
bullishCross = ta.crossover(ema7, ema19)
bearishCross = ta.crossunder(ema7, ema19)
// ==================== DAY FILTER ====================
canTrade = skipSaturday ? dayofweek != dayofweek.saturday : true
// ==================== STOP LOSS CALCULATIONS ====================
lowestLow3 = math.min(low, math.min(low[1], low[2]))
lowestLow4 = math.min(low, math.min(low[1], math.min(low[2], low[3])))
highestHigh3 = math.max(high, math.max(high[1], high[2]))
highestHigh4 = math.max(high, math.max(high[1], math.max(high[2], high[3])))
longSL = slCandles == 3 ? lowestLow3 : lowestLow4
shortSL = slCandles == 3 ? highestHigh3 : highestHigh4
// ==================== ENTRY CONDITIONS ====================
longSignal = bullishCross and canTrade
shortSignal = bearishCross and canTrade
skippedLong = bullishCross and not canTrade
skippedShort = bearishCross and not canTrade
// ==================== TRACK TREND ====================
var int trend = 0
if bullishCross
trend := 1
if bearishCross
trend := -1
// ==================== PLOTS ====================
plot(ema7, "7 EMA", color.lime, 2)
plot(ema19, "19 EMA", color.red, 2)
// Signal markers
plotshape(longSignal, "Long Signal", shape.triangleup, location.belowbar, color.lime, size=size.normal, text="LONG")
plotshape(shortSignal, "Short Signal", shape.triangledown, location.abovebar, color.red, size=size.normal, text="SHORT")
plotshape(skippedLong, "Skip Long", shape.xcross, location.belowbar, color.gray, size=size.small, text="SKIP")
plotshape(skippedShort, "Skip Short", shape.xcross, location.abovebar, color.gray, size=size.small, text="SKIP")
// SL level lines on signals
plot(showSLLevels and longSignal ? longSL : na, "Long SL", color.orange, 2, plot.style_circles)
plot(showSLLevels and shortSignal ? shortSL : na, "Short SL", color.orange, 2, plot.style_circles)
// Background
bgcolor(ema7 > ema19 ? color.new(color.green, 93) : color.new(color.red, 93))
// ==================== INFO TABLE ====================
var table t = table.new(position.top_right, 2, 6, bgcolor=color.new(color.black, 80))
if barstate.islast
table.cell(t, 0, 0, "7/19 EMA ALERTS", text_color=color.white, bgcolor=color.blue)
table.cell(t, 1, 0, "", bgcolor=color.blue)
table.cell(t, 0, 1, "Trend:", text_color=color.white, text_size=size.small)
table.cell(t, 1, 1, ema7 > ema19 ? "BULLISH" : "BEARISH", text_color=ema7 > ema19 ? color.lime : color.red, text_size=size.small)
table.cell(t, 0, 2, "EMA " + str.tostring(fastLen) + ":", text_color=color.white, text_size=size.small)
table.cell(t, 1, 2, str.tostring(ema7, "#.##"), text_color=color.lime, text_size=size.small)
table.cell(t, 0, 3, "EMA " + str.tostring(slowLen) + ":", text_color=color.white, text_size=size.small)
table.cell(t, 1, 3, str.tostring(ema19, "#.##"), text_color=color.red, text_size=size.small)
table.cell(t, 0, 4, "Long SL:", text_color=color.white, text_size=size.small)
table.cell(t, 1, 4, str.tostring(longSL, "#.##"), text_color=color.orange, text_size=size.small)
table.cell(t, 0, 5, "Short SL:", text_color=color.white, text_size=size.small)
table.cell(t, 1, 5, str.tostring(shortSL, "#.##"), text_color=color.orange, text_size=size.small)
// ==================== ALERTS ====================
// Main entry alerts
alertcondition(longSignal, "Long Entry", "7/19 EMA: LONG Signal")
alertcondition(shortSignal, "Short Entry", "7/19 EMA: SHORT Signal")
// Raw crossover alerts (ignore Saturday filter)
alertcondition(bullishCross, "Bullish Crossover (Any)", "7/19 EMA: Bullish Crossover")
alertcondition(bearishCross, "Bearish Crossover (Any)", "7/19 EMA: Bearish Crossover")
// Any signal alert (for single alert setup)
alertcondition(longSignal or shortSignal, "Any Signal", "7/19 EMA: Signal Triggered")
답변 1
예스스탁 예스스탁 답변
2025-12-23 10:21:56