Biên tập viên chọn
OPEN-SOURCE SCRIPT

Extreme Trend Reversal Points [HeWhoMustNotBeNamed]

Cập nhật
Using moving average crossover for identifying the change in trend is very common. However, this method can give lots of false signals during the ranging markets. In this algorithm, we try to find the extreme trend by looking at fully aligned multi-level moving averages and only look at moving average crossover when market is in the extreme trend - either bullish or bearish. These points can mean long term downtrend or can also cause a small pullback before trend continuation. In this discussion, we will also check how to handle different scenarios.

🎲 Components
🎯 Recursive Multi Level Moving Averages
Multi level moving average here refers to applying moving average on top of base moving average on multiple levels. For example,

Level 1 SMA = SMA(source, length)
Level 2 SMA = SMA(Level 1 SMA, length)
Level 3 SMA = SMA(Level 2 SMA, length)
..
..
..
Level n SMA = SMA(Level (n-1) SMA, length)

In this script, user can select how many levels of moving averages need to be calculated. This is achieved through "recursive moving average" algorithm. Requirement for building such algorithm was initially raised by loxx
While I was able to develop them in minimal code with the help of some of the existing libraries built on arrays and matrix, I also thought why not extend this to find something interesting.

Note that since we are using variable levels - we will not be able to plot all the levels of moving average. (This is because plotting cannot be done in the loop). Hence, we are using lines to display the latest moving average levels in front of the last candle. Lines are color coded in such a way that least numbered levels are greener and higher levels are redder.

ảnh chụp nhanh

🎯 Finding the trend and range
Strength of fully aligned moving average is calculated based on position of each level with respect to other levels.

For example, in a complete uptrend, we can find

source > L(1)MA > L(2)MA > L(3)MA ...... > L(n-1)MA > L(n)MA

Similarly in a complete downtrend, we can find

source < L(1)MA < L(2)MA < L(3)MA ...... < L(n-1)MA < L(n)MA

Hence, the strength of trend here is calculated based on relative positions of each levels. Due to this, value of strength can range from 0 to Level*(Level-1)/2

0 represents the complete downtrend
Level*(Level-1)/2 represents the complete uptrend.

Range and Extreme Range are calculated based on the percentile from median. The brackets are defined as per input parameters - Range Percentile and Extreme Range Percentile by using Percentile History as reference length.

Moving average plot is color coded to display the trend strength.

Green - Extreme Bullish
Lime - Bullish
Silver - range
Orange - Bearish
Red - Extreme Bearish

https://www.tradingview.com/x/GPocC07Q/

🎯 Finding the trend reversal
Possible trend reversals are when price crosses the moving average while in complete trend with all the moving averages fully aligned. Triangle marks are placed in such locations which can help observe the probable trend reversal points. But, there are possibilities of trend overriding these levels. An example of such thing, we can see here:

ảnh chụp nhanh

In order to overcome this problem, we can employ few techniques.

1. After the signal, wait for trend reversal (moving average plot color to turn silver) before placing your order.
2. Place stop orders on immediate pivot levels or support resistance points instead of opening market order. This way, we can also place an order in the direction of trend. Whichever side the price breaks out, will be the direction to trade.
3. Look for other confirmations such as extremely bullish and bearish candles before placing the orders.


🎯 An example of using stop orders

Let us take this scenario where there is a signal on possible reversal from complete uptrend.
ảnh chụp nhanh

Create a box joining high and low pivots at reasonable distance. You can also chose to add 1 ATR additional distance from pivots.
ảnh chụp nhanh

Use the top of the box as stop-entry for long and bottom as stop-entry for short. The other ends of the box can become stop-losses for each side.

After few bars, we can see that few more signals are plotted but, the price is still within the box. There are some candles which touched the top of the box. But, the candlestick patterns did not represent bullishness on those instances. If you have placed stop orders, these orders would have already filled in. In that case, just wait for position to hit either stop or target.

ảnh chụp nhanh

For bullish side, targets can be placed at certain risk reward levels. In this case, we just use 1:1 for bullish (trend side) and 1:1.5 for bearish side (reversal side)

ảnh chụp nhanh

In this case, price hit the target without any issue: ảnh chụp nhanh

Wait for next reversal signal to appear before placing another order :)


Phát hành các Ghi chú
Updated short title
Phát hành các Ghi chú
Updated libraries and added alerts on popular demand :)
hewhomustnotbenamedMoving AveragesTrend Analysistrendoscope

Mã nguồn mở

Theo tinh thần TradingView thực sự, tác giả của tập lệnh này đã xuất bản dưới dạng nguồn mở để các nhà giao dịch có thể hiểu và xác minh. Chúc mừng tác giả! Bạn có thể sử dụng miễn phí. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?

Thông báo miễn trừ trách nhiệm