hugocsalazar
New member
HI!
Would like to have the day's high and the day's low plot if the zscore crosses its average
as found here.
https://usethinkscript.com/threads/z-score-upper-indicator-for-thinkorswim.3896/
The lines should plot when the trigger occurs and stay static.
Only change on the next occurrence of the trigger.
Sorry if I´m not that clear, my english is not the best!
Thanks in advance.
Would like to have the day's high and the day's low plot if the zscore crosses its average
as found here.
https://usethinkscript.com/threads/z-score-upper-indicator-for-thinkorswim.3896/
The lines should plot when the trigger occurs and stay static.
Only change on the next occurrence of the trigger.
Sorry if I´m not that clear, my english is not the best!
Thanks in advance.
Ruby:
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: