Tang Qian Channel - MetaTrader 4 Script - MQL5 #47258 - MT4/MT5 Resources

The Donchian Channel is an indicator used in market trading developed by Richard Donchian and is formed by taking the highest and lowest points of the last n periods. The area between the highs and lows is the channel for the selected period.
A line marked with high and low values visually shows the channel of market price. The indicator also includes a midline and a moving average above the midline.
The Donchian Channel is a useful indicator for understanding market price volatility. If prices are stable, the Donchian channel will be relatively narrow. If prices fluctuate significantly, the Donchian Channel will be wider. However, its main use is to provide signals for long and short positions.
A long position is established if the security trades above its highest n-period high. If the trading price is below the lowest point of n periods, a short position is established.
The indicator is represented using four buffers;
Upper Tangchian Pass - Buffer Zone 0 - Green Line
Zhongtang Qian Channel - Buffer Zone 1 - Blue Line
Lower Tangchian Strait - Buffer Zone 2 - Green Line
MA Donchian Channel - Buffer 3 - Red Line
The code is quite simple, it gets the highest and lowest price of the last "n" periods in InpBarsToLookBack. The highest and lowest values are then averaged to create the centerline of the channel. Then, use the iMAOnArray function to obtain the moving average of the mid-Donchian channel based on the input parameters InpMaPeriod and InpMaMethod.
The output on the chart consists of the four buffers outlined above. If desired, you can change the color to None to show only the required buffers.
Use iCustom function to call the indicator;
double donchian = iCustom(Symbol(), Period(), "Donchian Channel", InpBarsToLookBack, InpMaPeriod, InpMaMethod, Buffer[], shift);
To use the script call the last price of the moving average buffer with default parameters;
double donchian = iCustom(Symbol(), period(), "Donchian channel", 20, 14, MODE_SMA, 3, 0);
Thank you for taking the time to download this indicator. Please feel free to post any questions related to this indicator, it will be greatly appreciated.
Attachment download
📎 donchian_channel.mq4 (4.65 KB)
Source: MQL5 #47258
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •