changes
This commit is contained in:
parent
40968f95ad
commit
5af8896e40
@ -1,52 +1,75 @@
|
||||
//@version=4
|
||||
study("DrNiki Nuke", shorttitle="DrNiki Nuke", overlay=true)
|
||||
//@version=5
|
||||
indicator("DrNiki's Market Nuker", shorttitle="DrNiki's Market Nuker", overlay=true)
|
||||
|
||||
// Define pairs and timeframes
|
||||
string[] pairs = ["US30", "GOLD", "DXY", "BTCUSDT.P", syminfo.ticker]
|
||||
int[] timeframes = [60, 120, 180, 240] // Timeframes in minutes
|
||||
// Input for Indicators
|
||||
rsiLength = input(14, title="RSI Length")
|
||||
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
|
||||
var float[] longOdds = array.new_float(0)
|
||||
var float[] shortOdds = array.new_float(0)
|
||||
// Wavetrend Indicator Calculation
|
||||
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)
|
||||
|
||||
// RSI and Stochastic RSI Calculation
|
||||
rsiValue = ta.rsi(close, rsiLength)
|
||||
stochRsiValue = ta.stoch(rsiValue, rsiValue, rsiValue, stochRsiLength)
|
||||
|
||||
wavetrendPoints(pair, timeframe) =>
|
||||
wt1 = ... // Your calculation for wavetrend wt1 here
|
||||
wt1[0] > wt1[1] ? 1 : wt1[0] < wt1[1] ? -1 : 0
|
||||
// Function to calculate points for a given indicator and pair
|
||||
calcPoints(currentValue, previousValue, isInverse) =>
|
||||
if isInverse
|
||||
currentValue < previousValue ? 1 : currentValue > previousValue ? -1 : 0
|
||||
else
|
||||
currentValue > previousValue ? 1 : currentValue < previousValue ? -1 : 0
|
||||
|
||||
rsiPoints(pair, timeframe) =>
|
||||
rsiValue = rsi(close, 14) // Example: using 14 periods for RSI
|
||||
rsiValue[0] > rsiValue[1] ? 1 : rsiValue[0] < rsiValue[1] ? -1 : 0
|
||||
// Calculate points for each currency pair
|
||||
longPoints(pair, isInverse) =>
|
||||
rsiP = calcPoints(rsiValue, rsiValue[1], isInverse)
|
||||
stochRsiP = calcPoints(stochRsiValue, stochRsiValue[1], isInverse)
|
||||
wavetrendP = calcPoints(wt1, wt1[1], isInverse)
|
||||
rsiP + stochRsiP + wavetrendP
|
||||
|
||||
stochRsiKPoints(pair, timeframe) =>
|
||||
K = stoch(close, high, low, 14) // Example: using 14 periods for Stoch RSI
|
||||
K[0] > K[1] ? 1 : K[0] < K[1] ? -1 : 0
|
||||
shortPoints(pair, isInverse) => -longPoints(pair, isInverse)
|
||||
|
||||
obvPoints(pair, timeframe) =>
|
||||
obvValue = obv(close, volume)
|
||||
obvValue[0] > obvValue[1] ? 1 : obvValue[0] < obvValue[1] ? -1 : 0
|
||||
// Pairs and their corresponding inverse flag
|
||||
var pairs = array.new_string(5)
|
||||
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
|
||||
calcPoints(indicator, current, previous) =>
|
||||
// Calculate points for each pair
|
||||
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
|
||||
for pair in pairs
|
||||
for timeframe in timeframes
|
||||
// Switch to pair and timeframe
|
||||
...
|
||||
// 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
|
||||
...
|
||||
// Display the results
|
||||
for i = 0 to array.size(pairs) - 1
|
||||
pair = array.get(pairs, i)
|
||||
plot(array.get(longPointsArray, i), title="Long Points " + pair, color=color.green)
|
||||
plot(array.get(shortPointsArray, i), title="Short Points " + pair, color=color.red)
|
||||
|
||||
// Combine and display most efficient combinations
|
||||
...
|
||||
plot(totalLongPoints, title="Total Long Points", color=color.blue)
|
||||
plot(totalShortPoints, title="Total Short Points", color=color.orange)
|
||||
|
@ -26,6 +26,9 @@ tci = ta.ema(ci, n2)
|
||||
wt1 = tci
|
||||
wt2 = ta.sma(wt1, 4)
|
||||
|
||||
//calculate obv
|
||||
obv = ta.obv(close, volume)
|
||||
|
||||
// Initialize points for BTCUSDT.P
|
||||
longPointsRSIBTC = close > close[1] ? 1 : 0
|
||||
shortPointsRSIBTC = close < close[1] ? 1 : 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user