TradingView
ImmortalFreedom
11 janv. 2020 11:40

Reflex Oscillator - Dr. John Ehlers 

PNC Financial Services Group, Inc. (The)NYSE

Description

Hot off the press, I present this NEW "Reflex Oscillator" employing PSv4.0, originally formulated by Dr. John Ehlers for TASC - February 2020 Traders Tips. John Ehlers might describe it's novel characteristics as being a reversal sensitive near zero-lag averaging indicator retaining the CYCLE component. Also, I would add that irregardless of the sampling interval, this indicator has a bound range between +/-2.0 on "1 second" candles all the way up to "1 month" candle durations. This indicator also has a companion indicator entitled "TrendFlex Oscillator". I have published it in tandem with this one in my scripts profile.

One notable difference between this and the original formulation is that I have added an independent control for the Super Smoother. This "tweak" is enabled by applying the override and adjusting it's period. There is a "Post Smooth" input() that "tweaks" the internal Reflex EMA too. Keep in mind that my intention of adding tweaks is solely for experimentation with the original formulation.

I also added adjustable levels for those of you that may wish to employ alertcondition()s to this indicator somehow. Providing a more utilitarian approach, I created this with an easy to use reusable function named reflex(). As always, I have included advanced Pine programming techniques that conform to proper "Pine Etiquette". Being this is one of John Ehlers' first two simultaneously released indicators for 2020, I felt a few more bells and whistles were appropriate as a proper contribution to the Tradingview community.

Features List Includes:
Dark Background - Easily disabled in indicator Settings->Style for "Light" charts or with Pine commenting
AND much, much more... You have the source!

The comments section below is solely just for commenting and other remarks, ideas, compliments, etc... regarding only this indicator, not others. When available time provides itself, I will consider your inquiries, thoughts, and concepts presented below in the comments section, should you have any questions or comments regarding this indicator. When my indicators achieve more prevalent use by TV members, I may implement more ideas when they present themselves as worthy additions. As always, "Like" it if you simply just like it with a proper thumbs up, and also return to my scripts list occasionally for additional postings. Have a profitable future everyone!
Commentaires
PineCoders
bydesign
Thanks for your efforts.

I'm an amateur coder and new to pine script... I have a question about this code which I've been unable to find

In the Plot and hline code below:
1. I'm not sure what the first plot line does. I have actually commented it out and do not see a difference in the output.
2. The Hex colors have 8 characters. What do the last 2 characters do? e.g. #FFFFFF22 (22)

plot( 0.0, color=#FFFFFF22, linewidth=7 , editable=false)
hline( 0.0, color=#FFFFFFff, title= "Zero", editable=false)
hline(upperLevel, color=#FF0000ff, title="Upper Threshold")
hline(lowerLevel, color=#00FF00ff, title="Lower Threshold")

Thanks!
ImmortalFreedom
@bydesign, Good question!

Behind the hline() zero line is a secondary 7px wide "TRANSPARENT" highlighter at 0.0 for hline(). If your monitor is not color calibrated OR you are using a Light chart, it may be visibly indistinguishable. If you increase the "brightness" (22) to 33, 40, etc... it will be more pronounced with a dark background color. 80 (hex) is effectively half way transparent. This controls the transparency of any line, yielding a mostly transparent line with 22. If you change 22 to ff, it will be full intensity white (#FFFFFFff) rather than a ghost gray. Equal separation transparency gradients can easily be coded with either of the following 00, 11, 22, 33, 44, 55, 66, 77, 88, 99, aa, bb, cc, dd, ee, ff (16 grades) OR 00, 40, 80, c0, ff (5 gradesl) OR 00, 33, 66, 99, cc, ff (6 grades). 00 will create a completely invisible line of any color. Try #80808022

This indicator is a high intensity bright yellow, so it appears to bleed into the transparent white mostly. If you go into Settings -> Style you can toggle this line on/off with a checkbox to easily see the difference. Toggling all of the other lines OFF will only leave only that one visible, and it should be unmistakable with a dark background. While you are in Settings -> Style, you may change colors, line style, and linewidth (1-4px) creating a perfectly styled indicator to your liking without coding. After coloring it to perfection you can use Firefox's in browser developer eyedropper to retrieve colors from almost anything HTML, however with transparency less than full intensity (ff), the actual color may vary when eyedropped from what the actual code may be in transparency controlled indicators.

Some Pine plotting functions have a transp= parameter that uses as a percentage of transparency. 100 being 100% color intensity and 0 being invisible, you may apply transparency = input(50, "Transparency for transp=", input.integer, minval=0, maxval=100, step=5) to these and then see how it works at the programming level using Settings. plot() is the most versatile with plot(AnyNumber, color=XXXXXX, transp=transparency) . xx won't be needed in this case.

Searching for "html color picker" will provide you with unlimited resources of everything in hex color. That is significantly more broad spectrum than transparency, yet able to be learned by anyone who can functionally program at any stage of experience. The best way to learn is code colors and a lot of them.

If you want a full list of my recommended colors, you may visit my "Pine Color Magic and Chart Theme Simulator" in my scripts profile. You will find amazing code, colors, and techniques that are applicable on both chart types of Dark and Light while toying with the colorcator Settings. This is intended for developers at any stage of learning, providing the best eye candy indicators that can be built utilizing the "Power of Pine". #XXXXXXxx yields more than 1.6 billion color code variations to choose from...
bydesign
@midtownsk8rguy, Thanks!
greyghost7
Big thank you for this, it was the missing link in my algo :D
bernylr1984
Great work! Thkx!
Duyck
Thanks, saved me quite some time, I was about to try to code these in the coming days! ;-)

Gr, JD.
exitleft
Great work.
phohat
Well done !!!!
Thank you for the share !!!

All the best
Sijo-Jose
Very useful indicator, thanks for sharing and caring traders community.
Plus