PROTECTED SOURCE SCRIPT

Momentum Alpha Gold (With Current Price Tag)

61
//version=6
indicator("Momentum Alpha Gold (With Current Price Tag)", overlay=true, max_labels_count=500)

// === Inputs ===
emaFastLen = input.int(20, "Fast EMA Length")
emaSlowLen = input.int(50, "Slow EMA Length")
supertrendFactor = input.float(2.0, "Supertrend Factor")
supertrendATR = input.int(10, "Supertrend ATR Period")
atrPeriod = input.int(14, "ATR Period for SL/TP")

// === EMA & Supertrend ===
emaFast = ta.ema(close, emaFastLen)
emaSlow = ta.ema(close, emaSlowLen)
[supertrendLine, direction] = ta.supertrend(supertrendFactor, supertrendATR)

trendBull = (emaFast > emaSlow) or direction == 1
trendBear = (emaFast < emaSlow) or direction == -1

// === Buy/Sell Signals ===
coUp = ta.crossover(close, emaFast)
coDown = ta.crossunder(close, emaFast)
buySignal = trendBull and coUp
sellSignal = trendBear and coDown

// === ATR-based Levels ===
atr = ta.atr(atrPeriod)

var float SL = na
var float TP1 = na
var float TP2 = na
var float TP3 = na
var float ReEntry = na
var float MartingaleSL = na

if buySignal
SL := close - atr
TP1 := close + (close - SL)
TP2 := close + 2 * (close - SL)
TP3 := close + 3 * (close - SL)
ReEntry := close - 0.5 * (close - SL)
MartingaleSL := SL - 0.5 * (close - SL)

if sellSignal
SL := close + atr
TP1 := close - (SL - close)
TP2 := close - 2 * (SL - close)
TP3 := close - 3 * (SL - close)
ReEntry := close + 0.5 * (SL - close)
MartingaleSL := SL + 0.5 * (SL - close)

// === Colors ===
neonBlue = color.new(color.aqua, 0) // Momentum Buy
neonPink = color.new(color.fuchsia, 0) // Momentum Sell
neonRed = color.new(color.red, 0) // Stoploss
neonOrange = color.new(color.orange, 0) // Martingale Entry
neonYellow = color.new(color.yellow, 0) // Instant Entry
neonGreen = color.new(color.lime, 0) // Take Profits
currentBlue = color.new(color.blue, 0) // Current Price

// === Arrays for Dynamic Labels ===
var label[] activeLabels = array.new<label>()
var line[] activeLines = array.new<line>()
priceFmt(p) => str.tostring(p, "#.###")

// === Draw Box Function (Label + Line) ===
drawBox(price, labelText, col) =>
offset = 3
ln = line.new(bar_index + offset, price, bar_index + 40, price, color=col, width=2)
lbl = label.new(bar_index + offset, price,
labelText + " : " + priceFmt(price),
style=label.style_label_left, size=size.normal,
textcolor=color.black, color=col)
array.push(activeLabels, lbl)
array.push(activeLines, ln)

// === Draw Current Price (styled like SL/TP) ===
drawCurrentPrice() =>
offset = 3
ln = line.new(bar_index + offset, close, bar_index + 40, close, color=currentBlue, width=2)
lbl = label.new(bar_index + offset, close,
"Current Price : " + priceFmt(close),
style=label.style_label_left, size=size.normal,
textcolor=color.white, color=currentBlue)
array.push(activeLabels, lbl)
array.push(activeLines, ln)

// === Clear and Redraw Labels Each Bar ===
if barstate.islast
for l in activeLabels
label.delete(l)
for ln in activeLines
line.delete(ln)
array.clear(activeLabels)
array.clear(activeLines)

if not na(SL) and not na(TP1)
drawBox(MartingaleSL, "Stoploss", neonRed)
drawBox(SL, "Martingale Entry", neonOrange)
drawBox(ReEntry, "Instant Entry", neonYellow)
drawBox(TP1, "TP1", neonGreen)
drawBox(TP2, "TP2", neonGreen)
drawBox(TP3, "TP3", neonGreen)
drawCurrentPrice() // Adds Current Price tag in same style

// === Momentum Buy/Sell Markers ===
plotshape(buySignal, title="Momentum Buy", location=location.belowbar,
color=neonBlue, style=shape.labelup, text="Momentum Buy", textcolor=color.black)

plotshape(sellSignal, title="Momentum Sell", location=location.abovebar,
color=neonPink, style=shape.labeldown, text="Momentum Sell", textcolor=color.black)

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.