커뮤니티

지표 부탁 드립니다

프로필 이미지
매치다2
2025-12-20 20:52:28
122
글번호 229234
답변완료

//@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

안녕하세요 예스스탁입니다. input : fastLen(7); input : slowLen(19); input : slCandles(4); input : skipSaturday(true); input : showSLLevels(true); var : Ema7(0),Ema19(0); var : bullishCross(False),bearishCross(False); var : canTrade(0),longSL(0),shortSL(0); var : lowestLow3(0),lowestLow4(0),highestHigh3(0),highestHigh4(0); VAR : longSignal(False),shortSignal(False),skippedLong(False),skippedShort(False); ema7 = ema(close, fastLen); ema19 = ema(close, slowLen); bullishCross = CrossUp(ema7, ema19); bearishCross = CrossDown(ema7, ema19); canTrade = iff(skipSaturday ,IFf(dayofweek(sDate) != 6,1,0) ,1); lowestLow3 = min(low, min(low[1], low[2])); lowestLow4 = min(low, min(low[1], min(low[2], low[3]))); highestHigh3 = max(high, max(high[1], high[2])); highestHigh4 = max(high, max(high[1],max(high[2], high[3]))); longSL = iff(slCandles == 3 , lowestLow3 , lowestLow4); shortSL = iff(slCandles == 3 , highestHigh3 , highestHigh4); longSignal = bullishCross and canTrade == 1; shortSignal = bearishCross and canTrade == 1; skippedLong = bullishCross and canTrade == 0; skippedShort = bearishCross and canTrade == 0; var : trend(0),tx(0); if bullishCross Then trend = 1; if bearishCross Then trend = -1; plot1(ema7, "7 EMA", lime); plot2(ema19, "19 EMA", red); if longSignal == true Then { tx = Text_New(sDate,sTime,l,"▲"); Text_SetStyle(tx,2,0); Text_SetColor(tx,Lime); Text_SetSize(tx,20); } if shortSignal == true Then { tx = Text_New(sDate,sTime,h,"▼"); Text_SetStyle(tx,2,1); Text_SetColor(tx,Red); Text_SetSize(tx,20); } if skippedLong == true Then { tx = Text_New(sDate,sTime,l,"▲"); Text_SetStyle(tx,2,0); Text_SetColor(tx,Gray); Text_SetSize(tx,20); } if skippedShort == true Then { tx = Text_New(sDate,sTime,h,"▼"); Text_SetStyle(tx,2,1); Text_SetColor(tx,Gray); Text_SetSize(tx,20); } if showSLLevels and longSignal Then plot3(longSL,"Long SL",orange); Else NoPlot(3); if showSLLevels and shortSignal Then plot4(shortSL, "Short SL", orange); Else NoPlot(4); var : grid(0),str1(""); if Index == 0 Then Grid = Grid_New(1, 2, 5,Gray, Gray, 1, Gray, 0); if LastBarOnChart == 1 Then { if ema7 > ema19 Then str1 = "BULLISH"; Else str1 = "BEARISH"; Grid_Cell(Grid,0,0,"Trend:",0,0,BLACK,LightBlue); Grid_Cell(Grid,1,0,str1,0,0,BLACK,White); Grid_Cell(Grid,0,1,"EMA 7:",0,0,BLACK,LightBlue); Grid_Cell(Grid,1,1,ntostr(ema7,2),0,0,BLACK,White); Grid_Cell(Grid,0,2,"EMA19:",0,0,BLACK,LightBlue); Grid_Cell(Grid,1,2,ntostr(ema19,2),0,0,BLACK,White); Grid_Cell(Grid,0,3,"Long SL:",0,0,BLACK,LightBlue); Grid_Cell(Grid,1,3,ntostr(longSL,2),0,0,BLACK,White); Grid_Cell(Grid,0,4,"Short SL:",0,0,BLACK,LightBlue); Grid_Cell(Grid,1,4,ntostr(shortSL,2),0,0,BLACK,White); } 즐거운 하루되세요