xenathe

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.
開源腳本

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?