89 lines
2.7 KiB
Plaintext
89 lines
2.7 KiB
Plaintext
//@version=5
|
|
indicator("DrNiki's Market Nuker", shorttitle="DrNiki's Market Nuker", overlay=true)
|
|
|
|
// [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")
|
|
|
|
// 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)
|
|
|
|
// 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 = 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) =>
|
|
value = 0
|
|
if isInverse
|
|
value := currentValue < previousValue ? 1 : currentValue > previousValue ? -1 : 0
|
|
else
|
|
value := currentValue > previousValue ? 1 : currentValue < previousValue ? -1 : 0
|
|
value
|
|
|
|
// 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
|
|
|
|
shortPoints(pair, isInverse) => -longPoints(pair, isInverse)
|
|
|
|
|
|
// Hardcoded pairs and their corresponding inverse flags
|
|
pairs = array.new_string(5)
|
|
array.set(pairs, 0, "US30")
|
|
array.set(pairs, 1, "GOLD")
|
|
array.set(pairs, 2, "DXY")
|
|
array.set(pairs, 3, "BTCUSDT.P")
|
|
array.set(pairs, 4, syminfo.tickerid)
|
|
|
|
isInverse = array.new_bool(5, false)
|
|
array.set(isInverse, 2, true) // Inverse for DXY
|
|
|
|
// Initialize variables for storing points
|
|
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)
|
|
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)
|
|
|
|
|
|
// Display |