Probably not the most efficient code, oh well..
Let me know if it's useful :)
- Made it much more user friendly with options in the input tab
Below you see 2 triangles on the chart. It takes the highest high and lowest low between current price and the triangles, the mid point will be the current moving average value.
The offset (prediction) is calculated by giving it 1 length less than the previous, and an offset 1 more than the previous. This offset should always be true until a new high or new low is made out of the range between the triangles.
Với tinh thần của TradingView, tác giả đã xuất bản tập lệnh theo mã nguồn mở, vì thế trader có thể dễ dàng hiểu và tùy chỉnh được. Bạn có thể sử dụng miễn phí, hoặc tùy chỉnh lại mã đã được cấp phép bởi Quy tắc Chung. Bạn có thể sử dụng nó trên biểu đồ.
You can use this like any other moving average following the trend based on its color or for support and resistance.
How is this useful ?
This type of moving average is very good at following the current direction of the market, either up (yellow) or down (red), staying flat means it will follow its last known direction.
By knowing the calculation of your indicator you can often tell what it is going to do before it actually happened, so you can make a plan in advance.
By looking at the marker (triangles) with in this case a 60 bars look back period, you can tell if the current movement is based on new data or old data.
The plotted prediction is always based on old data, as you can not know new price data before it has happened. Meaning if price doesn't make a new highest or lowest point since the 60 bars back (marker) the next move can be calculated and you can make your trading plan based on that data.