Awesome Oscillator Trend Bar
Sat Dec 04 2021 15:42:32 GMT+0000 (Coordinated Universal Time)
Saved by
@finallynitin
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © finallynitin
//@version=5
indicator(title="Awesome Oscillator Trend Bar", shorttitle="AO Trend Bar", timeframe="", timeframe_gaps=true)
// Only show content if on a WEEKLY timeframe
onWeeklyChart = timeframe.isweekly
// Awesome Oscillator
ao = ta.ema(hl2,13) - ta.ema(hl2,34)
diff = ao - ao[1]
// Multi-time frame
AO_W = request.security(syminfo.tickerid, 'W', ao, lookahead=barmerge.lookahead_on)
diff_W = AO_W - AO_W[1]
AO_D = request.security(syminfo.tickerid, 'D', ao, lookahead=barmerge.lookahead_on)
diff_D = AO_D - AO_D[1]
//Conditions
longaow = AO_W >=0
longaod = AO_D >=0
shortaow = AO_W <0
shortaod = AO_D <0
//Plot
iff_1 = onWeeklyChart and shortaow and shortaod ? color.red : color.black
iff_2 = onWeeklyChart and longaow and shortaod ? color.orange : iff_1
iff_3 = onWeeklyChart and shortaow and longaod ? color.orange : iff_2
AOColor = onWeeklyChart and longaow and longaod ? color.green : iff_3
bgcolor(color=color.new(AOColor, transp = 20))
content_copyCOPY
Comments