Z-Score Heikin-Ashi Transformed for ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
3KfhHhv.png

Author Message:
he Z-Score Heikin-Ashi Transformed (𝘡 𝘏-𝘈) indicator is a powerful technical tool that combines the principles of Z-Score and Heikin Ashi to provide traders with a smoothed representation of price movements and a standardized measure of market volatility.

The 𝘡 𝘏-𝘈 indicator applies the Z-Score calculation to price data and then transforms the resulting Z-Scores using the Heikin Ashi technique. Understanding the individual components of Z-Score and Heikin Ashi will provide a foundation for comprehending the methodology and unique features of this indicator.
More Details : https://www.tradingview.com/v/MFW8vsmU/

CODE:

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#https://www.tradingview.com/v/MFW8vsmU/
#// © QuantiLuxe
#indicator("Z-Score Heikin Ashi Transformed", "{?} - ? ?-?", false)
# converted by Sam4Cok@Samer800    - 07/2023
declare lower;
#f_z(src, len) =>
script f_z {
    input src = close;
    input len = 21;
    def mean = Average(src, len);
    def dev = StDev(src, len);
    def f_z = (src - mean) / dev;
    plot out = f_z;
}
input Zperiod = 21;            # 'Z Period'
input showSignals = yes;
input ReversionThreshold = {"1", default "2", "3"};    # "Reversion Threshold"
input showMovAvgLine1 = yes;
input movAvgLength1 = 50;
input showMovAvgLine2 = yes;
input movAvgLength2 = 150;

def na = Double.NaN;
def last = isNaN(close);

def revt;
Switch (ReversionThreshold) {
Case "1" : revt = 1;
Case "2" : revt = 2;
Case "3" : revt = 3;
}
#-- Colors
DefineGlobalColor("colup", CreateColor(255,242,204));
DefineGlobalColor("coldn", CreateColor(111,168,220));
DefineGlobalColor("colema1", Color.CYAN);
DefineGlobalColor("colema2", Color.MAGENTA);
DefineGlobalColor("low", CreateColor(255,214,232));
DefineGlobalColor("dlow", Color.PLUM);

def o_z = f_z(open, Zperiod);
def h_z = f_z(high, Zperiod);
def l_z = f_z(low, Zperiod);
def c_z = f_z(close, Zperiod);

def haClose = (o_z + h_z + l_z + c_z) / 4;
def haOpen = CompoundValue(1, (haOpen[1] + haClose[1]) / 2, (o_z + c_z) / 2);
def haHigh = Max(h_z, Max(haOpen, haClose));
def haLow = Min(l_z, Min(haOpen, haClose));
#def ohlc = (haClose + haOpen + haHigh + haLow) / 4;

def haColor = if haClose > haOpen then 1 else
              if haClose < haOpen then -1 else 0;
def OpenUp = if haColor > 0 then haOpen else na;
def OpenDn = if haColor < 0 then haOpen else na;

# Plot the new Chart
AddChart(high = if haColor > 0 then haHigh else na , low = haLow , open = haClose,  close = OpenUp,
         type = ChartType.CANDLE, growcolor =  GlobalColor("colup"));

AddChart(high = if haColor < 0 then haHigh else na, low = haLow , open = OpenDn,  close = haClose,
         type = ChartType.CANDLE, growcolor =  GlobalColor("coldn"));

plot EMA1 = if showMovAvgLine1 then ExpAverage(haClose, movAvgLength1) else na;
plot EMA2 = if showMovAvgLine2 then ExpAverage(haClose, movAvgLength2) else na;
EMA1.SetDefaultColor(GlobalColor("colema1"));
EMA2.SetDefaultColor(GlobalColor("colema2"));

plot zero = if last then na else 0;    # "Mid Line"
zero.SetStyle(Curve.SHORT_DASH);
zero.SetDefaultColor(Color.DARK_GRAY);

def max = if last then na else 4;
def hh = if last then na else 3;
def lh = if last then na else 2;

AddCloud(hh, lh, Color.DARK_GRAY);
AddCloud(max, hh, Color.WHITE);

def min = if last then na else -4;
def ll = if last then na else -3;
def hl = if last then na else -2;

AddCloud(hl, ll, GlobalColor("dlow"));
AddCloud(ll, min, GlobalColor("low"));

def dn = haHigh[1] < haHigh[2];
def up = haLow[1] > haLow[2];

plot SigUp = if !showSignals then na else
             if (haHigh > revt and haHigh < haHigh[1] and !dn) then haHigh + 0.75 else na;    # "OB"
plot SigDn = if !showSignals then na else
             if (haLow < -revt and haLow > haLow[1] and !up) then haLow - 0.75 else na;       # "OS"

SigUp.SetPaintingStrategy(PaintingStrategy.SQUARES);
SigDn.SetPaintingStrategy(PaintingStrategy.SQUARES);
SigUp.SetDefaultColor(Color.GREEN);
SigDn.SetDefaultColor(Color.RED);

#--- END of CODE
 
@samer800// In my experience (just downloaded to my TOS) this provides an Excellent addition to the already existing Z score indicator on TOS. The additional signals in a cloud formation with the Reversal dots are great visual add to the "tool box" for the ardent tape price action reader. It does a great job of summarizing the order flow without the Bid Ask "brownian type movement" that is so popular with the Order Flow Cult movement.. IT PRINTS OUT EVEN ON A TICK CHART!, excuse the capital letters, as unlike the $Tick and $TIKND (which do not print on tick based chart for the futures trade :sick:)the HeikinAshi transformed indicator can be used for both Time based and intraday Tick charts.. Congratulations . Gratitude from MagicQuotes. Best to all on the thread
 
This is the true Z-score in the statistical sense...
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
259 Online
Create Post

Similar threads

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.
Back
Top