Pine Script Strategy: KON SET By Sai:
Overview:
This Pine Script strategy, KON SET By Sai, is designed for trend-based trading. It detects entry points based on price crossovers with a smoothed moving average, sets dynamic stop-loss and target prices using ATR, and includes a re-entry mechanism when the price retraces within a buffer zone.
Key Features:
✅ Trend-Based Entry – Uses moving averages and ATR to detect trend shifts.
✅ ATR-Based Stop-Loss & Target – Dynamically adjusts risk levels.
✅ Re-Entry Mechanism – Allows new entries when price revisits the entry zone.
✅ Visual & Alert System – Displays key levels and sends alerts on signals.
Strategy Logic
1️⃣ Entry Conditions
A long trade is initiated when the closing price crosses above a dynamically calculated resistance level (sma_high).
Entry price: close price at signal.
Stop-loss: 2x ATR below entry.
Target: 5x ATR + user-defined multiplier above entry.
pinescript
Copy
Edit
signal_up = ta.crossover(close, sma_high)
if not inTrade and signal_up
entryPrice := close
stopLoss := close - atr_value * 2
targetPrice := close + atr_value * (5 + target_multiplier)
strategy.entry("Long", strategy.long)
strategy.exit("Exit Long", "Long", stop=stopLoss, limit=targetPrice)
📌 Alerts:
Sends an entry alert with price details when a trade is triggered.
2️⃣ Trade Exit Conditions
The position closes when:
✔ Price reaches the target
✔ Price hits the stop-loss
pinescript
Copy
Edit
if inTrade and (close <= stopLoss or close >= targetPrice)
inTrade := false
entryPrice := na
stopLoss := na
targetPrice := na
Labels and lines are cleared to avoid clutter.
3️⃣ Re-Entry Mechanism
If a trade closes and price retraces within a buffer range, a new entry is triggered.
The re-entry buffer is ATR-based to avoid false signals.
Ensures only one re-entry per signal to prevent overtrading.
pinescript
Copy
Edit
if not inTrade and close >= lastEntryPrice - re_entry_buffer and close <= lastEntryPrice + re_entry_buffer
entryPrice := close
stopLoss := close - atr_value * 2
targetPrice := close + atr_value * (5 + target_multiplier)
strategy.entry("Re-Long", strategy.long)
strategy.exit("Re-Exit Long", "Re-Long", stop=stopLoss, limit=targetPrice)
lastEntryPrice := na
📌 Alerts:
Sends a re-entry alert when a new position is taken.
Visual Enhancements
🟢 Entry Labels – Marks trade entries on the chart.
🔴 Stop-Loss Labels – Displays stop-loss levels.
🔵 Target Labels – Highlights target points.
pinescript
Copy
Edit
entryLabel := label.new(bar_index, entryPrice, text="Entry: " + str.tostring(entryPrice, "#.##"), color=color.green)
slLabel := label.new(bar_index, stopLoss, text="Stop Loss: " + str.tostring(stopLoss, "#.##"), color=color.red)
targetLabel := label.new(bar_index, targetPrice, text="Target: " + str.tostring(targetPrice, "#.##"), color=color.blue)
📌 Background Zones:
Green: Active trade within entry & target range.
Red: Stop-loss risk area.
Customization Options
Users can adjust:
✅ ATR Length & Smoothing (for volatility-based stop-loss & targets).
✅ Trend Length (for moving average sensitivity).
✅ Target Multiplier (to fine-tune profit-taking).
✅ Re-Entry Buffer (to control re-entry conditions).
pinescript
Copy
Edit
length = input.int(10, "Trend Length")
target_multiplier = input.int(0, "Target Multiplier")
atr_length = input.int(200, "ATR Length")
atr_smoothing = input.int(200, "ATR Smoothing")
re_entry_buffer_multiplier = input.float(0.5, "Re-entry Buffer Multiplier")
Conclusion
🛠 KON SET By Sai is a trend-following strategy with an adaptive risk-reward system.
✅ Ideal for volatile markets with clear trends.
✅ Works well with multiple assets (Forex, Stocks, Crypto).
✅ Customizable parameters for flexible trading styles.
📌 How to Use:
1️⃣ Backtest on different assets & timeframes.
2️⃣ Fine-tune parameters for better performance.
3️⃣ Use alerts for live monitoring.