AwesomeOscillator AO Color Change without crossing the Zero axis

TrainDoodle

New member
New user to this forum - it's quite impressive, cant wait to spend some serious time reading and learning. I've done my best researching and don't see that this has been discussed on here before.

Is there a way to generate a signal based on a color change on the AwesomeOscillator oscillator without a cross of the Zero line being required?

Thanks a million pips in advance.

Bj9JABs.png
 

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
Not the perfect solution. I forgot how to display only the first transition (from red to green and vice versa).

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2020
#

declare lower;
declare zerobase;

plot AO = Average(hl2, 5) - Average(hl2, 34);
plot Zero = 0;

AO.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
AO.SetLineWeight(3);
AO.DefineColor("Up", Color.UPTICK);
AO.DefineColor("Down", Color.DOWNTICK);
AO.AssignValueColor(if AO > AO[1] then AO.color("Up") else if AO < AO[1] then AO.color("Down") else GetColor(1));
Zero.SetDefaultColor(GetColor(5));

def bullish = AO > AO[1];
def bearish = AO < AO[1];

# Plot arrows
plot UpSignal = if bullish then 0 else Double.NaN;
UpSignal.SetDefaultColor(Color.Orange);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

plot DownSignal = if bearish then 0 else Double.NaN;
DownSignal.SetDefaultColor(Color.Orange);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
 

TrainDoodle

New member
This generates an arrow on every bar.
Im trying to generate the arrow on the switch over from green to red or red to green.

For example

G,G,G,R,R the arrow would be down on the the first R only.
G,G,R,G,G the arrow world be down on the R and Up on the first G following the R
With no arrow present when A0 = A0[1]

Also looking for this signal to generate alerts through the scan.

I really do appreciate anything thought that goes into this, Im the kind of person that feels bad even asking questions.
 

rad14733

Well-known member
VIP
Change ARROW_UP and ARROW_DOWN to BOOLEAN_ARROW_UP and BOOLEAN_ARROW_DOWN... That should do it... 💡 (y)

Hmmm... Nope...!!! I'll check further unless BenTen beats me to it...
 
Last edited:

TrainDoodle

New member
MACD Histogram is one of the more common used indicators that incorporates color changes without the zero line being crossed, (Two shades of Green and two shades of Red) looking through code for it to see if there are answers hidden there.
 
Last edited:

Pensar

Well-known member
VIP
Lifetime
@TrainDoodle Here are two different arrow plot methods. Use the code @BenTen posted, and replace the code below "#Plot Arrows" with one or the other.

This code plots an arrow on each color change, regardless if the AO is above or below 0 -
Code:
# Plot arrows
plot UpSignal = if !bullish[1] && bullish then 0 else Double.NaN;
UpSignal.SetDefaultColor(Color.Orange);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

plot DownSignal = if !bearish[1] && bearish then 0 else Double.NaN;
DownSignal.SetDefaultColor(Color.Orange);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

This code plots an arrow on each color change, but only up arrows when below 0 and down arrows when above 0 -
Code:
# Plot arrows
plot UpSignal = if AO < 0 && !bullish[1] && bullish then AO else Double.NaN;
UpSignal.SetDefaultColor(Color.Orange);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

plot DownSignal = if AO > 0 && !bearish[1] && bearish then AO else Double.NaN;
DownSignal.SetDefaultColor(Color.Orange);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
 

TrainDoodle

New member
People who write code are amazing.
Thank you all so much this worked exactly as I was hoping.

No that it is displaying perfectly how do I get the scan to give me a notification when the "DownSignal" or the "UpSignal" is true?
They can be combined into an or statement.

I know how to enter the custom scans into the thinkscript editor
 

rad14733

Well-known member
VIP
@Pensar Great work... I had similar code half done last night but fell asleep with my fingers on the keyboard... I was working on setting a state and then decided on a solution more in line with your code but sleep won out over desire...

@TrainDoodle We members here work very hard, at no benefit to ourselves, in an effort to help fellow members not only succeed at trading but to also encourage them to learn Thinkscript and give back to the community... I used to run a programming forum that had the same mission and we were far more responsive to those who joined in as givers rather than merely being takers... It is very rewarding to see folks roll up their sleeves and learn to help themselves and others... Not making any accusations, merely stating facts based on experience... I hope you find the code Pensar posted useful... ;)
 

rad14733

Well-known member
VIP
@rad14733 It's funny because my credit card WAS in my hand when I opened the site up just now
I'm sure BenTen would be appreciative of any donations to help keep this site up and running... What I was referring to is that contributing members don't receive any monetary compensation but, rather, see member requests and stumbling blocks as logic problems... I help because that's how I'm wired... 🤓
 

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Top