Strategy Description: "Breaks and Retests - Free990" The "Breaks and Retests - Free990" strategy is based on identifying breakout and retest opportunities for potential entries in both long and short trades. The idea is to detect price breakouts above resistance levels or below support levels, and subsequently identify retests that confirm the breakout levels. The strategy offers an automated approach to enter trades after a breakout followed by a retest, which serves as a confirmation of trend continuation.
Key Components: Support and Resistance Detection:
The strategy calculates pivot levels based on historical price movements to define support and resistance areas. A lookback range is used to determine these key levels. Breakouts and Retests:
The system identifies when a breakout occurs above a resistance level or below a support level. It then waits for a retest of the previously broken level as confirmation, which is often a better entry opportunity. Trade Direction Selection:
Users can choose between "Long Only," "Short Only," or "Both" directions for trading based on their market view.
Stop Loss and Trailing Stop: An initial stop loss is placed at a defined percentage away from the entry. The trailing stop loss is activated after the position gains a specified percentage in profit.
Long Entry: A long entry is triggered if the price breaks above a resistance level and subsequently retests that level successfully. The entry condition checks if the breakout was confirmed and if a retest was valid. The long entry is only executed if the user-selected direction is either "Long Only" or "Both."
Short Entry:
A short entry is triggered if the price breaks below a support level and subsequently retests that level. The short entry is only executed if the user-selected direction is either "Short Only" or "Both."
sell_condition checks whether the support has been broken and whether the retest condition is valid. An initial stop loss is placed when the trade is opened to limit the risk if the trade moves against the position. The stop loss is calculated based on a user-defined percentage (stop_loss_percent) of the entry price.
pinescript Copy code stop_loss_price := strategy.position_avg_price * (1 - stop_loss_percent / 100) For long positions, the stop loss is placed below the entry price. For short positions, the stop loss is placed above the entry price. Trailing Stop:
When a position achieves a certain profit threshold (profit_threshold_percent), the trailing stop mechanism is activated. For long positions, the trailing stop follows the highest price reached, ensuring that some profit is locked in if the price reverses. For short positions, the trailing stop follows the lowest price reached. Code Logic for Trailing Stop:
Exit Execution:
The strategy exits the position when the price hits the calculated stop loss level. This includes both the initial stop loss and the trailing stop that adjusts as the trade progresses. Code Logic for Exit:
Summary: Breaks and Retests - Free990 uses support and resistance levels to identify breakouts, followed by retests for confirmation. Entry Points: Triggered when a breakout is confirmed and a retest occurs, for both long and short trades. Exit Points: Initial Stop Loss: Limits risk for both long and short trades. Trailing Stop Loss: Locks in profits as the price moves in favor of the position. This strategy aims to capture the momentum after breakouts and minimize losses through effective use of stop loss and trailing stops. It gives the flexibility of selecting trade direction and ensures trades are taken with confirmation through the retest, which helps to reduce false breakouts.
진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.