niki's update
This commit is contained in:
parent
2093561046
commit
4078ed67fe
217
Niki/niki.pine
217
Niki/niki.pine
@ -1,152 +1,111 @@
|
|||||||
//@version=5
|
//@version=5
|
||||||
indicator("DrNiki's Market Nuker", shorttitle="DrNiki's Market Nuker", overlay=true)
|
indicator("Divergence Odds Calculator", shorttitle="DrNiki DivOdds", overlay=true)
|
||||||
|
|
||||||
// Relative Strength Index (RSI)
|
// Function to detect bullish divergence
|
||||||
|
bullishDivergence(src, refSrc, rsiSrc, overboughtLevel, oversoldLevel) =>
|
||||||
|
priceHigh = ta.highest(src, 5)
|
||||||
|
rsiHigh = ta.highest(rsiSrc, 5)
|
||||||
|
priceLow = ta.lowest(src, 5)
|
||||||
|
rsiLow = ta.lowest(rsiSrc, 5)
|
||||||
|
|
||||||
|
priceDiv = (src > priceHigh[1] and rsiSrc > rsiHigh[1]) ? true : false
|
||||||
|
rsiDiv = (rsiSrc > rsiHigh[1] and src > priceHigh[1]) ? true : false
|
||||||
|
|
||||||
|
priceDiv or rsiDiv
|
||||||
|
|
||||||
|
// Function to detect bearish divergence
|
||||||
|
bearishDivergence(src, refSrc, rsiSrc, overboughtLevel, oversoldLevel) =>
|
||||||
|
priceHigh = ta.highest(src, 5)
|
||||||
|
rsiHigh = ta.highest(rsiSrc, 5)
|
||||||
|
priceLow = ta.lowest(src, 5)
|
||||||
|
rsiLow = ta.lowest(rsiSrc, 5)
|
||||||
|
|
||||||
|
priceDiv = (src < priceLow[1] and rsiSrc < rsiLow[1]) ? true : false
|
||||||
|
rsiDiv = (rsiSrc < rsiLow[1] and src < priceLow[1]) ? true : false
|
||||||
|
|
||||||
|
priceDiv or rsiDiv
|
||||||
|
|
||||||
|
// RSI settings
|
||||||
rsiLength = input(14, title="RSI Length")
|
rsiLength = input(14, title="RSI Length")
|
||||||
rsiValue = ta.rsi(close, rsiLength)
|
rsiOverbought = input(70, title="RSI Overbought Level")
|
||||||
|
rsiOversold = input(30, title="RSI Oversold Level")
|
||||||
|
rsiSrc = ta.rsi(close, rsiLength)
|
||||||
|
|
||||||
// Stochastic RSI
|
// Calculate the number of occurrences of bullish and bearish divergences for different periods
|
||||||
stochRsiLength = input(14, title="Stochastic RSI Length")
|
bullishCount1 = ta.barssince(bullishDivergence(close, close[1], rsiSrc, rsiOverbought, rsiOversold))[1] + 1
|
||||||
stochRsiValue = ta.stoch(close, close, close, stochRsiLength)
|
bearishCount1 = ta.barssince(bearishDivergence(close, close[1], rsiSrc, rsiOverbought, rsiOversold))[1] + 1
|
||||||
|
|
||||||
// Wavetrend Indicator
|
bullishCount2 = ta.barssince(bullishDivergence(close, close[1], rsiSrc, rsiOverbought, rsiOversold))[2] + 1
|
||||||
n1 = input(10, "Channel Length")
|
bearishCount2 = ta.barssince(bearishDivergence(close, close[1], rsiSrc, rsiOverbought, rsiOversold))[2] + 1
|
||||||
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
|
bullishCount3 = ta.barssince(bullishDivergence(close, close[1], rsiSrc, rsiOverbought, rsiOversold))[3] + 1
|
||||||
esa = ta.ema(ap, n1)
|
bearishCount3 = ta.barssince(bearishDivergence(close, close[1], rsiSrc, rsiOverbought, rsiOversold))[3] + 1
|
||||||
d = ta.ema(math.abs(ap - esa), n1)
|
|
||||||
ci = (ap - esa) / (0.015 * d)
|
|
||||||
tci = ta.ema(ci, n2)
|
|
||||||
|
|
||||||
wt1 = tci
|
bullishCount5 = ta.barssince(bullishDivergence(close, close[1], rsiSrc, rsiOverbought, rsiOversold))[5] + 1
|
||||||
wt2 = ta.sma(wt1, 4)
|
bearishCount5 = ta.barssince(bearishDivergence(close, close[1], rsiSrc, rsiOverbought, rsiOversold))[5] + 1
|
||||||
|
|
||||||
// Custom implementation of On Balance Volume (OBV)
|
bullishCount10 = ta.barssince(bullishDivergence(close, close[1], rsiSrc, rsiOverbought, rsiOversold))[10] + 1
|
||||||
var float obv = na
|
bearishCount10 = ta.barssince(bearishDivergence(close, close[1], rsiSrc, rsiOverbought, rsiOversold))[10] + 1
|
||||||
obv := close > close[1] ? obv + volume : close < close[1] ? obv - volume : obv
|
|
||||||
|
|
||||||
// Money Flow Index (MFI)
|
bullishCount20 = ta.barssince(bullishDivergence(close, close[1], rsiSrc, rsiOverbought, rsiOversold))[20] + 1
|
||||||
mfiLength = input(7, title="MFI Length")
|
bearishCount20 = ta.barssince(bearishDivergence(close, close[1], rsiSrc, rsiOverbought, rsiOversold))[20] + 1
|
||||||
mfiValue = ta.mfi(close, mfiLength)
|
|
||||||
|
|
||||||
|
// Calculate odds based on the occurrences of divergences
|
||||||
|
calcOdds(count, candles) =>
|
||||||
|
odds = (count / candles) * 100
|
||||||
|
odds
|
||||||
|
|
||||||
var logMessage = barTimeStr + "| Symbol: " + symbol + ", Long: " + str.tostring(longPoints) + ", Short: " + str.tostring(shortPoints)
|
// Normalize probabilities so they add up to 100%
|
||||||
log.info(logMessage)
|
normalizeProbabilities(bullish, bearish) =>
|
||||||
|
total = bullish + bearish
|
||||||
|
bullishProb = (bullish / total) * 100
|
||||||
|
bearishProb = (bearish / total) * 100
|
||||||
|
[bullishProb, bearishProb]
|
||||||
|
|
||||||
barTimeStr = str.format_time(time, "yyyy-MM-dd HH:mm:ss", "Europe/Sofia")
|
// Calculate odds for different candle periods
|
||||||
closeStr = str.tostring(close)
|
[bullishOdds1, bearishOdds1] = normalizeProbabilities(calcOdds(bullishCount1, 1), calcOdds(bearishCount1, 1))
|
||||||
log.info(barTimeStr + " close: " + closeStr)
|
[bullishOdds2, bearishOdds2] = normalizeProbabilities(calcOdds(bullishCount2, 2), calcOdds(bearishCount2, 2))
|
||||||
|
[bullishOdds3, bearishOdds3] = normalizeProbabilities(calcOdds(bullishCount3, 3), calcOdds(bearishCount3, 3))
|
||||||
|
[bullishOdds5, bearishOdds5] = normalizeProbabilities(calcOdds(bullishCount5, 5), calcOdds(bearishCount5, 5))
|
||||||
|
[bullishOdds10, bearishOdds10] = normalizeProbabilities(calcOdds(bullishCount10, 10), calcOdds(bearishCount10, 10))
|
||||||
|
[bullishOdds20, bearishOdds20] = normalizeProbabilities(calcOdds(bullishCount20, 20), calcOdds(bearishCount20, 20))
|
||||||
|
|
||||||
// Initialize points for BTCUSDT.P
|
// Calculate total odds for the selected candle periods
|
||||||
longPointsRSIBTC = close > close[1] ? 1 : 0
|
totalBullishOdds = bullishOdds1 + bullishOdds2 + bullishOdds3 + bullishOdds5 + bullishOdds10 + bullishOdds20
|
||||||
shortPointsRSIBTC = close < close[1] ? 1 : 0
|
totalBearishOdds = bearishOdds1 + bearishOdds2 + bearishOdds3 + bearishOdds5 + bearishOdds10 + bearishOdds20
|
||||||
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
|
// New totals
|
||||||
longPointsRSIDXY = close > close[1] ? 0 : 1
|
totalBullishOdds1_2 = bullishOdds1 + bullishOdds2
|
||||||
shortPointsRSIDXY = close < close[1] ? 0 : 1
|
totalBullishOdds1_2_3 = totalBullishOdds1_2 + bullishOdds3
|
||||||
longPointsStochRSIDXY = stochRsiValue > stochRsiValue[1] ? 0 : 1
|
totalBullishOdds1_2_3_5 = totalBullishOdds1_2_3 + bullishOdds5
|
||||||
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
|
totalBearishOdds1_2 = bearishOdds1 + bearishOdds2
|
||||||
longPointsRSIGOLD = close > close[1] ? 1 : 0
|
totalBearishOdds1_2_3 = totalBearishOdds1_2 + bearishOdds3
|
||||||
shortPointsRSIGOLD = close < close[1] ? 1 : 0
|
totalBearishOdds1_2_3_5 = totalBearishOdds1_2_3 + bearishOdds5
|
||||||
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
|
|
||||||
|
|
||||||
|
// Display odds information in a label
|
||||||
|
var labelOdds = label.new(na, na, "")
|
||||||
|
label.set_xy(labelOdds, bar_index, high)
|
||||||
|
label.set_text(labelOdds, "Odds:\nLast 1 Candle: Bullish " + str.tostring(bullishOdds1) + "%, Bearish " + str.tostring(bearishOdds1) + "%\nLast 2 Candles: Bullish " + str.tostring(bullishOdds2) + "%, Bearish " + str.tostring(bearishOdds2) + "%\nLast 3 Candles: Bullish " + str.tostring(bullishOdds3) + "%, Bearish " + str.tostring(bearishOdds3) + "%\nLast 5 Candles: Bullish " + str.tostring(bullishOdds5) + "%, Bearish " + str.tostring(bearishOdds5) + "%\nLast 10 Candles: Bullish " + str.tostring(bullishOdds10) + "%, Bearish " + str.tostring(bearishOdds10) + "%\nLast 20 Candles: Bullish " + str.tostring(bullishOdds20) + "%, Bearish " + str.tostring(bearishOdds20) + "%\nTotal: Bullish " + str.tostring(totalBullishOdds) + "%, Bearish " + str.tostring(totalBearishOdds) + "%\n\nNew Totals:\nTotal 1-2: Bullish " + str.tostring(totalBullishOdds1_2) + "%, Bearish " + str.tostring(totalBearishOdds1_2) + "%\nTotal 1-2-3: Bullish " + str.tostring(totalBullishOdds1_2_3) + "%, Bearish " + str.tostring(totalBearishOdds1_2_3) + "%\nTotal 1-2-3-5: Bullish " + str.tostring(totalBullishOdds1_2_3_5) + "%, Bearish " + str.tostring(totalBearishOdds1_2_3_5) + "%")
|
||||||
|
label.set_color(labelOdds, totalBullishOdds > totalBearishOdds ? color.new(color.green, 0) : color.new(color.red, 0))
|
||||||
|
label.set_style(labelOdds, label.style_label_left)
|
||||||
|
|
||||||
// Initialize points for US30
|
// Plotting
|
||||||
longPointsRSIUS30 = close > close[1] ? 1 : 0
|
plot(rsiSrc, title="RSI", color=color.new(color.blue, 0), linewidth=2)
|
||||||
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)
|
// Plot green flag if total bullish odds are 5 times higher than bearish odds
|
||||||
longPointsRSIPAIR = close > close[1] ? 1 : 0
|
plotshape(totalBullishOdds > 5 * totalBearishOdds, style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.small)
|
||||||
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
|
// Plot red flag if total bearish odds are 5 times higher than bullish odds
|
||||||
totalLongPointsBTC = longPointsRSIBTC + longPointsStochRSIBTC + longPointsWavetrendBTC
|
plotshape(totalBearishOdds > 5 * totalBullishOdds, style=shape.triangledown, location=location.belowbar, color=color.new(color.red, 0), size=size.small)
|
||||||
totalShortPointsBTC = shortPointsRSIBTC + shortPointsStochRSIBTC + shortPointsWavetrendBTC
|
|
||||||
|
|
||||||
totalLongPointsGOLD = longPointsRSIGOLD + longPointsStochRSIGOLD + longPointsWavetrendGOLD
|
// Plot diamond if total bullish odds are 6 times higher than bearish odds
|
||||||
totalShortPointsGOLD = shortPointsRSIGOLD + shortPointsStochRSIGOLD + shortPointsWavetrendGOLD
|
plotshape(totalBullishOdds > 6 * totalBearishOdds, style=shape.diamond, location=location.belowbar, color=color.new(color.blue, 0), size=size.small)
|
||||||
|
|
||||||
totalLongPointsDXY = longPointsRSIDXY + longPointsStochRSIDXY + longPointsWavetrendDXY
|
// Plot diamond if total bearish odds are 6 times higher than bullish odds
|
||||||
totalShortPointsDXY = shortPointsRSIDXY + shortPointsStochRSIDXY + shortPointsWavetrendDXY
|
plotshape(totalBearishOdds > 6 * totalBullishOdds, style=shape.diamond, location=location.belowbar, color=color.new(color.purple, 0), size=size.small)
|
||||||
|
|
||||||
totalLongPointsUS30 = longPointsRSIUS30 + longPointsStochRSIUS30 + longPointsWavetrendUS30
|
// Plot green flag for previous occurrences if total bullish odds are 5 times higher than bearish odds
|
||||||
totalShortPointsUS30 = shortPointsRSIUS30 + shortPointsStochRSIUS30 + shortPointsWavetrendUS30
|
plotshape(totalBullishOdds[1] > 5 * totalBearishOdds[1], style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.small)
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
// Plot red
|
93
Niki/old/new.pine
Normal file
93
Niki/old/new.pine
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
//@version=5
|
||||||
|
indicator("DrNiki's Market Nuker", shorttitle="DrNiki's Market Nuker", overlay=true)
|
||||||
|
|
||||||
|
// Function to calculate RSI
|
||||||
|
rsiLength = input(14, title="RSI Length")
|
||||||
|
calcRSI() => ta.rsi(close, rsiLength)
|
||||||
|
|
||||||
|
// Function to calculate Stochastic RSI
|
||||||
|
stochRsiLength = input(14, title="Stochastic RSI Length")
|
||||||
|
calcStochRSI() => ta.stoch(close, close, close, stochRsiLength)
|
||||||
|
|
||||||
|
// Function to calculate Wavetrend
|
||||||
|
n1 = input(10, "Channel Length")
|
||||||
|
n2 = input(21, "Average Length")
|
||||||
|
calcWavetrend() =>
|
||||||
|
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)
|
||||||
|
[wt1, wt2]
|
||||||
|
|
||||||
|
// Function to calculate On Balance Volume (OBV)
|
||||||
|
calcOBV() =>
|
||||||
|
var float obv = na
|
||||||
|
obv := close > close[1] ? obv + volume : close < close[1] ? obv - volume : obv
|
||||||
|
obv
|
||||||
|
|
||||||
|
// Function to calculate MFI
|
||||||
|
mfiLength = input(7, title="MFI Length")
|
||||||
|
calcMFI() => ta.mfi(close, mfiLength)
|
||||||
|
|
||||||
|
// Function to calculate points for a symbol
|
||||||
|
calcPoints(symbol) =>
|
||||||
|
rsiValue = calcRSI()
|
||||||
|
stochRsiValue = calcStochRSI()
|
||||||
|
[wt1, wt2] = calcWavetrend()
|
||||||
|
obv = calcOBV()
|
||||||
|
mfiValue = calcMFI()
|
||||||
|
|
||||||
|
longPoints = 0
|
||||||
|
shortPoints = 0
|
||||||
|
longPoints := rsiValue > rsiValue[1] ? longPoints + 1 : longPoints
|
||||||
|
shortPoints := rsiValue < rsiValue[1] ? shortPoints + 1 : shortPoints
|
||||||
|
longPoints := stochRsiValue > stochRsiValue[1] ? longPoints + 1 : longPoints
|
||||||
|
shortPoints := stochRsiValue < stochRsiValue[1] ? shortPoints + 1 : shortPoints
|
||||||
|
longPoints := wt1 > wt1[1] ? longPoints + 1 : longPoints
|
||||||
|
shortPoints := wt1 < wt1[1] ? shortPoints + 1 : shortPoints
|
||||||
|
longPoints := obv > obv[1] ? longPoints + 1 : longPoints
|
||||||
|
shortPoints := obv < obv[1] ? shortPoints + 1 : shortPoints
|
||||||
|
longPoints := mfiValue > 50 ? longPoints + 1 : longPoints
|
||||||
|
shortPoints := mfiValue < 50 ? shortPoints + 1 : shortPoints
|
||||||
|
var logMessage = "Symbol: " + symbol + ", RSI: " + str.tostring(rsiValue)
|
||||||
|
+ ", StochRSI: " + str.tostring(stochRsiValue)
|
||||||
|
+ ", WT1: " + str.tostring(wt1)
|
||||||
|
+ ", OBV: " + str.tostring(obv)
|
||||||
|
+ ", MFI: " + str.tostring(mfiValue)
|
||||||
|
+ ", Long: " + str.tostring(longPoints) + ", Short: " + str.tostring(shortPoints)
|
||||||
|
log.info(logMessage)
|
||||||
|
[longPoints, shortPoints]
|
||||||
|
|
||||||
|
// Symbols array
|
||||||
|
symbols = array.new_string(5)
|
||||||
|
array.set(symbols, 0, syminfo.tickerid)
|
||||||
|
array.set(symbols, 1, "GOLD")
|
||||||
|
array.set(symbols, 2, "DXY")
|
||||||
|
array.set(symbols, 3, "BTCUSDT.P")
|
||||||
|
array.set(symbols, 4, "US30" )
|
||||||
|
|
||||||
|
// Calculate points for each symbol
|
||||||
|
var symbolPoints = array.new_int(2, 0)
|
||||||
|
for symbol in symbols
|
||||||
|
// Change symbol context using security() function
|
||||||
|
[longPoints, shortPoints] = calcPoints(symbol)
|
||||||
|
var logMessage = "Symbol: " + symbol + ", Long: " + str.tostring(longPoints) + ", Short: " + str.tostring(shortPoints)
|
||||||
|
log.info(logMessage)
|
||||||
|
array.set(symbolPoints, 0, array.get(symbolPoints, 0) + longPoints)
|
||||||
|
array.set(symbolPoints, 1, array.get(symbolPoints, 1) + shortPoints)
|
||||||
|
|
||||||
|
// Calculate total long and short probabilities
|
||||||
|
totalLongPoints = array.get(symbolPoints, 0)
|
||||||
|
totalShortPoints = array.get(symbolPoints, 1)
|
||||||
|
combinedProbabilityLong = totalLongPoints / (array.size(symbols) * 3) * 100
|
||||||
|
combinedProbabilityShort = totalShortPoints / (array.size(symbols) * 3) * 100
|
||||||
|
|
||||||
|
// Display combined probabilities
|
||||||
|
var labelBox = label.new(na, na, "")
|
||||||
|
label.set_xy(labelBox, bar_index, high)
|
||||||
|
label.set_text(labelBox, "Combined Probabilities\nLong: " + str.tostring(combinedProbabilityLong) + "%\nShort: " + str.tostring(combinedProbabilityShort) + "%")
|
||||||
|
label.set_color(labelBox, color.new(color.blue, 0))
|
||||||
|
label.set_style(labelBox, label.style_label_left)
|
151
Niki/old/niki.pine
Normal file
151
Niki/old/niki.pine
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
//@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
|
||||||
|
//log time and close
|
||||||
|
//log.info("close: " + str.tostring(close))
|
||||||
|
// get time formatted
|
||||||
|
timeStr = time(timeframe.period, "YYYY-MM-DD HH:mm:ss")
|
||||||
|
log.info("time: " + str.tostring(time) + " close: " + str.tostring(close) + " longPointsRSIBTC: " + str.tostring(longPointsRSIBTC) + " shortPointsRSIBTC: " + str.tostring(shortPointsRSIBTC) + " longPointsStochRSIBTC: " + str.tostring(longPointsStochRSIBTC) + " shortPointsStochRSIBTC: " + str.tostring(shortPointsStochRSIBTC) + " longPointsWavetrendBTC: " + str.tostring(longPointsWavetrendBTC) + " shortPointsWavetrendBTC: " + str.tostring(shortPointsWavetrendBTC) + " longPointsOBVBTC: " + str.tostring(longPointsOBVBTC) + " shortPointsOBVBTC: " + str.tostring(shortPointsOBVBTC) + " longPointsMFIBTC: " + str.tostring(longPointsMFIBTC) + " shortPointsMFIBTC: " + str.tostring(shortPointsMFIBTC))
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user