OPEN-SOURCE SCRIPT
Xen's Flag Pattern Scalper

1. Input Parameters:
2 Flag Conditions:
3. Entry Price:
4. Stop Loss:
5. Take Profit Levels:
6. Plotting Signals and Levels:
7. Label Placement:
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.
- 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が提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、この作者はスクリプトのソースコードを公開しているので、その内容を理解し検証することができます。作者に感謝です!無料でお使いいただけますが、このコードを投稿に再利用する際にはハウスルールに従うものとします。
免責事項
これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。