mufasis
New member
So I just created this simple script for z-score and I want to create some arrows or warnings when z-score is above 3 or below -3, how can I do that? Thanks!
# Declare
declare lower;
# Inputs
input price = close;
input length = 21;
# Calculate rolling mean and standard deviation
def mean = movingAverage(averageType.SIMPLE, price, length);
def deviation = standardDeviation(price, length);
# Calculate Z-Score
def z_score = (price - mean) / deviation;
# Plots
plot zscore = z_score;
plot zscore_avg = movingAverage(averageType.SIMPLE, z_score, length);
plot zero = 0;
plot three = 3;
plot negativeThree = -3;
# Set Z-Score to histogram and set colors
zscore.setPaintingStrategy(paintingStrategy.HISTOGRAM);
zscore.assignValueColor(if zscore > 0 then color.GREEN else color.red);
# Define signals
# Plot signals
# Declare
declare lower;
# Inputs
input price = close;
input length = 21;
# Calculate rolling mean and standard deviation
def mean = movingAverage(averageType.SIMPLE, price, length);
def deviation = standardDeviation(price, length);
# Calculate Z-Score
def z_score = (price - mean) / deviation;
# Plots
plot zscore = z_score;
plot zscore_avg = movingAverage(averageType.SIMPLE, z_score, length);
plot zero = 0;
plot three = 3;
plot negativeThree = -3;
# Set Z-Score to histogram and set colors
zscore.setPaintingStrategy(paintingStrategy.HISTOGRAM);
zscore.assignValueColor(if zscore > 0 then color.GREEN else color.red);
# Define signals
# Plot signals