Custom Trading Strategy
ADX _ RSI _ MACD signal strategy3169
plain_text
10 months ago
2.5 kB
12
Indexable
/@version=5 indicator("Custom Trading Strategy", overlay=true) // ADX calculation adxFunc(src, length) => up = ta.change(high) down = -ta.change(low) plusDM = na(up) ? na : (up > down and up > 0 ? up : 0) minusDM = na(down) ? na : (down > up and down > 0 ? down : 0) tr = ta.rma(ta.tr(true), length) plusDI = 100 * ta.rma(plusDM, length) / tr minusDI = 100 * ta.rma(minusDM, length) / tr dx = 100 * math.abs(plusDI - minusDI) / (plusDI + minusDI) ta.rma(dx, length) adx = adxFunc(close, 14) // RSI rsi = ta.rsi(close, 14) // MACD [macdLine, signalLine, _] = ta.macd(close, 12, 26, 9) // Fibonacci Retracement Levels highLevel = ta.highest(high, 100) lowLevel = ta.lowest(low, 100) fibLevel = highLevel - (highLevel - lowLevel) * 0.618 // Heikin-Ashi haClose = (open + high + low + close) / 4 var float haOpen = na haOpen := na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2 haHigh = math.max(high, math.max(haOpen, haClose)) haLow = math.min(low, math.min(haOpen, haClose)) heikinAshiGreen = haClose > haOpen heikinAshiRed = haClose < haOpen // Buy and Sell Conditions adxBuyCondition = adx > 25 rsiBuyCondition = rsi < 30 rsiSellCondition = rsi > 70 macdBuyCondition = ta.crossover(macdLine, signalLine) macdSellCondition = ta.crossunder(macdLine, signalLine) fibBuyCondition = close <= fibLevel fibSellCondition = close >= fibLevel // Plot MACD conditions with updated labels plotshape(series=macdBuyCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="KESİN AL") plotshape(series=macdSellCondition, location=location.abovebar, color=color.red, style=shape.labeldown, text="KESİN SAT") plot(fibLevel, title="Fibonacci Level", color=color.purple) // Combined Signal Line var float signalLineValue = na signalLineValue := adxBuyCondition and rsiBuyCondition and macdBuyCondition and fibBuyCondition and heikinAshiGreen ? 1 : (adxBuyCondition and rsiSellCondition and macdSellCondition and fibSellCondition and heikinAshiRed ? -1 : 0) // Plot the Signal Line plot(signalLineValue, title="Signal Line", color=color.blue, linewidth=2) // Buy and Sell Signals Based on the Signal Line plotshape(series=signalLineValue == 1, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY") plotshape(series=signalLineValue == -1, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
Editor is loading...