Author message: [My add is the bar color and option to change the fast and slow length ]
The Zone is mention in New Trading Dimensions by Bill Williams , PhD .
The Zone is used for Entry Signal
Green Zone are painting Green when Awesome Oscillator (AO) and Accelerater/Decelerator ( AC ) are both increasing.
Red Zone are painting Red when Awesome Oscillator (AO) and Accelerater/Decelerator ( AC ) are both decreasing.
Gray Zone are painting Gray when AO and AC in difference changing
Gray Zone are indicate the indecision between bulls and bears.
Bill Williams , PhD . mention that Green Zone or Red Zone usually happen 6-8 bars Continuously.
(in my opinion, it happen lower than in intraday time frame)
The First Bar that change to be Green or Red color is the Signal Bar.
Entry Signal is the second bar in the same color as the Signal bar happen with Volume
Price go higher the high of previous Green Bar is Buy Signal. Entry Buy (Long) and place Stop at 1 tick lower the Low of previous bar.
Price go lower the Low of previous Red Bars is Sell Signal. Entry Sell (Short) and place Stop at 1 tick higher the High of previous bar.
Can Entry from 2nd bar to 5th bar.
Do not Entry if Green Bars or Red Bars completed 5 bars continuously.
This indicator have AO , AC and Zone in 1 tools and there are counter to show the number of Green bar or Red bar.
Green counter will happen when AO >0 and Green zone because AO > 0 show uptrend condition.
Red Counter will happen when AO < 0 and Red Zone because AO <0 show downtrend condition.
When we entry , we should follow the trend. So I design to non-show the counter if zone is against the trend.
#WaveRiders
Code:
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0
#// Copyright by © WaveRiders
#https://www.tradingview.com/script/axNQ0vK4/
#// Awesome Oscillator + The Zone
#study(title="AO-Zone" , shorttitle = "AOZ")
# Converted and mod by Sam4Cok@Samer800 - 10/2022
declare lower;
input ShowCounter = yes;
input BarColor = no;
input FastPeriod = 5;
Input SlowPeriod = 34;
def zG;
def zR;
def na = Double.NaN;
#//calculate AO, AC
def ao = SimpleMovingAvg(hl2, FastPeriod) - SimpleMovingAvg(hl2, SlowPeriod);
def ac = ao - SimpleMovingAvg(ao, FastPeriod);
#//Green Zone , Red Zone and Gray Zone
def GreenZone = ao > ao[1] and ac > ac[1];
def RedZone = ao < ao[1] and ac < ac[1];
#//Plot AO
plot Accelerater = ac; # color = change(ac) <= 0 ? #ffb330 : #1ccaff
Accelerater.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
Accelerater.AssignValueColor(if ac <= ac[1] then CreateColor(255,255,0)
else CreateColor(0,221,255));
Accelerater.SetLineWeight(2);
plot Awesome = ao; # color = change(ao) <= 0 ? #872323 : #007F0E
Awesome.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Awesome.AssignValueColor(if ao <= ao[1] then CreateColor(135,35,35)
else CreateColor(0,127,14));
#Awesome.AssignValueColor(if ao > 0 then if ao > ao[1] then Color.GREEN else Color.DARK_GREEN
# else if ao < ao[1] then Color.RED else Color.DARK_RED);
#//Fill Zone Background
AddCloud(if isNaN(close) then na else Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY,CreateColor(42,42,42));
AddCloud(if GreenZone then Double.POSITIVE_INFINITY else
if RedZone then Double.NEGATIVE_INFINITY else na,
if GreenZone then Double.NEGATIVE_INFINITY else Double.POSITIVE_INFINITY,
Color.DARK_GREEN, Color.DARK_RED);
#//Zone counter
if ao > ao[1] and ac > ac[1]
then {
zG = zG[1] + 1;
zR = 0;
} else
if ao < ao[1] and ac < ac[1]
then {
zG = 0;
zR = zR[1] + 1;
} else {
zG = 0;
zR = 0;
}
AddLabel(ShowCounter and GreenZone and ao > 0,"Count(" + zG + ")", Color.GREEN);
AddLabel(ShowCounter and RedZone and ao < 0, "Count(" + zR + ")", CreateColor(247,82,95));
def GZone11 = if GreenZone and ao>0 then zG == 1 else na;#, title ='GZone1',
def GZone22 = if GreenZone and ao>0 then zG == 2 else na;#, title ='GZone1',
def GZone33 = if GreenZone and ao>0 then zG == 3 else na;#, title ='GZone1',
def GZone44 = if GreenZone and ao>0 then zG == 4 else na;#, title ='GZone1',
def GZone55 = if GreenZone and ao>0 then zG == 5 else na;#, title ='GZone1',
plot GZone1 = if GZone11 then 2 else na;
plot GZone2 = if GZone22 then 2 else na;
plot GZone3 = if GZone33 then 2 else na;
plot GZone4 = if GZone44 then 2 else na;
plot GZone5 = if GZone55 then 2 else na;
GZone1.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
GZone2.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
GZone3.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
GZone4.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
GZone5.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
GZone1.SetDefaultColor(Color.GREEN);
GZone2.SetDefaultColor(Color.GREEN);
GZone3.SetDefaultColor(Color.GREEN);
GZone4.SetDefaultColor(Color.GREEN);
GZone5.SetDefaultColor(Color.GREEN);
def RZone11 = if RedZone and ao<0 then zR == 1 else na;#, title ='RZone1',
def RZone22 = if RedZone and ao<0 then zR == 2 else na;#, title ='RZone1',
def RZone33 = if RedZone and ao<0 then zR == 3 else na;#, title ='RZone1',
def RZone44 = if RedZone and ao<0 then zR == 4 else na;#, title ='RZone1',
def RZone55 = if RedZone and ao<0 then zR == 5 else na;#, title ='RZone1',
plot RZone1 = if RZone11 then -2 else na;
plot RZone2 = if RZone22 then -2 else na;
plot RZone3 = if RZone33 then -2 else na;
plot RZone4 = if RZone44 then -2 else na;
plot RZone5 = if RZone55 then -2 else na;
RZone1.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
RZone2.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
RZone3.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
RZone4.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
RZone5.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
RZone1.SetDefaultColor(Color.RED);
RZone2.SetDefaultColor(Color.RED);
RZone3.SetDefaultColor(Color.RED);
RZone4.SetDefaultColor(Color.RED);
RZone5.SetDefaultColor(Color.RED);
#---- Bar Color
def color = if ao>ao[1] and ac>ac[1] then 2 else
if ao>ao[1] and ac<=ac[1] then 1 else
if ao<=ao[1] and ac<=ac[1] then -2 else
if ao<=ao[1] and ac>ac[1] then -1 else 0;
AssignPriceColor(if !BarColor then Color.CURRENT else
if color==2 then Color.GREEN else
if color==1 then Color.DARK_GREEN else
if color==-2 then Color.RED else
if color==-1 then Color.DARK_RED else Color.GRAY);
#---- END
Last edited by a moderator: