Ads Top

Gold Selling Oscillator

Built by Grok 
Working?

//@version=6
indicator("ML Gold Selling Oscillator", shorttitle="MLGSO", overlay=false)

// Inputs
rsiLength = input.int(14, "RSI Length", minval=1)
momLength = input.int(10, "Momentum Length", minval=1)
lookback = input.int(50, "Lookback Period for Dynamic Threshold", minval=10)
sellThreshold = input.float(70, "Base Sell Threshold", minval=0, maxval=100)
smoothLength = input.int(5, "Smoothing Length", minval=1)

// Core Calculations
rsi = ta.rsi(close, rsiLength)
mom = ta.mom(close, momLength)

// Safeguard for momentum normalization
momHigh = ta.highest(mom, lookback)
momLow = ta.lowest(mom, lookback)
momRange = momHigh - momLow
momNorm = momRange == 0 ? 50 : 100 * (mom - momLow) / momRange

// Dynamic threshold
rsiHigh = ta.highest(rsi, lookback)
dynamicThreshold = rsiHigh * 0.9

// Oscillator calculation
oscillatorRaw = (rsi + momNorm) / 2
oscillator = ta.sma(oscillatorRaw, smoothLength)

// Sell signal
sellSignal = oscillator > math.max(dynamicThreshold, sellThreshold)

// Plotting
plot(oscillator, "ML Gold Oscillator", color=color.blue, linewidth=2)
plot(sellThreshold, "Static Sell Threshold", color=color.red, style=plot.style_dashed)
plot(dynamicThreshold, "Dynamic Threshold", color=color.orange, style=plot.style_dashed)
hline(50, "Midline", color=color.gray, linestyle=hline.style_dotted)
plotshape(sellSignal, "Sell Signal", style=shape.triangledown, color=color.red, size=size.small)

// Alert
alertcondition(sellSignal, "Advanced Sell Signal", "Gold Selling Opportunity Detected")

No comments:

Powered by Blogger.