gogo2/Niki/new.pine
2024-01-12 17:39:10 +02:00

125 lines
3.9 KiB
Plaintext

//@version=5
indicator("DrNiki's Market Nuker", shorttitle="DrNiki's Market Nuker", overlay=true)
// /*
// create a calculator in pinescript that uses all of this data at the same time:
// here are the pairs:
// -US30
// -GOLD
// -DXY (for this pair inverse the results, each long point goes to a short point and vice versa)
// -BTCUSDT.P
// -syminfo.ticker
// (e.g.:pairs = ["US30", "GOLD", "DXY", "BTCUSDT.P", syminfo.ticker])
// use these 4 timeframes:
// 1 hour
// 2 hour
// 3 hour
// 4 hour
// Use these 4 indicators:
// Wavetrend with crosses [LazyBear] and use wt1 only - when it goes higher than the previous candle from the timeframe specified (we specified 4 timeframes) give it 1 point for longs. When it goes lower than the previous candle from the current timeframe specified (we specified 4 timeframes) give it 1 point for shorts
// for rsi do the same
// for stoch rsi K line do the same
// for OBV do the same
// DO it on all pairs and on all timeframes at the same time, the maximum odds should be 100% total. write the results in a text with the odds per pair for a long and short based on each timeframe and pair and based on each pair and timeframe.
// Then have a total when you have the most efficient way of combining them calculated
// */
// [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