anandanand84 / technicalindicators

A javascript technical indicators written in typescript with pattern recognition right in the browser
MIT License
2.15k stars 558 forks source link

Trendline #100

Open heekah7 opened 6 years ago

heekah7 commented 6 years ago

Btw any chance that a trend line can be computed algorithmically?

anandanand84 commented 6 years ago

@heekah7 I am working on it.

heekah7 commented 6 years ago

Some idea from my research. 1) By using zipzap indicator we can identify all the high and low of the stock. 2) Then draw all possible trend-line 3) Filter trendline by a) АB/BС distances ratio b) Number of times the price crosses the AB segment c) Number of times the price crosses the BC segment d) Distance from С to the current price e) Minimum and maximum line length f) Line slope g) Price location above or below the resistance line

Let's consider the above criteria in more details to better understand the inputs configuration. To maintain acceptable proportions, you can use the Fibo ratios and set the minimum allowable ratio to 0.25 or 0.382. According to this criterion, the length ratios should correspond to the condition АB/АС>=02.25 (0.382) and BС/АС>=02.25 (0.382). For convenience, the value of this parameter can be set in the inputs. All existing lines should also be thoroughly sorted by the number of times the price crosses the AB line. There are many options for how to conduct such verification. We can consider only the bars that closed breaking through this line, or we can consider a breakthrough by High/Low prices. The second criterion for this verification is the number of bars that crossed this line segment. These parameters are also made as inputs. We can evaluate the line importance by a number of breakthroughs, their nature and the current price location relative to the BC segment. All of the above criteria can be used both for forming a line and for forming trading strategies when developing EAs. In this indicator, we will only display the lines that have not yet crossed this segment. The distance from the current price to the line in the first place can be filtered according to the line's current relevance. For example, we may plot only the lines, the distance to which does not exceed 50-100 points. The minimum length of the line in our case is determined by the inputs of the ZigZag indicator, but this parameter can also be monitored if necessary. The indicator will check the minimum lengths of AB and BC segments. Since the support lines are more significant because they are used to open positions, the indicator constructs the lines with zero or positive slope for an uptrend and the lines with zero or negative slope for a downtrend. We can use the lines in two ways. The first one is considering only unbroken lines and trade in the direction of a trend. The second one is using only a breakthrough of trend lines for opening trades in the opposite direction. Both types of lines are important, therefore both are to be reflected in the indicator.

casparss commented 3 years ago

This TA package supports generated support/resistance data. Haven't used it yet, I'm using manual trendlines at the momemt but fully intend to implement this.

https://www.npmjs.com/package/trendyways