OPEN-SOURCE SCRIPT

Xen's Flag Pattern Scalper

1. Input Parameters:

  • FlagLength: Determines the length of the flag pattern.

  • TakeProfit1Ratio, takeProfit2Ratio, takeProfit3Ratio: Define the ratios for calculating
    the take-profit levels relative to the entry price.

  • RiskRewardRatio: Specifies the risk-reward ratio for calculating the stop-loss level
    relative to the entry price.


2 Flag Conditions:
  • BullishFlag: Checks if the current bar meets the conditions for a bullish flag pattern. It
    evaluates to true if the low of the current bar is lower than the low flagLength bars
    ago, and the close of the current bar is higher than the high flagLength bars ago.

  • BearishFlag: Checks if the current bar meets the conditions for a bearish flag pattern. It evaluates to true if the high of the current bar is higher than the high flagLength bars
    ago, and the close of the current bar is lower than the low flagLength bars ago.


3. Entry Price:
  • EntryPrice: Calculates the entry price based on whether a bullish or bearish flag
    pattern is identified. For a bullish flag, the entry price is set to the low of the current bar.
    For a bearish flag, the entry price is set to the high of the current bar.


4. Stop Loss:
  • StopLoss: Determines the stop-loss level based on the entry price and the specified
    riskRewardRatio. For a bullish flag, the stop-loss level is calculated by subtracting the
    difference between the high and low of the current bar multiplied by the riskRewardRatio from the low of the current bar. For a bearish flag, the stop-loss level
    is calculated similarly but added to the high of the current bar.


5. Take Profit Levels:
  • Three take-profit levels (takeProfit1, takeProfit2, takeProfit3) are calculated based on
    the entry price, stop-loss level, and specified take-profit ratios (takeProfit1Ratio,
    takeProfit2Ratio, takeProfit3Ratio
    ).


6. Plotting Signals and Levels:
  • Bullish and bearish flag patterns are plotted using triangle shapes (shape.triangleup for
  • bullish and shape.triangledown for bearish) above or below the bars, respectively.

  • Entry, stop-loss, and take-profit levels are plotted using horizontal lines (line.new)
    with different colors and styles. Entry and stop-loss levels are labeled with "Entry" and "SL",
    respectively, while take-profit levels are labeled with "TP 1", "TP 2", and "TP 3".

  • The colors for bullish flags are white for entry, red for stop-loss, and green for take-profit levels. For bearish flags, the colors are the same, but the labels are plotted above the bars.


7. Label Placement:
  • Labels for entry, stop-loss, and take-profit levels are placed a distance of 4 bars to the right
    of the entry price using bar_index + 4.


This indicator is intended to help traders identify flag patterns on price charts and visualize potential entry, stop-loss, and take-profit levels associated with these patterns.

Please use risk management and when TP1 is hit, move stoploss to breakeven.
Chart patterns

오픈 소스 스크립트

진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

차트에 이 스크립트를 사용하시겠습니까?

면책사항