76 lines
2.7 KiB
Plaintext
76 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)
|
|
|
|
// 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
|
|
calcPoints(currentValue, previousValue, isInverse) =>
|
|
if isInverse
|
|
currentValue < previousValue ? 1 : currentValue > previousValue ? -1 : 0
|
|
else
|
|
currentValue > previousValue ? 1 : currentValue < previousValue ? -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
|
|
|
|
shortPoints(pair, isInverse) => -longPoints(pair, isInverse)
|
|
|
|
// 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)
|
|
|
|
// 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)
|
|
|
|
// 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)
|
|
|
|
plot(totalLongPoints, title="Total Long Points", color=color.blue)
|
|
plot(totalShortPoints, title="Total Short Points", color=color.orange)
|