Find the trend lines DEMO
The script draws trendlines on a chart. Each line is drawn based on two highs and two lows. The program is specific in the way it defines these points.
First it finds the highs and lows on the chart. Determines the size of the candlesticks that have formed these extremes. Next, it defines the distance that the price has passed after this extremum. It should be several times larger than the candlestick size (default is 3 times). The lines will be drawn only based on such points.
It is very likely that these were the points of the largest imbalance of supply and demand, which is why the price moved away from that level.
The script draws a few lines. For example, it finds the two points T1 and T2, wherein T2 is higher than T1, the script draws the first line. If it finds the third point T3, which is even higher (above T2), the second line is drawn at two points T2 and T3. There can be 5 lines.
Then the script counts the number of candlestick around each line and finds the most "popular" line. Because the price moved along this line and moved away from it more often, it is considered to be a trend line. The script deletes the lines on the opposite side of the price. This feature can be disabled in the settings, and the script will not determine the trend, but will only draw the lines.
The script is an excellent addition to the Price Action Levels analyzer. It allows to determine the direction of trade and filter the levels that can be broken through by the price.
Basically, the names of the settings reflect their meaning. Only some of them require explanation:
- how many bars to analyze - the number of bars from the last bar
- indicate the beginning of the search - if true, during the first launch it will create a vertical line, which you can move to the desired distance, from which the analysis starts. The number of bars specified in the first parameter is not considered.
- identify the trend - enables/disabled trend detection function. If enabled, the script will determine the direction and remove the opposite lines.
- minimum width of the level - the minimum size of the candlestick that has formed the high or the low. It is compared with the distance, that the price moves after that.
- ratio of the width of the level to move after - this is the comparison of the candlestick size with the distance after. If the candlestick with the high is 100 points, the price must pass 300 points, then the level will be taken into account.