gogo2/Niki/niki.pine
2024-01-12 16:56:05 +02:00

145 lines
6.6 KiB
Plaintext

//@version=5
indicator("DrNiki's Market Nuker", shorttitle="DrNiki's Market Nuker", overlay=true)
// Relative Strength Index (RSI)
rsiLength = input(14, title="RSI Length")
rsiValue = ta.rsi(close, rsiLength)
// Stochastic RSI
stochRsiLength = input(14, title="Stochastic RSI Length")
stochRsiValue = ta.stoch(close, close, close, stochRsiLength)
// Wavetrend Indicator
n1 = input(10, "Channel Length")
n2 = input(21, "Average Length")
obLevel1 = input(60, "Over Bought Level 1")
obLevel2 = input(53, "Over Bought Level 2")
osLevel1 = input(-60, "Over Sold Level 1")
osLevel2 = input(-53, "Over Sold Level 2")
ap = hlc3
esa = ta.ema(ap, n1)
d = ta.ema(math.abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * d)
tci = ta.ema(ci, n2)
wt1 = tci
wt2 = ta.sma(wt1, 4)
// Custom implementation of On Balance Volume (OBV)
var float obv = na
obv := close > close[1] ? obv + volume : close < close[1] ? obv - volume : obv
// Money Flow Index (MFI)
mfiLength = input(7, title="MFI Length")
mfiValue = ta.mfi(close, mfiLength)
// Initialize points for BTCUSDT.P
longPointsRSIBTC = close > close[1] ? 1 : 0
shortPointsRSIBTC = close < close[1] ? 1 : 0
longPointsStochRSIBTC = stochRsiValue > stochRsiValue[1] ? 1 : 0
shortPointsStochRSIBTC = stochRsiValue < stochRsiValue[1] ? 1 : 0
longPointsWavetrendBTC = wt1 > wt1[1] ? 1 : 0
shortPointsWavetrendBTC = wt1 < wt1[1] ? 1 : 0
longPointsOBVBTC = obv > obv[1] ? 1 : 0
shortPointsOBVBTC = obv < obv[1] ? 1 : 0
longPointsMFIBTC = mfiValue > 50 ? 1 : 0
shortPointsMFIBTC = mfiValue < 50 ? 1 : 0
// Initialize points for DXY
longPointsRSIDXY = close > close[1] ? 0 : 1
shortPointsRSIDXY = close < close[1] ? 0 : 1
longPointsStochRSIDXY = stochRsiValue > stochRsiValue[1] ? 0 : 1
shortPointsStochRSIDXY = stochRsiValue < stochRsiValue[1] ? 0 : 1
longPointsWavetrendDXY = wt1 < wt1[1] ? 0 : 1
shortPointsWavetrendDXY = wt1 > wt1[1] ? 0 : 1
longPointsOBVDXY = obv > obv[1] ? 0 : 1
shortPointsOBVDXY = obv < obv[1] ? 0 : 1
longPointsMFIDXY = mfiValue > 50 ? 0 : 1
shortPointsMFIDXY = mfiValue < 50 ? 0 : 1
// Initialize points for GOLD
longPointsRSIGOLD = close > close[1] ? 1 : 0
shortPointsRSIGOLD = close < close[1] ? 1 : 0
longPointsStochRSIGOLD = stochRsiValue > stochRsiValue[1] ? 1 : 0
shortPointsStochRSIGOLD = stochRsiValue < stochRsiValue[1] ? 1 : 0
longPointsWavetrendGOLD = wt1 > wt1[1] ? 1 : 0
shortPointsWavetrendGOLD = wt1 < wt1[1] ? 1 : 0
longPointsOBVGOLD = obv > obv[1] ? 1 : 0
shortPointsOBVGOLD = obv < obv[1] ? 1 : 0
longPointsMFIGOLD = mfiValue > 50 ? 1 : 0
shortPointsMFIGOLD = mfiValue < 50 ? 1 : 0
// Initialize points for US30
longPointsRSIUS30 = close > close[1] ? 1 : 0
shortPointsRSIUS30 = close < close[1] ? 1 : 0
longPointsStochRSIUS30 = stochRsiValue > stochRsiValue[1] ? 1 : 0
shortPointsStochRSIUS30 = stochRsiValue < stochRsiValue[1] ? 1 : 0
longPointsWavetrendUS30 = wt1 > wt1[1] ? 1 : 0
shortPointsWavetrendUS30 = wt1 < wt1[1] ? 1 : 0
longPointsOBVUS30 = obv > obv[1] ? 1 : 0
shortPointsOBVUS30 = obv < obv[1] ? 1 : 0
longPointsMFIUS30 = mfiValue > 50 ? 1 : 0
shortPointsMFIUS30 = mfiValue < 50 ? 1 : 0
// Initialize points for the current trading pair (syminfo.ticker)
longPointsRSIPAIR = close > close[1] ? 1 : 0
shortPointsRSIPAIR = close < close[1] ? 1 : 0
longPointsStochRSIPAIR = stochRsiValue > stochRsiValue[1] ? 1 : 0
shortPointsStochRSIPAIR = stochRsiValue < stochRsiValue[1] ? 1 : 0
longPointsWavetrendPAIR = wt1 > wt1[1] ? 1 : 0
shortPointsWavetrendPAIR = wt1 < wt1[1] ? 1 : 0
longPointsOBVPAIR = obv > obv[1] ? 1 : 0
shortPointsOBVPAIR = obv < obv[1] ? 1 : 0
longPointsMFIPAIR = mfiValue > 50 ? 1 : 0
shortPointsMFIPAIR = mfiValue < 50 ? 1 : 0
// Calculate total points for each symbol
totalLongPointsBTC = longPointsRSIBTC + longPointsStochRSIBTC + longPointsWavetrendBTC
totalShortPointsBTC = shortPointsRSIBTC + shortPointsStochRSIBTC + shortPointsWavetrendBTC
totalLongPointsGOLD = longPointsRSIGOLD + longPointsStochRSIGOLD + longPointsWavetrendGOLD
totalShortPointsGOLD = shortPointsRSIGOLD + shortPointsStochRSIGOLD + shortPointsWavetrendGOLD
totalLongPointsDXY = longPointsRSIDXY + longPointsStochRSIDXY + longPointsWavetrendDXY
totalShortPointsDXY = shortPointsRSIDXY + shortPointsStochRSIDXY + shortPointsWavetrendDXY
totalLongPointsUS30 = longPointsRSIUS30 + longPointsStochRSIUS30 + longPointsWavetrendUS30
totalShortPointsUS30 = shortPointsRSIUS30 + shortPointsStochRSIUS30 + shortPointsWavetrendUS30
totalLongPointsPAIR = longPointsRSIPAIR + longPointsStochRSIPAIR + longPointsWavetrendPAIR
totalShortPointsPAIR = shortPointsRSIPAIR + shortPointsStochRSIPAIR + shortPointsWavetrendPAIR
// Calculate total long and short probabilities for all symbols
totalLongPoints = totalLongPointsBTC + totalLongPointsDXY + totalLongPointsGOLD + totalLongPointsUS30 + totalLongPointsPAIR
totalShortPoints = totalShortPointsBTC + totalShortPointsDXY + totalShortPointsGOLD + totalShortPointsUS30 + totalShortPointsPAIR
// Calculate combined probabilities for each symbol
combinedProbabilityLongBTC = totalLongPointsBTC / 3 * 100
combinedProbabilityShortBTC = totalShortPointsBTC / 3 * 100
combinedProbabilityLongDXY = totalLongPointsDXY / 3 * 100
combinedProbabilityShortDXY = totalShortPointsDXY / 3 * 100
combinedProbabilityLongGOLD = totalLongPointsGOLD / 3 * 100
combinedProbabilityShortGOLD = totalShortPointsGOLD / 3 * 100
combinedProbabilityLongUS30 = totalLongPointsUS30 / 3 * 100
combinedProbabilityShortUS30 = totalShortPointsUS30 / 3 * 100
combinedProbabilityLongPAIR = totalLongPointsPAIR / 3 * 100
combinedProbabilityShortPAIR = totalShortPointsPAIR / 3 * 100
// Calculate combined probabilities for all symbols
combinedProbabilityLong = totalLongPoints / 15 * 100
combinedProbabilityShort = totalShortPoints / 15 * 100
// Display combined probabilities in a box at the top right corner
var labelBox = label.new(na, na, "")
label.set_xy(labelBox, bar_index, high)
label.set_text(labelBox, "Long: BTC " + str.tostring(combinedProbabilityLongBTC) + "%, DXY " + str.tostring(combinedProbabilityLongDXY) + "%, GOLD " + str.tostring(combinedProbabilityLongGOLD) + "%, US30 " + str.tostring(combinedProbabilityLongUS30) + "%, syminfo.ticker " + str.tostring(combinedProbabilityLongPAIR) + "%\nShort: BTC " + str.tostring(combinedProbabilityShortBTC) + "%, DXY " + str.tostring(combinedProbabilityShortDXY) + "%, GOLD " + str.tostring(combinedProbabilityShortGOLD) + "%, US30 " + str.tostring(combinedProbabilityShortUS30) + "%, syminfo.ticker " + str.tostring(combinedProbabilityShortPAIR) + "%\n\nTotal: Long " + str.tostring(combinedProbabilityLong) + "%, Short " + str.tostring(combinedProbabilityShort) + "%")
label.set_color(labelBox, color.new(color.blue, 0))
label.set_style(labelBox, label.style_label_left)