Set Scan for ZigZag patterns


Category:
0
0

Here is the script below that I would like to set a scan for when the stock is on an uptrend and then another scan for when the stock is in a downtrend. Is this even possible?

input price = close;
input reversalAmount = 8.0;
input showBubbles = no;
input showLabel = no;

assert(reversalAmount > 0, “‘reversal amount’ should be positive: ” + reversalAmount);

plot “ZZ%” = reference ZigZagHighLow(price, price, reversalAmount, 0, 1, 0);

def zzSave = if !IsNaN(“ZZ%”) then price else getValue(zzSave, 1);
def chg = (price / getValue(zzSave, 1) – 1) * 100;
def isUp = chg >= 0;
def isConf = AbsValue(chg) >= reversalAmount or (IsNaN(getValue(“ZZ%”, 1)) and getValue(isConf, 1));

“ZZ%”.EnableApproximation();
“ZZ%”.DefineColor(“Up Trend”, Color.UPTICK);
“ZZ%”.DefineColor(“Down Trend”, Color.DOWNTICK);
“ZZ%”.DefineColor(“Undefined”, Color.DARK_ORANGE);
“ZZ%”.AssignValueColor(if !isConf then “ZZ%”.color(“Undefined”) else if isUp then “ZZ%”.color(“Up Trend”) else “ZZ%”.color(“Down Trend”));

DefineGlobalColor(“Unconfirmed”, Color.DARK_ORANGE);
DefineGlobalColor(“Up”, Color.UPTICK);
DefineGlobalColor(“Down”, Color.DOWNTICK);

def barNumber = barNumber();

AddChartBubble(showBubbles and !IsNaN(“ZZ%”) and barNumber != 1, price, round(chg) + “%”, if !isConf then globalColor(“Unconfirmed”) else if isUp then globalColor(“Up”) else globalColor(“Down”), isUp);
#AddLabel(showLabel and barNumber != 1, (if isConf then “Confirmed ” else “Unconfirmed “) + “ZigZag: ” + round(chg) + “%”, if !isConf then globalColor(“Unconfirmed”) else if isUp then globalColor(“Up”) else globalColor(“Down”));

Marked as spam
Posted by (Questions: 6, Answers: 3)
Asked on November 25, 2019 8:39 am
136 views
0
Private answer

Sorry but ZigZag studies are not useful for anything except training your eyes to see the structure of the market. I wish more care were taken to explain this to folks. The signals created by any ZigZag study are subject to repainting. There is no way to build a scan, strategies or alerts using any ZigZag study.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on November 25, 2019 6:42 pm