//@version=5 indicator("DrNiki's Market Nuker", shorttitle="DrNiki's Market Nuker", overlay=true) // Function to calculate RSI rsiLength = input(14, title="RSI Length") stochRsiLength = input(14, title="Stochastic RSI Length") n1 = input(10, "Channel Length") n2 = input(21, "Average Length") 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) tci = ta.ema(ci, n2) wt1 = tci wt2 = ta.sma(wt1, 4) [wt1, wt2] calcOBV(source, volumeSource) => var float obv = na obv := close > close[1] ? obv + volume : close < close[1] ? obv - volume : obv obv calcMFI(source) => ta.mfi(source, mfiLength) // Function to calculate points for a symbol calcPoints(symbol) => 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 longPoints := rsiValue > rsiValue[1] ? longPoints + 1 : longPoints shortPoints := rsiValue < rsiValue[1] ? shortPoints + 1 : shortPoints longPoints := stochRsiValue > stochRsiValue[1] ? longPoints + 1 : longPoints shortPoints := stochRsiValue < stochRsiValue[1] ? shortPoints + 1 : shortPoints longPoints := wt1 > wt1[1] ? longPoints + 1 : longPoints shortPoints := wt1 < wt1[1] ? shortPoints + 1 : shortPoints longPoints := obv > obv[1] ? longPoints + 1 : longPoints shortPoints := obv < obv[1] ? shortPoints + 1 : shortPoints longPoints := mfiValue > 50 ? longPoints + 1 : longPoints shortPoints := mfiValue < 50 ? shortPoints + 1 : shortPoints var logMessage = "Symbol: " + symbol + ", Long: " + str.tostring(longPoints) + ", Short: " + str.tostring(shortPoints) log.info(logMessage) [longPoints, shortPoints] // Symbols array symbols = array.new_string(5) 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 i in list var sm = i +" " barTimeStr = str.format_time(time, "yyyy-MM-dd HH:mm:ss", "Europe/Sofia") var logMessage = barTimeStr + "| Symbol: " + i + "sm: " + sm log.info(logMessage) //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) totalShortPoints = array.get(symbolPoints, 1) combinedProbabilityLong = totalLongPoints / (array.size(symbols) * 3) * 100 combinedProbabilityShort = totalShortPoints / (array.size(symbols) * 3) * 100 // Display combined probabilities var labelBox = label.new(na, na, "") 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)