fix pines

This commit is contained in:
Dobromir Popov 2024-01-12 16:56:05 +02:00
parent bae87ad380
commit 5ef4bad84c
2 changed files with 72 additions and 33 deletions

View File

@ -1,7 +1,7 @@
//@version=4
study("DrNiki's Market Nuker", shorttitle="DrNiki's Market Nuker", overlay=true)
//@version=5
indicator("DrNiki's Market Nuker", shorttitle="DrNiki's Market Nuker", overlay=true)
// Input for Indicators
// [Input for Indicators]
rsiLength = input(14, title="RSI Length")
stochRsiLength = input(14, title="Stochastic RSI Length")
n1 = input(10, title="WT Channel Length")
@ -9,16 +9,29 @@ n2 = input(21, title="WT Average Length")
// Wavetrend Indicator Calculation
ap = hlc3
esa = ema(ap, n1)
d = ema(abs(ap - esa), n1)
esa = ta.ema(ap, n1)
d = ta.ema(math.abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * d)
tci = ema(ci, n2)
tci = ta.ema(ci, n2)
wt1 = tci
wt2 = sma(wt1, 4)
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)
// RSI and Stochastic RSI Calculation
rsiValue = rsi(close, rsiLength)
stochRsiValue = stoch(rsiValue, rsiValue, rsiValue, stochRsiLength)
rsiValue = ta.rsi(close, rsiLength)
stochRsiValue = ta.stoch(rsiValue, rsiValue, rsiValue, stochRsiLength)
// [Function to calculate points for a given indicator and pair]
// Function to calculate points for a given indicator and pair
calcPoints(currentValue, previousValue, isInverse) =>
@ -38,6 +51,7 @@ longPoints(pair, isInverse) =>
shortPoints(pair, isInverse) => -longPoints(pair, isInverse)
// Hardcoded pairs and their corresponding inverse flags
pairs = array.new_string(5)
array.set(pairs, 0, "US30")
@ -54,18 +68,22 @@ var float totalLongPoints = 0
var float totalShortPoints = 0
// Calculate points for each pair
longPointsArray = array.new_float(5)
shortPointsArray = array.new_float(5)
for i = 0 to 4
pair = array.get(pairs, i)
inverseFlag = array.get(isInverse, i)
totalLongPoints := totalLongPoints + longPoints(pair, inverseFlag)
totalShortPoints := totalShortPoints + shortPoints(pair, inverseFlag)
array.set(longPointsArray, i, longPoints(pair, inverseFlag))
array.set(shortPointsArray, i, shortPoints(pair, inverseFlag))
// Update total points
for i = 0 to 4
totalLongPoints := totalLongPoints + array.get(longPointsArray, i)
totalShortPoints := totalShortPoints + array.get(shortPointsArray, i)
// Display the results
plot(totalLongPoints, title="Total Long Points", color=color.blue)
plot(totalShortPoints, title="Total Short Points", color=color.orange)
// BUYING VOLUME AND SELLING VOLUME
buyVolume = high == low ? 0 : volume * (close - low) / (high - low)
sellVolume = high == low ? 0 : volume * (high - close) / (high - low)
plot(volume, style=plot.style_columns, color=color.red, title="SELL V") // shows total volume
plot(buyVolume, style=plot.style_columns, color=color.teal, title="BUY V") // shows only buy volume
// Display

View File

@ -26,13 +26,13 @@ tci = ta.ema(ci, n2)
wt1 = tci
wt2 = ta.sma(wt1, 4)
//calculate obv
obv = ta.obv(close, volume)
//15:38:24 Error at 30:7 Could not find function or function reference 'ta.obv'
//calculate mfi
mfi = ta.mfi(high, low, close, volume)
// 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
@ -41,14 +41,22 @@ 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] ? 1 : 0
shortPointsRSIDXY = close < close[1] ? 1 : 0
longPointsStochRSIDXY = stochRsiValue > stochRsiValue[1] ? 1 : 0
shortPointsStochRSIDXY = stochRsiValue < stochRsiValue[1] ? 1 : 0
longPointsWavetrendDXY = wt1 < wt1[1] ? 1 : 0 // Inversed for DXY
shortPointsWavetrendDXY = wt1 > wt1[1] ? 1 : 0 // Inversed 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
@ -57,6 +65,11 @@ 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
@ -65,6 +78,10 @@ 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
@ -73,10 +90,10 @@ longPointsStochRSIPAIR = stochRsiValue > stochRsiValue[1] ? 1 : 0
shortPointsStochRSIPAIR = stochRsiValue < stochRsiValue[1] ? 1 : 0
longPointsWavetrendPAIR = wt1 > wt1[1] ? 1 : 0
shortPointsWavetrendPAIR = wt1 < wt1[1] ? 1 : 0
// Adjust the total points calculation for DXY
totalLongPointsDXY = longPointsRSIDXY + longPointsStochRSIDXY + shortPointsWavetrendDXY
totalShortPointsDXY = shortPointsRSIDXY + shortPointsStochRSIDXY + longPointsWavetrendDXY
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
@ -85,6 +102,9 @@ totalShortPointsBTC = shortPointsRSIBTC + shortPointsStochRSIBTC + shortPointsWa
totalLongPointsGOLD = longPointsRSIGOLD + longPointsStochRSIGOLD + longPointsWavetrendGOLD
totalShortPointsGOLD = shortPointsRSIGOLD + shortPointsStochRSIGOLD + shortPointsWavetrendGOLD
totalLongPointsDXY = longPointsRSIDXY + longPointsStochRSIDXY + longPointsWavetrendDXY
totalShortPointsDXY = shortPointsRSIDXY + shortPointsStochRSIDXY + shortPointsWavetrendDXY
totalLongPointsUS30 = longPointsRSIUS30 + longPointsStochRSIUS30 + longPointsWavetrendUS30
totalShortPointsUS30 = shortPointsRSIUS30 + shortPointsStochRSIUS30 + shortPointsWavetrendUS30
@ -121,3 +141,4 @@ 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)