Z-Score Upper Indicator for ThinkorSwim

chewie76

chewie76

Active member
VIP
I took the standard Zscore indicator and created an upper indicator out of it that gives buy and sell signals. You can change the sensitivity by going into the code and adjusting the two conditions of -.75 and .75. A closer number to 0 will be more sensitive with more alerts and a higher number will be less sensitive. I don't suggest going over 1.

Below is a picture of ROKU on 9/22/2020 using a 2 min chart. I show the lower indicator as well. The alert is triggered when the Zscore line crosses the average line where the average line is greater than or less than .75. See circled areas. Give it a whirl.



Here is the code:

Code:
declare upper;

input price = close;
input length = 20;
input ZavgLength = 20;

#Initialize values
def oneSD = stdev(price,length);
def avgClose = simpleMovingAvg(price,length);
def ofoneSD = oneSD*price[1];
def Zscorevalue = ((price-avgClose)/oneSD);
def avgZv = average(Zscorevalue,20);

#Compute and plot Z-Score

DEF avgZscore = average(Zscorevalue,ZavgLength);
#avgZscore.setPaintingStrategy(paintingStrategy.LINE);

DEF Zscore = ((price-avgClose)/oneSD);

#Plot zero line and extreme bands
DEF zero = 0;
DEF two = 2;
DEF one = 1;
DEF negone = -1;
DEF negtwo = -2;
def three = 3;
def negthree = -3;

def condition1 = zscore crosses above avgZscore and avgzscore < -.75;
def condition2 = zscore crosses below avgZscore and avgzscore > .75;

# Plot arrows
plot UArrow = if condition1 is true then 1 else 0;
UArrow.SetDefaultColor(Color.white);
UArrow.SetPaintingStrategy(PaintingStrategy.Boolean_arrow_up);
Uarrow.setLineWeight(4);
plot DArrow = if condition2 is true then 1 else 0;
DArrow.SetDefaultColor(Color.white);
DArrow.SetPaintingStrategy(PaintingStrategy.Boolean_ARROW_DOWN);
Darrow.setLineWeight(4);
 
Last edited by a moderator:
rad14733

rad14733

Well-known member
VIP
@chewie76 Looking good...!!! Szcore seems to be popular these days... I've been working away at my Zscore system for the past few days as well... I'm at the point of deciding which criteria I want signals for at the moment... It can be really easy to incorporate too much information so I'm working on narrowing down the plethora of possibilities... I've been waiting to release any code until I get things the way I like them so I don't get distracted by member requests... I like how you are also using the lower Histogram and that you noticed how the Zscore bar beneath the average line is a trigger... (y)
 
K

kfio

New member
VIP
Could you give the code for the lower indicator, can't seem to find it, thanks
 
chewie76

chewie76

Active member
VIP
I've seen the upper indicator arrows repaint (flicker on and off) until the bar closes and the lower indicator paints on the fly until the bar closes...
Right. Once the bar closes, it will not repaint.
 
chewie76

chewie76

Active member
VIP
Example of indicator triggering premarket suggesting bullish day. It turned out correct.
 
F

FOTM_8888

Member
VIP
Thank you for posted the indicator.. a quick question. can you share the candles color indicator? thanks
 
chewie76

chewie76

Active member
VIP
Thank you for posted the indicator.. a quick question. can you share the candles color indicator? thanks
That one is available on tosindicators.com with their membership. Dynamic RSI color candles.
 
B

Bhai

New member
link to the lower indicator not working. can you please check.
@chewie76
 

Similar threads

Top