latest changes
This commit is contained in:
parent
1bfb5670b8
commit
ed545a1ddb
@ -3,17 +3,40 @@ indicator("DrNiki's Market Nuker", shorttitle="DrNiki's Market Nuker", overlay=t
|
||||
|
||||
// Function to calculate RSI
|
||||
rsiLength = input(14, title="RSI Length")
|
||||
calcRSI() => ta.rsi(close, rsiLength)
|
||||
|
||||
// Function to calculate Stochastic RSI
|
||||
stochRsiLength = input(14, title="Stochastic RSI Length")
|
||||
calcStochRSI() => ta.stoch(close, close, close, stochRsiLength)
|
||||
|
||||
// Function to calculate Wavetrend
|
||||
n1 = input(10, "Channel Length")
|
||||
n2 = input(21, "Average Length")
|
||||
calcWavetrend() =>
|
||||
ap = hlc3
|
||||
mfiLength = input(7, title="MFI Length")
|
||||
|
||||
|
||||
// calcRSI() => ta.rsi(close, rsiLength)
|
||||
// // Function to calculate Stochastic RSI
|
||||
// calcStochRSI() => ta.stoch(close, close, close, stochRsiLength)
|
||||
// // Function to calculate Wavetrend
|
||||
// calcWavetrend() =>
|
||||
// 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)
|
||||
// [wt1, wt2]
|
||||
|
||||
// // Function to calculate On Balance Volume (OBV)
|
||||
// calcOBV() =>
|
||||
// var float obv = na
|
||||
// obv := close > close[1] ? obv + volume : close < close[1] ? obv - volume : obv
|
||||
// obv
|
||||
|
||||
// // Function to calculate MFI
|
||||
// calcMFI() => ta.mfi(close, mfiLength)
|
||||
|
||||
|
||||
calcRSI(source) => ta.rsi(source, rsiLength)
|
||||
calcStochRSI(source) => ta.stoch(source, source, source, stochRsiLength)
|
||||
calcWavetrend(source) =>
|
||||
ap = source
|
||||
esa = ta.ema(ap, n1)
|
||||
d = ta.ema(math.abs(ap - esa), n1)
|
||||
ci = (ap - esa) / (0.015 * d)
|
||||
@ -22,23 +45,20 @@ calcWavetrend() =>
|
||||
wt2 = ta.sma(wt1, 4)
|
||||
[wt1, wt2]
|
||||
|
||||
// Function to calculate On Balance Volume (OBV)
|
||||
calcOBV() =>
|
||||
calcOBV(source, volumeSource) =>
|
||||
var float obv = na
|
||||
obv := close > close[1] ? obv + volume : close < close[1] ? obv - volume : obv
|
||||
obv
|
||||
|
||||
// Function to calculate MFI
|
||||
mfiLength = input(7, title="MFI Length")
|
||||
calcMFI() => ta.mfi(close, mfiLength)
|
||||
calcMFI(source) => ta.mfi(source, mfiLength)
|
||||
|
||||
// Function to calculate points for a symbol
|
||||
calcPoints(symbol) =>
|
||||
rsiValue = calcRSI()
|
||||
stochRsiValue = calcStochRSI()
|
||||
[wt1, wt2] = calcWavetrend()
|
||||
obv = calcOBV()
|
||||
mfiValue = calcMFI()
|
||||
rsiValue = request.security(symbol, timeframe.period, calcRSI(close), barmerge.gaps_off, barmerge.lookahead_on)
|
||||
stochRsiValue = request.security(symbol, timeframe.period, calcStochRSI(close), barmerge.gaps_off, barmerge.lookahead_on)
|
||||
[wt1, wt2] = request.security(symbol, timeframe.period, calcWavetrend(close), barmerge.gaps_off, barmerge.lookahead_on)
|
||||
obv = request.security(symbol, timeframe.period, calcOBV(close, volume), barmerge.gaps_off, barmerge.lookahead_on)
|
||||
mfiValue = request.security(symbol, timeframe.period, calcMFI(close), barmerge.gaps_off, barmerge.lookahead_on)
|
||||
|
||||
longPoints = 0
|
||||
shortPoints = 0
|
||||
@ -58,22 +78,39 @@ calcPoints(symbol) =>
|
||||
|
||||
// Symbols array
|
||||
symbols = array.new_string(5)
|
||||
array.set(symbols, 0, syminfo.tickerid)
|
||||
array.set(symbols, 0, syminfo.ticker) // Replace with the symbol of your chart
|
||||
array.set(symbols, 1, "GOLD")
|
||||
array.set(symbols, 2, "DXY")
|
||||
array.set(symbols, 3, "BTCUSDT.P")
|
||||
array.set(symbols, 4, "US30")
|
||||
|
||||
|
||||
var string[] list = array.from(syminfo.ticker, "GOLD", "DXY", "BTCUSDT.P", "US30")
|
||||
var string sym = ""
|
||||
|
||||
for i in list
|
||||
log.info(i)
|
||||
[longPoints, shortPoints] = calcPoints(i)
|
||||
sym := i + " "
|
||||
var logMessage = "| sym: " + sym + " " + i
|
||||
barTimeStr = str.format_time(time, "yyyy-MM-dd HH:mm:ss", "Europe/Sofia")
|
||||
log.info(logMessage)
|
||||
|
||||
log.info("-------------------------")
|
||||
|
||||
// Calculate points for each symbol
|
||||
var symbolPoints = array.new_int(size=array.size(symbols) * 2, initial_value=0)
|
||||
for symbol in symbols
|
||||
// Change symbol context using security() function
|
||||
[longPoints, shortPoints] = calcPoints(symbol)
|
||||
for i in list
|
||||
var sm = i +" "
|
||||
barTimeStr = str.format_time(time, "yyyy-MM-dd HH:mm:ss", "Europe/Sofia")
|
||||
var logMessage = barTimeStr + "| Symbol: " + symbol + ", Long: " + str.tostring(longPoints) + ", Short: " + str.tostring(shortPoints)
|
||||
var logMessage = barTimeStr + "| Symbol: " + i + "sm: " + sm
|
||||
log.info(logMessage)
|
||||
array.set(symbolPoints, 0, array.get(symbolPoints, 0) + longPoints)
|
||||
array.set(symbolPoints, 1, array.get(symbolPoints, 1) + shortPoints)
|
||||
//rsiValue = request.security(symbol, timeframe.period, calcRSI(close), barmerge.gaps_off, barmerge.lookahead_on)
|
||||
|
||||
// Change symbol context using security() function
|
||||
// [longPoints, shortPoints] = calcPoints(symbol.symbol)
|
||||
// array.set(symbolPoints, 0, array.get(symbolPoints, 0) + longPoints)
|
||||
// array.set(symbolPoints, 1, array.get(symbolPoints, 1) + shortPoints)
|
||||
|
||||
// Calculate total long and short probabilities
|
||||
totalLongPoints = array.get(symbolPoints, 0)
|
||||
@ -87,3 +124,6 @@ label.set_xy(labelBox, bar_index, high)
|
||||
label.set_text(labelBox, "Combined Probabilities\nLong: " + str.tostring(combinedProbabilityLong) + "%\nShort: " + str.tostring(combinedProbabilityShort) + "%")
|
||||
label.set_color(labelBox, color.new(color.blue, 0))
|
||||
label.set_style(labelBox, label.style_label_left)
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user