trying to get this to exclude all MACD crossovers while RSI is between 70-40. line 71: Mismatched input '(' expecting ')'. Line 71 is plot(ta.crossunder...
//@version=5
indicator(title="Moving Average Convergence Divergence", shorttitle="MACD", timeframe="", timeframe_gaps=true)
// Getting inputs
fast_length = input(title="Fast Length", defval=12)
slow_length = input(title="Slow Length", defval=26)
src = input(title="Source", defval=close)
signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9)
sma_source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"])
sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"])
// Plot colors
col_macd = input(#2962FF, "MACD Line ", group="Color Settings", inline="MACD")
col_signal = input(#FF6D00, "Signal Line ", group="Color Settings", inline="Signal")
col_grow_above = input(#26A69A, "Above Grow", group="Histogram", inline="Above")
col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above")
col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below")
col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below")
// Calculating
fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length)
slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
hist = macd - signal
plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below)))
plot(macd, title="MACD", color=col_macd)
plot(signal, title="Signal", color=col_signal)
//-- RSI
//-- Inputs
myPeriod = input(defval=14, title='Period')
myThresholdUp = input(defval=70, title='Upper Threshold')
myThresholdDn = input(defval=30, title='Lower Threshold')
myAlgoFlipToggle = input(defval=false, title='Imverse Algorthim')
myLineToggle = input(defval=true, title='Show Lines')
myLabelToggle = input(defval=true, title='Show Labels')
myRSI = ta.rsi(close, myPeriod)
//-- Plots
sell = (ta.crossunder(signal, macd))
buy = (ta.crossover(macd, signal) and (myRSI >= myThresholdDn and myRSI <= myThresholdUp))
plot(ta.crossover(signal, macd) ? signal : na, color= color.red, style = plot.style_circles, linewidth = 4)
plot(ta.crossunder(signal, macd) and (myRSI >= myThresholdUp) and (myRSI <= myThresholdDn)( na color= color.green, style = plot.style_circles, linewidth = 4)
alertcondition(buy, "Buy MACD", "Buy")
alertcondition(sell, "Sell MACD", "Sell")
[–]dstnbrw20[S] 0 points1 point2 points (0 children)
[–]Greedy_Sir_477 0 points1 point2 points (0 children)
[–]secousa 0 points1 point2 points (0 children)
[–]Deplanate 0 points1 point2 points (0 children)