Работа завершена
Техническое задание
Hi,
i need an ZigZag Indicator which also identifies the higher trendlevels.
The ZigZag indicator should start at a reltive high or low. Relative high is where the previous high of a candle and the next high of a candle was lower, relative low same but the previous low and next low must be higher. There should be an input how many candles in the past the indicator should look for this, e.g. 100, means 100 candles back, if 102 fullfill the creteria of relative high or low, then start with this.
Once the first candle found, the indicator should paint the lines indicating an upward or downward movement.
(1) Upward (2) cannot occur as there isnt a relative high or low (3) downward (4) neutral, wait for next candle
Once the initial movement is defined, all of the four situations above may occur. Lets assume there is an upward movement. (1) Continuing upward (3) turning from upward to downward (4) neutral, next candle, still upward .... what about (2)? its having higher high and lower low. Rule here: The existing overrules, if upward, then continuing upward when the candle body is long, if downward, continuing downward, WHEN the candle body is short, else turn.
On this lowest trendlevel the trend is defined. Its going up and down, creating 123 pattern. The next higher trendlevel only refers to the lowest trendlevel. As long the lowest trendlevel is in a downtrend, the upper trendlevel is in a downward movement, if the lowest trend is in an upward trend, the upper trendlevel is in an upward movement.
Ok but when the upward / downward movement of the upper level begin? When the lowest level starts an upward or downward trend by 123 pattern. Attention! When the lowest trend level breaks an upward or downward trend is the same as if a counter trend established.
Input is the number of historic candles. Outcome is the lowest trend level with lines, as per logic, it doesnt repaint. The upper level is painted based on the lowest trendlevel and will not repaint too.
Example
more examples grey line is lowest trend level, green and red are the upper trend
Another example for clarification,the lowest trend level (grey line) follows the highs and lows of the candles. Only the four situations explained above can occur. The upper trend level only follows the lowest trend level. You see how the trend breaks at the lowest level also defines upward or downward movements of the upper level. I have more examples if needed.