Strategy Overview This strategy, named "Trendlines with Breaks Strategy [AlexGoldHunter]", is designed to identify and trade trendline breakouts. It uses pivot highs and lows to detect significant levels and calculates slopes to plot trendlines. The strategy places buy and sell orders based on these trendlines and triggers alerts for potential breakouts.
Inputs and Parameters Swing Detection Lookback (length): Defines the number of bars to look back for identifying pivot highs and lows.
Slope Multiplier (mult): Adjusts the steepness of the trendlines.
Slope Calculation Method (calcMethod): Determines how the slope is calculated (Atr, Stdev, or Linreg).
Backpainting (backpaint): Toggles the display of elements in the past, providing real-time information when disabled.
Style Settings Up Trendline Color (upCss): Color for upward trendlines (default: teal).
Down Trendline Color (dnCss): Color for downward trendlines (default: red).
Show Extended Lines (showExt): Option to show extended trendlines.
Calculations Pivot High (ph) and Pivot Low (pl): Identifies significant highs and lows based on the lookback period.
Slope Calculation: Determines the slope of trendlines using the selected calculation method.
Trendline Calculation: Updates the positions of the upper and lower trendlines based on the pivot points and slopes.
Plotting Upper and Lower Trendlines: Plots the calculated trendlines on the chart.
Breakout Labels: Adds labels "alex_buy_now" for upward trendline breaks and "alex_sell_now" for downward trendline breaks.
Strategy Conditions Buy Condition:
Triggers a buy order when the price breaks above the downward trendline.
Sell Condition:
Triggers a sell order when the price breaks below the upward trendline.
Alerts Upward Breakout Alert: Notifies when the price breaks above the downward trendline.
Downward Breakout Alert: Notifies when the price breaks below the upward trendline.
Example Code Explanation
//version=5 strategy("Trendlines with Breaks Strategy [AlexGoldHunter]", overlay=true)
// Input parameters length = input.int(14, title="Swing Detection Lookback") mult = input.float(1.0, title="Slope", minval=0, step=0.1) calcMethod = input.string('Atr', title="Slope Calculation Method", options=['Atr','Stdev','Linreg']) backpaint = input(true, tooltip='Backpainting offset displayed elements in the past. Disable backpainting to see real-time information returned by the indicator.')
This script effectively integrates the trendline detection, breakout identification, and automated trading into a single strategy, making it a powerful tool for technical traders on TradingView. If you have any questions or need further clarification, feel free to ask!
Follow Alexgoldhunter for more strategic ideas and minds
진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.