Sebelum membaca artikel ini, baca yuk klik pusat rebate untuk trading optimal

Tradingview Previous Daily/Weekly High Low Close and EMA

I made my pinescript code from ChatGPT and they unpublish it because it doesnt meet they requirement. So i just publish here in my personal blog, to anybody who might need it.

//@version=5
indicator("Previous Daily/Weekly Candle and EMA", overlay=true)

// Daily Timeframe
dailyHigh = request.security(syminfo.tickerid, "D", high[1], lookahead=barmerge.lookahead_on)
dailyLow = request.security(syminfo.tickerid, "D", low[1], lookahead=barmerge.lookahead_on)
dailyClose = request.security(syminfo.tickerid, "D", close[1], lookahead=barmerge.lookahead_on)

// Weekly Timeframe for the previous week
weeklyHigh = request.security(syminfo.tickerid, "W", high[1], lookahead=barmerge.lookahead_on)
weeklyLow = request.security(syminfo.tickerid, "W", low[1], lookahead=barmerge.lookahead_on)
weeklyClose = request.security(syminfo.tickerid, "W", close[1], lookahead=barmerge.lookahead_on)

// EMA 20
ema20 = ta.ema(close, 20)

// Plotting Previous Daily Candle as Line
plot(dailyHigh, color=color.blue, linewidth=2, title="Prev Daily High")
plot(dailyLow, color=color.blue, linewidth=2, title="Prev Daily Low")
plot(dailyClose, color=color.green, linewidth=2, title="Prev Daily Close")

// Plotting Previous Weekly Candle as Line
plot(weeklyHigh, color=color.new(color.yellow, 0), linewidth=4, title="Prev Weekly High")
plot(weeklyLow, color=color.new(color.yellow, 0), linewidth=4, title="Prev Weekly Low")
plot(weeklyClose, color=color.new(color.green, 0), linewidth=4, title="Prev Weekly Close")

// Plotting EMA 20
plot(ema20, color=color.orange, linewidth=2, title="EMA 20")

Here we go, happy trading ...

Comments

point bellow