This indicator, and most of the descriptions below, were derived largely from the TradingView reference manual. Feedback and suggestions for improvement are more than welcome, as well are recommended Input settings and best practices for use.
Recommend using the below DMI and PSAR indicators in conjunction with this script to fully visualize and understand how entry and exit conditions are chosen. Variable inputs should correlate between the scripts for uniformity and visual compatibility.
THANKS to LazyBear and his Momentum Squeeze script for helping me quickly develop a momentum state model for coloring the Chop line by trend.
CHOP produces values that determine whether the market is choppy or trending. The closer the value is to 100, the higher the levels, while the closer it is to 0, the stronger the market is trending. Territories for both levels, and their associated upper and lower thresholds, are popularly defined using the Fibonacci Retracements, 61.8 and 38.2.
CHOP is often used to confirm the market condition to help you stay out of sideways markets and only enter when there is movement or imminent explosions. When readings are above the upper threshold, continued sideways movement may be expected, while readings below the lower threshold are typically indicative of a continuing trend. It is also used to anticipate upcoming trendiness changes, with the general belief that extended periods of consolidation (sideways movement) are followed by extended periods of strong, trending, , and vice versa.
One limitation in this index is that you must be cautious in deciding whether the range or trend will likely continue, or if it will reverse.
Confidence in price action and trend is higher when two or more indicators are in agreement -- while this strategy combines CHOP with both DMI and PSAR, we would still recommend pairing with other indicators to determine entry or exit trade opportunities.
Recommend also choosing 'Once Per Bar Close' when creating alerts.
Strategy Direction - an option to only trade Short, Long, Both, or only in the direction of the Trend (Follow Trend is the Default).
Sensitivity - an incremental variable to test whether the past n candles are in the same trend state before triggering a delayed long or short alert (1 is the Default). Can help filter out noise and reduces active alerts.
Show Chop Index - two visual styles are provided for user preference, a visible Chop line with a background overlay, or a compact column and label only view.
Chop Lookback Period - the time period to be used in calculating CHOP (14 is the Default).
Chop Offset - changing this number will move the CHOP either forwards or backwards relative to the current market (0 is the Default).
Smooth Chop Line and Length - if enabled, the entered time period will be used in calculating a smooth average of the index (Enabled and 4 are the Defaults).
Color Line to Trend Direction - toggles whether the index line is colored to visually depict the current trend direction (Enabled is the Default).
Color Background - toggles the visibility of a background color based on the index state (Enabled is the Default).
Enable DMI Option - if enabled, then entry will be confirmed by and dependent on the Key Level, with any close or reversal confirmed by both and +/ to determine whether there is a strong trend present or not (Enabled is the Default).
ADX Smoothing - the time period to be used in calculating the which has a smoothing component (14 is the Default).
DI Length - the time period to be used in calculating the DI (14 is the Default).
ADX Key Level - any trade with the above the key level is a strong indicator that it is trending (23 to 25 is the suggested setting).
Enable PSAR Option - enables trailing stop loss orders (Enabled is the Default).
PSAR Start - the starting value for the Acceleration Force (0.015 is our chosen Default, 0.02 is more common).
PSAR Increment - the increment in which the Acceleration Force will move (0.001 is our chosen Default, 0.02 is more common).
PSAR Max Value - the maximum value of the Acceleration Factor (0.2 is the Default).
Color Candles Option - an option to transpose the CHOP condition levels to the main candle bars. Note that the outer red and green border will still be distinguished by whether each individual candle is or during the specified timeframe.
Note too that if both DMI and PSAR are deselected, then close determinations will default to a CHOP reversal strategy (e.g., close long when below 38.2 and close short when above 61.8). Though if either DMI or PSAR are enabled, then the CHOP reversal for close determination will automatically be disabled.
For the candle colors, black indicates tight chop (45 to 55), yellow is loose chop (38.2 to 45 and 55 to 61.8), dark purple is trending down (< 38.2), and dark blue is trending up (> 61.8).
The background color has additional shades to differentiate a wider range of more levels…
• < 30 is dark purple
• 30 to 38.2 is purple
• 38.2 to 45 is light purple
• 45 to 55 is black
• 55 to 61.8 is light blue
• 61.8 to 70 is blue
• > 70 is dark blue
Long, Short, Close, and Reverse labels are plotted on the Chop line, which itself can be colored based on the trend. The chop line can also be hidden for a clean and compact, columnar view, which is my preferred option (see example image below).
Visual cues are intended to improve analysis and decrease interpretation time during trading, as well as to aid in understanding the purpose of this strategy and how its inclusion can benefit a comprehensive trading plan.
DMI and Trend Strength
To analyze trend strength, the focus should be on the line and not the or lines. An ADX reading above 25 indicates a strong trend, while a reading below 20 indicates a weak or non-existent trend. A reading between those two values would be considered indeterminable. Though what is truly a strong trend or a weak trend depends on the financial instrument being examined; historical analysis can assist in determining appropriate values.
DMI exits trade when is below the user selected key level (e.g., default is 25) and when the +/- DI lines cross (e.g., > exits long position and > exits short position).
PSAR and Trailing Stop
PSAR is a time and price based indicator that excels at measuring direction and duration, though not the actual strength of a trend, which is why we use this in conjunction with DMI. It is also included in this script as a trailing stop option to maximize gains during strong trends and to mitigate any false strengthening signals.
This creates a parabola that is located below the candle during a and above during a . A buy or reversal is signaled when the price crosses above or below the .
1. CHOP must be over 61.8 (long) or under 38.2 (short).
2. If DMI is enabled, then the signal line must be above the user selected Key Level (default is 25).
3. If Sensitivity is selected, then that past candle must meet the criteria in step 1, as well as all the intermediate candles in between.
4. If "Follow Trend" is selected and PSAR is enabled, then a long position can only open when the momentum and PSAR are in an uptrend, or short when both are in a downtrend, to include all intermediate candles if the Sensitivity option is set on a past candle.
1. If DMI is enabled, then a close flag will be raised when the signal drops below the Key Level (of 25), and crosses over (if long), or crosses over (if short).
2. If PSAR is enabled, then a close flag will be raised when the current trend state is opposite the last state.
3. If both DMI and PSAR are disabled, then a close flag will be raised if the Chop line drops under 38.2 (if long) or goes over 61.8 (if short).
4. If a Long or Short Entry is triggered on the same candle as any of the above close flags, then the position will be reversed, else the position will be closed.
1. Long Entry
2. Short Entry
The provided backtest result is based on a position sizing of 10% equity with 100k initial capital. When testing SPX , disabling the DMI performed the best, but EURUSD performed poorly without it enabled, and TSLA had a small reduction in net profit. Timeframe likewise differed between with TSLA performing best at 30M, SPX at 15M, and EURUSD at 4H. I do not plan on using this as a standalone strategy, but I also was expecting better results with the inclusion of EMI and PSAR to compliment the CHOP. Key elements of this script will likely be included in future, more holistic strategies.
Past performance may not be indicative of future results. Due to various factors, including changing market conditions, the strategy may no longer perform as well as in historical backtesting. This post and the script are not intended to provide any financial advice. Trade at your own risk.
No known repainting, though there may be if an offset is introduced in the Inputs. I did my best not to code any other variables that repaint, but cannot fully attest to this fact.
- Cleaned up selectable option to display Chop Index as a Line, Colored Line (using Momentum Trend), Colored Line (using PSAR Trend), or as Columns.
- Added option to color Chop Index line by PSAR trend direction, as opposed to only the momentum trend. This is useful to also help understand when a position exit is triggered by a PSAR reversal.
- Changed Follow Trend to only use the momentum or PSAR, not both. PSAR is the default in all cases unless the trend line with momentum is explicitly displayed. Note that the noisy nature of the momentum line could result in a missed Bullish or Bearish entry.
- Updating script description image to show companion DMI indicator with only Exit conditions shown. This is useful in understanding how a position exit is triggered by DI crossover or ADX trend below the key level.
- Removed Input to enable Smooth Line. This has redundant functionality -- the default Smooth Length is still 4, but changing this value to 1 has the same effect as disabling the Smooth Line checkbox.
- Reorganized Input selections for readability and user efficiency.
진정한 TradingView의 정신에 따라, 이 스크립트의 작성자는 스크립트를 오픈소스로 게시했기에 거래자들이 이해하고 확인할 수 있습니다. 작가님께 건배! 스크립트를 무료로 사용할 수 있지만, 게시물에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 당신은 스크립트를 차트에 사용하기 위해 그것을 즐겨찾기 할 수 있습니다.