//version=4
study (title="Ichimoku Cloud with MACD and RSI", shorttitle="Ichimoku_MACD_RSI", overlay=true)

// Ichimoku Cloud parameters
conversionPeriods = input (9, minval=1), basePeriods = input (26, minval=1)
laggingSpan2Periods = input (52, minval=1)
displacement = basePeriods

donchian(len) => avg(lowest(len), highest(len))

conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)

plot(conversionLine, color=color.red, title="Conversion Line")
plot(baseLine, color=color.blue, title="Base Line")
plot(close, offset = -displacement, color=color.green, title="Lagging Span")
p1 = plot(leadLine1, offset = displacement, color=color.green, title="Lead 1")
p2 = plot(leadLine2, offset = displacement, color=color.red, title="Lead 2")

// MACD Settings
fastLength = input(12, title="Fast Length")
slowLength = input(26, title="Slow Length")
signalLength = input(9, title="Signal Length")

// Calculate MACD
[macdLine, signalLine, _] = macd(close, fastLength, slowLength, signalLength)

// Buy and Sell conditions
buyCondition = macdLine > signalLine
sellCondition = macdLine < signalLine

// Create Study
bgcolor(buyCondition ? color.new(color.green, 90) : sellCondition ? color.new(color.red, 90) : na)

// Fill Ichimoku Cloud
fill(p1, p2, color=color.gray, transp=80)

// Plot signals
plotchar(buyCondition, char='M', color=color.blue, location=location.belowbar)
plotchar(sellCondition, char='B', color=color.red, location=location.abovebar)

// RSI conditions
rsi_length = input(14, title="RSI Length")
rsi_overbought = input(70, title="RSI Overbought Level")
rsi_oversold = input(30, title="RSI Oversold Level")

rsi_condition_buy = rsi(close, rsi_length) > rsi_overbought
rsi_condition_sell = rsi(close, rsi_length) < rsi_oversold

// Plot signals
plotchar(rsi_condition_buy, char='X', color=color.blue, location=location.belowbar)
plotchar(rsi_condition_sell, char='X', color=color.red, location=location.abovebar)
Technical Indicators

כתב ויתור