This commit is contained in:
Dobromir Popov 2024-01-12 15:38:26 +02:00
parent 40968f95ad
commit 5af8896e40
2 changed files with 68 additions and 42 deletions

View File

@ -1,52 +1,75 @@
//@version=4 //@version=5
study("DrNiki Nuke", shorttitle="DrNiki Nuke", overlay=true) indicator("DrNiki's Market Nuker", shorttitle="DrNiki's Market Nuker", overlay=true)
// Define pairs and timeframes // Input for Indicators
string[] pairs = ["US30", "GOLD", "DXY", "BTCUSDT.P", syminfo.ticker] rsiLength = input(14, title="RSI Length")
int[] timeframes = [60, 120, 180, 240] // Timeframes in minutes stochRsiLength = input(14, title="Stochastic RSI Length")
n1 = input(10, title="WT Channel Length")
n2 = input(21, title="WT Average Length")
// Initialize variables for odds and points // Wavetrend Indicator Calculation
var float[] longOdds = array.new_float(0) ap = hlc3
var float[] shortOdds = array.new_float(0) 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)
// RSI and Stochastic RSI Calculation
rsiValue = ta.rsi(close, rsiLength)
stochRsiValue = ta.stoch(rsiValue, rsiValue, rsiValue, stochRsiLength)
wavetrendPoints(pair, timeframe) => // Function to calculate points for a given indicator and pair
wt1 = ... // Your calculation for wavetrend wt1 here calcPoints(currentValue, previousValue, isInverse) =>
wt1[0] > wt1[1] ? 1 : wt1[0] < wt1[1] ? -1 : 0 if isInverse
currentValue < previousValue ? 1 : currentValue > previousValue ? -1 : 0
else
currentValue > previousValue ? 1 : currentValue < previousValue ? -1 : 0
rsiPoints(pair, timeframe) => // Calculate points for each currency pair
rsiValue = rsi(close, 14) // Example: using 14 periods for RSI longPoints(pair, isInverse) =>
rsiValue[0] > rsiValue[1] ? 1 : rsiValue[0] < rsiValue[1] ? -1 : 0 rsiP = calcPoints(rsiValue, rsiValue[1], isInverse)
stochRsiP = calcPoints(stochRsiValue, stochRsiValue[1], isInverse)
wavetrendP = calcPoints(wt1, wt1[1], isInverse)
rsiP + stochRsiP + wavetrendP
stochRsiKPoints(pair, timeframe) => shortPoints(pair, isInverse) => -longPoints(pair, isInverse)
K = stoch(close, high, low, 14) // Example: using 14 periods for Stoch RSI
K[0] > K[1] ? 1 : K[0] < K[1] ? -1 : 0
obvPoints(pair, timeframe) => // Pairs and their corresponding inverse flag
obvValue = obv(close, volume) var pairs = array.new_string(5)
obvValue[0] > obvValue[1] ? 1 : obvValue[0] < obvValue[1] ? -1 : 0 var isInverse = array.new_bool(5)
array.set(pairs, 0, "US30")
array.set(pairs, 1, "GOLD")
array.set(pairs, 2, "DXY") // DXY is inversed
array.set(pairs, 3, "BTCUSDT.P")
array.set(pairs, 4, syminfo.ticker)
array.set(isInverse, 0, false)
array.set(isInverse, 1, false)
array.set(isInverse, 2, true) // Inverse for DXY
array.set(isInverse, 3, false)
array.set(isInverse, 4, false)
// Initialize arrays for storing points
var longPointsArray = array.new_float(size = 5, initial_value = 0)
var shortPointsArray = array.new_float(size = 5, initial_value = 0)
// Function to calculate points for indicators // Calculate points for each pair
calcPoints(indicator, current, previous) => for i = 0 to array.size(pairs) - 1
pair = array.get(pairs, i)
inverseFlag = array.get(isInverse, i)
array.set(longPointsArray, i, longPoints(pair, inverseFlag))
array.set(shortPointsArray, i, shortPoints(pair, inverseFlag))
// Calculate total points
totalLongPoints = array.sum(longPointsArray)
totalShortPoints = array.sum(shortPointsArray)
// Main Calculation Loop // Display the results
for pair in pairs for i = 0 to array.size(pairs) - 1
for timeframe in timeframes pair = array.get(pairs, i)
// Switch to pair and timeframe plot(array.get(longPointsArray, i), title="Long Points " + pair, color=color.green)
... plot(array.get(shortPointsArray, i), title="Short Points " + pair, color=color.red)
// Calculate points for each indicator
longPoints = calcPoints(wt1, ...) + calcPoints(rsi, ...) + ...
shortPoints = calcPoints(wt1, ...) + calcPoints(rsi, ...) + ...
// Inverse for DXY
if pair == "DXY"
...
// Normalize to get odds
longOdds = ...
shortOdds = ...
// Display results
...
// Combine and display most efficient combinations plot(totalLongPoints, title="Total Long Points", color=color.blue)
... plot(totalShortPoints, title="Total Short Points", color=color.orange)

View File

@ -26,6 +26,9 @@ tci = ta.ema(ci, n2)
wt1 = tci wt1 = tci
wt2 = ta.sma(wt1, 4) wt2 = ta.sma(wt1, 4)
//calculate obv
obv = ta.obv(close, volume)
// Initialize points for BTCUSDT.P // Initialize points for BTCUSDT.P
longPointsRSIBTC = close > close[1] ? 1 : 0 longPointsRSIBTC = close > close[1] ? 1 : 0
shortPointsRSIBTC = close < close[1] ? 1 : 0 shortPointsRSIBTC = close < close[1] ? 1 : 0