Color Candles Based on Zig Zag Trend


Category:
0
0

I’m currently using a Zig Zag Percent study. I’m curious if it’s possible to adjust the price color to reflect the Zig Zag trend color? I’ve tried using the assignPriceColor function but haven’t had much luck.

Thanks in advance.

Editor’s note: The title and URL of this question has been adjusted to better reflect the context of the question and make it easier for other viewers to search for and find the solution.

Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on September 16, 2017 2:33 pm
203 views
0
Private answer

Couple things.

First, please be sure to use a brief but descriptive title when creating a new post. This will ensure other viewers searching for a similar solution will be able to quickly find it through the search tools.

Second, be careful about using the trend direction of any of the ZigZag indicators. This group of indicators loop through the chart, changing the trend direction as new candles are added to the right side of the chart. This is called ‘repainting’. That means what you see in the historical data is not exactly what was present when those historical candles were the current active candle on the chart.

The solution is extremely simple. I wish you had posted code showing your attempts. This would enable me to provide a deeper level of teaching on how to apply this method.

It requires a signal line of code. And all I did was to copy the if statement within the “ZZ%”.AssignValueColor() line. Screenshot also included showing how it looks on the chart.

AssignPriceColor(if !isConf then "ZZ%".color("Undefined") else if isUp then "ZZ%".color("Up Trend") else "ZZ%".color("Down Trend"));

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on September 16, 2017 4:06 pm