20-EMA Reversal Scalp Strategy

20-EMA Reversal Scalp Strategy

20-EMA Reversal Scalp Strategy

1. Introduction & Basics

📚 Pine Script 101: Basics for Beginners

Pine Script is the programming language used to create custom indicators and strategies on TradingView. It's designed to be simple and powerful. Here are the core components you need to know: More Info Here

This strategy is specially optimized for high-momentum instruments like **NIFTY, BANKNIFTY, Bitcoin (BTC), and Ethereum (ETH)** on a 5-minute chart. It's a quick, mechanical approach to trading volatility.


2. Simplified Core Logic: The Rubber Band Effect

The strategy is based on the powerful concept of **Mean Reversion**. Think of the **20-EMA** as the anchor (or mean value). When the price is pushed too far away from the anchor by a sudden surge in volume and an extreme RSI reading, the market tends to 'snap back' to the 20-EMA very quickly. This script identifies that overextended moment for a rapid scalp trade.

🎯 The trade goal is simple: Enter at the extreme reversal point and exit when the price touches the 20-EMA.


3. What the Pine Script Automates

This is an **automated strategy** that initiates the trade, closes the trade at the EMA, and uses smart parameters based on the market selected.

  • Entry Conditions (4-Factor Confirmation):
    • **Big Move:** Price movement must be significantly larger than the average movement (ATR Multiplier).
    • **RSI Extreme:** RSI (3 period) must confirm **oversold** (for Long) or **overbought** (for Short) conditions using market-specific levels (e.g., Nifty 22/78, BTC 18/82).
    • **Volume Surge:** Requires a sudden volume spike (e.g., 2.5x the average) to validate the conviction.
    • **EMA Distance:** Ensures the price is far enough from the 20-EMA line.
  • Exit Condition (Profit Target):

    The script automatically executes a `strategy.close()` command when the price closes near the 20-EMA, locking in the reversal profit.


4. Step-by-Step Usage Guide

  1. Setup & Chart: Open **TradingView**, load your symbol (e.g., NSE:NIFTY), and switch to the **5-minute chart**.
  2. Install Script: Open the **Pine Editor (F4)**, paste the code from Section 5 below, and click **"Add to Chart."**
  3. Configure Inputs: In the strategy settings, ensure you select the correct **Market** (`NIFTY`, `BANKNIFTY`, `BTC`, or `ETH`). The script adjusts its internal logic automatically.
  4. Set Stop Loss Manually: **Crucial Step:** The Pine Script closes the trade automatically for profit (at EMA), but you **MUST** place a manual Stop Loss order with your broker (e.g., -35 points for Nifty, -2.5% for BTC) to manage risk.

5. Pine Script Code (Copy-Paste)

//@version=5
strategy("Simple 20-EMA Reversal - NIFTY/BTC", overlay=true)

// Basic Inputs
market_type = input.string("NIFTY", "Market", options=["NIFTY", "BANKNIFTY", "BTC", "ETH"])

// Indicators
atr_value = ta.atr(14)
ema_20 = ta.ema(close, 20)
rsi_fast = ta.rsi(close, 3)
volume_avg = ta.sma(volume, 20)

// Market-specific settings (Conditional Assignments)
atr_multiplier = market_type == "NIFTY" ? 1.6 : market_type == "BANKNIFTY" ? 1.8 : market_type == "BTC" ? 1.9 : 1.8
rsi_upper = market_type == "NIFTY" ? 78 : market_type == "BANKNIFTY" ? 80 : market_type == "BTC" ? 82 : 81
rsi_lower = market_type == "NIFTY" ? 22 : market_type == "BANKNIFTY" ? 20 : market_type == "BTC" ? 18 : 19
volume_multiplier = market_type == "NIFTY" ? 2.2 : market_type == "BANKNIFTY" ? 2.5 : market_type == "BTC" ? 2.8 : 2.6

// Signals
price_move = math.abs(close - close[1])
big_move = (price_move / atr_value) >= atr_multiplier
volume_surge = (volume / volume_avg) >= volume_multiplier
ema_distance = (math.abs(close - ema_20) / atr_value) >= 1.0

long_signal = big_move and close < close[1] and rsi_fast <= rsi_lower and volume_surge and ema_distance
short_signal = big_move and close > close[1] and rsi_fast >= rsi_upper and volume_surge and ema_distance

// Execute trades
if long_signal
    strategy.entry("Long", strategy.long)
    
if short_signal
    strategy.entry("Short", strategy.short)

// Exit at EMA (Profit Target)
if strategy.position_size > 0 and math.abs(close - ema_20) <= (close * 0.0005)
    strategy.close("Long")
    
if strategy.position_size < 0 and math.abs(close - ema_20) <= (close * 0.0005)
    strategy.close("Short")

// Visuals
plot(ema_20, "20 EMA", color=color.blue)
plotshape(long_signal, "Long", shape.triangleup, location.belowbar, color=color.green)
plotshape(short_signal, "Short", shape.triangledown, location.abovebar, color=color.red)

Your Next Step: Start Small, Learn Daily!

This strategy emphasizes **consistency** over big, occasional wins. Start with **paper trading** or very small risk (e.g., ₹500) to understand the reversal timing before scaling up. Never neglect your broker's stop-loss!

🚀 Crypto Options ROTO Scanner Pro - Free PineScript for Delta Exchange (ROTO = Range-bound Options Trading Optimizer)

Crypto Options Master: Bilingual Guide

Crypto Options Master Guide क्रिप्टो ऑप्शन्स मास्टर मार्गदर्शक

🎯 Core Idea: Time Zone Alignment for IST 🎯 मुख्य कल्पना: IST साठी टाइम झोन अलाइनमेंट

This script is designed to exploit crypto options volatility during high-probability early morning hours in India (**6:00 AM to 10:00 AM IST**). Since Pine Script's built-in `hour` function uses the chart's current time zone, **you must set your TradingView chart timezone to Asia/Calcutta** for the signals to trigger accurately on time.

हा स्क्रिप्ट भारतीय वेळेनुसार पहाटेच्या उच्च-संभाव्यता वेळेत (**सकाळ 6:00 AM ते 10:00 AM IST**) क्रिप्टो ऑप्शन्सच्या अस्थिरतेचा फायदा घेण्यासाठी तयार केला आहे. पाइन स्क्रिप्टमधील `hour` फंक्शन चार्टचा वर्तमान टाइम झोन वापरत असल्याने, सिग्नल्स योग्य वेळेत ट्रिगर होण्यासाठी **तुम्हाला तुमचा TradingView चार्ट टाइम झोन Asia/Calcutta वर सेट करावा लागेल**.

📚 Pine Script 101: Basics for Beginners 📚 पाइन स्क्रिप्ट १०१: नवशिक्यांसाठी मूलभूत गोष्टी

Pine Script is the programming language used to create custom indicators and strategies on TradingView. It's designed to be simple and powerful. Here are the core components you need to know:

For a detailed beginner's introduction to Pine Script, check out this guide:

Trading With Pine Script: Full Beginner's Guide

1. Version and Declaration

Every script starts with the **version** and a function call to declare its type:

  • `//@version=5`: Always specifies the Pine Script version (currently 5).
  • `indicator(...)`: Declares the code as an **Indicator** (visual signals only).
  • `strategy(...)`: Declares the code as a **Strategy** (can backtest and execute trades).

2. Inputs and Variables

Inputs allow users to customize the script without editing the code. Variables store data for calculations.

  • `input.int(...)`: Creates a customizable integer (whole number) setting, like our **Capital** or **Contracts**.
  • `risk_percent = input.float(...)`: Takes the user input and stores it in the `risk_percent` **variable**.
  • `volume_ma = ta.sma(volume, 20)`: Calculates the Simple Moving Average (SMA) of volume over 20 bars and stores it in the `volume_ma` variable.

3. Plotting and Alerts

These commands display the results on the chart:

  • `plot(...)`: Draws lines or shapes directly on the chart (e.g., the price line or a moving average).
  • `plotshape(...)`: Draws small icons (like circles or squares) above or below bars to highlight signals.
  • `alert(...)`: Creates a popup notification that can be set up in TradingView for real-time alerts.

पाइन स्क्रिप्ट ही TradingView वर सानुकूल इंडिकेटर (Indicators) आणि स्ट्रॅटेजी (Strategies) तयार करण्यासाठी वापरली जाणारी प्रोग्रामिंग भाषा आहे. ही साधी पण शक्तिशाली बनवलेली आहे. तुम्हाला आवश्यक असलेले मुख्य घटक खालीलप्रमाणे आहेत:

पाइन स्क्रिप्टच्या तपशीलवार परिचयासाठी, हा मार्गदर्शक तपासा:

पाइन स्क्रिप्टसह ट्रेडिंग: संपूर्ण नवशिक्या मार्गदर्शक

१. आवृत्ती (Version) आणि घोषणा

  • `//@version=5`: नेहमी पाइन स्क्रिप्टची आवृत्ती (सध्या 5) निर्दिष्ट करते.
  • `indicator(...)`: कोडला **इंडिकेटर** (केवळ व्हिज्युअल सिग्नल्स) म्हणून घोषित करते.
  • `strategy(...)`: कोडला **स्ट्रॅटेजी** (बॅकटेस्ट आणि ट्रेड कार्यान्वित करू शकते) म्हणून घोषित करते.

२. इनपुट्स (Inputs) आणि व्हेरिएबल्स (Variables)

इनपुट्समुळे वापरकर्त्यांना कोड संपादित न करता स्क्रिप्ट सानुकूलित करता येते. व्हेरिएबल्स गणनेसाठी डेटा संग्रहित करतात.

  • `input.int(...)`: **भांडवल** (Capital) किंवा **कॉन्ट्रॅक्ट्स** (Contracts) सारखी सानुकूलित पूर्णांक (whole number) सेटिंग तयार करते.
  • `risk_percent = input.float(...)`: वापरकर्त्याचे इनपुट घेते आणि ते `risk_percent` **व्हेरिएबलमध्ये** संग्रहित करते.
  • `volume_ma = ta.sma(volume, 20)`: 20 बार्सवरील व्हॉल्यूमची सिम्पल मूव्हिंग एव्हरेज (SMA) ची गणना करते आणि ती `volume_ma` व्हेरिएबलमध्ये संग्रहित करते.

३. प्लॉटिंग (Plotting) आणि अलर्ट्स

या कमांड्समुळे चार्टवर परिणाम दर्शविले जातात:

  • `plot(...)`: चार्टवर थेट रेषा किंवा आकृत्या काढते (उदा. किंमत रेषा किंवा मूव्हिंग एव्हरेज).
  • `plotshape(...)`: सिग्नल्स हायलाइट करण्यासाठी बार्सच्या वर किंवा खाली लहान चिन्ह (उदा. मंडळे किंवा चौकोन) काढते.
  • `alert(...)`: TradingView मध्ये रिअल-टाइम अलर्टसाठी सेट केले जाऊ शकणारे पॉपअप सूचना तयार करते.

💻 Code Breakdown: How the Strategy Works 💻 कोड ब्रेकडाउन: स्ट्रॅटेजी कशी कार्य करते

This script is an overlay indicator that identifies high-probability options setups during peak volatility hours (6 AM to 10 AM IST).

1. Risk Management and Inputs

  • **Toggles (`show_...`):** These inputs let you manually enable or disable each of the five sub-strategies (OI Fade, Volume Spike, etc.) from the indicator settings.
  • **Risk Controls:** The `capital`, `risk_percent`, and `contract_size` inputs define your maximum **Capital** (e.g., ₹50,000) and the **Risk %** per trade (e.g., 2%). The script uses these to calculate the actual position size, ensuring a disciplined approach to capital preservation.

2. Time and Volatility Logic

  • **Time Filter:** The core logic uses `current_hour` to define the trading window. `is_morning` (6 AM - 10 AM), `is_early_morning` (6 AM - 7 AM), and `is_late_morning` (9 AM - 10 AM) are flags that restrict signals to very specific, high-edge hours. **No signals are generated outside the 6 AM to 10 AM IST window.**
  • **Volume Spike:** It calculates the Simple Moving Average of Volume (`volume_ma`). A `volume_spike` is flagged when the current bar's volume is **2.5 times higher** than the average, indicating institutional participation.
  • **ATR/Volatility:** It uses the Average True Range (`atr_value`) to determine market conditions. `low_volatility` triggers premium-selling trades (Condors, Strangles), while high volatility supports buying momentum trades.

3. The Four Core Strategies

Each strategy is triggered by a combination of time, volatility, and momentum:

  • **1. OI Wall Fade (6-7 AM):** A directional trade (Credit Spread) triggered during the first hour (`is_early_morning`) when volatility is **low**. It aims to fade the initial morning movement.
  • **2. Volume Spike Momentum (6-10 AM):** A buy-side (Long Option) strategy triggered by a strong combination of high volume and upward price change. This targets quick, high-momentum breakouts.
  • **3. Gamma Flip Strangle (8-9 AM):** A neutral, premium-selling trade (Short Strangle) triggered in the middle of the window when volatility is **low**, anticipating consolidation.
  • **4. IV Crush Condor (9-10 AM):** A complex, neutral premium-selling trade (Iron Condor) triggered late when volatility is detected to be **compressing**. This targets the expected drop in Implied Volatility (IV) towards the expiry time.

हा स्क्रिप्ट उच्च अस्थिरता काळात (सकाळ 6 ते 10 IST) उच्च-संभाव्यता ऑप्शन्स सेटअप ओळखण्यासाठी बनवलेला आहे.

१. जोखीम व्यवस्थापन आणि इनपुट्स

  • **टॉगल्स (`show_...`):** हे इनपुट्स तुम्हाला पाच उप-स्ट्रॅटेजीपैकी (OI Fade, Volume Spike, इत्यादी) प्रत्येक स्ट्रॅटेजी व्यक्तिचलितपणे चालू किंवा बंद करण्याची परवानगी देतात.
  • **जोखीम नियंत्रण:** `capital`, `risk_percent`, आणि `contract_size` इनपुट्स तुमचे कमाल **भांडवल** (उदा. ₹50,000) आणि प्रति ट्रेड **जोखीम %** (उदा. 2%) परिभाषित करतात. भांडवल सुरक्षित ठेवण्यासाठी स्क्रिप्ट यानुसार वास्तविक पोझिशनचा आकार मोजते.

२. वेळ आणि अस्थिरता लॉजिक

  • **वेळ फिल्टर:** मुख्य लॉजिक ट्रेडिंग विंडो परिभाषित करण्यासाठी `current_hour` वापरते. `is_morning` (6 ते 10), `is_early_morning` (6 ते 7), आणि `is_late_morning` (9 ते 10) हे फ्लॅग सिग्नल्सला अत्यंत विशिष्ट, उच्च-लाभ वेळेपर्यंत मर्यादित करतात. **सकाळ 6 ते 10 IST या वेळेव्यतिरिक्त कोणतेही सिग्नल्स तयार होत नाहीत.**
  • **व्हॉल्यूम स्पाइक:** स्क्रिप्ट व्हॉल्यूमची सिम्पल मूव्हिंग एव्हरेज (`volume_ma`) मोजते. जेव्हा वर्तमान बारचा व्हॉल्यूम सरासरीपेक्षा **2.5 पट जास्त** असतो, तेव्हा `volume_spike` ध्वजांकित केला जातो, जो संस्थात्मक सहभाग दर्शवतो.
  • **ATR/अस्थिरता:** ते बाजार स्थिती निश्चित करण्यासाठी Average True Range (`atr_value`) वापरते. **कमी अस्थिरता** प्रीमियम-विक्री ट्रेड (Condors, Strangles) ट्रिगर करते, तर जास्त अस्थिरता खरेदी मोमेंटम ट्रेडना समर्थन देते.

३. चार मुख्य स्ट्रॅटेजीज

प्रत्येक स्ट्रॅटेजी वेळ, अस्थिरता आणि मोमेंटमच्या संयोजनाने ट्रिगर होते:

  • **१. OI Wall Fade (6-7 AM):** कमी अस्थिरता असताना पहिल्या तासात (`is_early_morning`) ट्रिगर होणारी दिशात्मक ट्रेड (क्रेडिट स्प्रेड). याचा उद्देश सकाळच्या सुरुवातीच्या हालचालीस 'फेड' करून प्रीमियम मिळवण्याचा आहे.
  • **२. Volume Spike Momentum (6-10 AM):** उच्च व्हॉल्यूम आणि वाढत्या किंमतीच्या मजबूत संयोजनामुळे ट्रिगर होणारी खरेदी-बाजूसंबंधी स्ट्रॅटेजी. हे जलद, उच्च-मोमेंटम ब्रेकआउट्सना लक्ष्य करते.
  • **३. Gamma Flip Strangle (8-9 AM):** कमी अस्थिरता असताना मध्यभागी ट्रिगर होणारी तटस्थ, प्रीमियम-विक्री ट्रेड (शॉर्ट स्ट्रॅंगल), जी एकत्रीकरण (consolidation) अपेक्षित ठेवते.
  • **४. IV Crush Condor (9-10 AM):** अस्थिरता **आकुंचन** पावत असल्याचे आढळल्यास वेळेच्या शेवटी ट्रिगर होणारी जटिल, तटस्थ प्रीमियम-विक्री ट्रेड (आयरन कॉन्डॉर). हे एक्स्पायरी जवळ Implied Volatility (IV) मध्ये होणाऱ्या अपेक्षित घसरणीला लक्ष्य करते.

📋 The Complete Pine Script Code 📋 संपूर्ण पाइन स्क्रिप्ट कोड

//@version=5
indicator("Crypto Daily Options Master [FREE]", overlay=true, max_labels_count=50)

// === STRATEGY TOGGLES (Input allows user to turn strategies on/off) ===
show_oi_fade = input.bool(true, "OI Wall Fade Strategy")
show_volume_spike = input.bool(true, "Volume Spike Strategy")
show_gamma_flip = input.bool(true, "Gamma Flip Strategy")
show_iv_crush = input.bool(true, "IV Crush Strategy")
show_correlation = input.bool(true, "BTC/ETH Correlation")

// === RISK MANAGEMENT (Inputs that define risk parameters) ===
capital = input.int(50000, "Capital (₹)", minval=10000, maxval=1000000)
risk_percent = input.float(2.0, "Risk % per Trade", minval=0.5, maxval=5.0)
contract_size = input.int(5, "Contracts per Trade", minval=1, maxval=20)

// === SIMPLE TIME DETECTION (Works if Chart Timezone is IST) ===
current_hour = hour
current_minute = minute
is_morning = current_hour >= 6 and current_hour < 10 // Defines the 6 AM to 10 AM window
is_early_morning = current_hour >= 6 and current_hour < 7
is_late_morning = current_hour >= 9 and current_hour < 10

// === CORE INDICATORS (FREE VERSION) ===
// Volume Analysis
volume_ma = ta.sma(volume, 20) // Calculate 20-period Simple Moving Average of Volume
volume_ratio = volume / volume_ma
volume_spike = volume_ratio > 2.5 // Check if current volume is 2.5x the average

// Volatility Analysis (Using Average True Range - ATR)
atr_period = 14
atr_value = ta.atr(atr_period)
atr_percent = atr_value / close * 100
low_volatility = atr_percent < 1.2
high_volatility = atr_percent > 2.0

// Price Momentum
price_change_5m = (close - close[5]) / close[5] * 100 // Percentage change over 5 bars
price_change_30m = (close - close[30]) / close[30] * 100
is_uptrend = ta.ema(close, 10) > ta.ema(close, 20) // 10 EMA above 20 EMA
is_downtrend = ta.ema(close, 10) < ta.ema(close, 20)

// === CALCULATE ATM STRIKE ===
// Finds the nearest strike price rounded to the nearest 100 (approximation)
current_atm_strike = math.round(close / 100) * 100

// === 1. OI WALL FADE STRATEGY (6-7 AM) ===
// Triggers if strategy is enabled, time is early morning, and volatility is low
if show_oi_fade and is_early_morning and low_volatility
    // Calculation for strike prices (5% Out-of-the-Money and a further hedge)
    call_strike = math.round(close * 1.05 / 100) * 100
    hedge_strike = call_strike + 200
    risk_per_trade = capital * risk_percent / 100
    position_size = math.min(contract_size, math.floor(risk_per_trade / 800))
    
    // Draw a label on the chart for the signal
    label.new(bar_index, high, 
          "🎯 OI WALL FADE\n" +
          "SELL " + str.tostring(call_strike) + " CE\n" +
          "BUY " + str.tostring(hedge_strike) + " CE\n" +
          "Credit: ~₹600-800\n" +
          "Size: " + str.tostring(position_size) + " lots\n" +
          "Risk: ₹" + str.tostring(risk_per_trade),
          color=color.rgb(200, 50, 50), /* Darker Red for visibility */
          style=label.style_label_down, 
          textcolor=color.white, 
          size=size.normal)
    
    // Send an alert if the signal occurs on the last bar
    if barstate.islast
        alert("OI WALL FADE: Sell " + str.tostring(call_strike) + "CE + Buy " + 
              str.tostring(hedge_strike) + "CE | Credit Spread", alert.freq_once_per_bar_close)

// === 2. VOLUME SPIKE MOMENTUM (6-10 AM) ===
if show_volume_spike and is_morning and volume_spike and price_change_5m > 0.15
    risk_per_trade = capital * risk_percent / 100
    position_size = math.min(contract_size, math.floor(risk_per_trade / 1200))
    
    label.new(bar_index, low, 
          "🚀 VOLUME SPIKE\n" +
          "BUY " + str.tostring(current_atm_strike) + " CE\n" +
          "Volume: " + str.tostring(volume_ratio, "#.##") + "x\n" +
          "Target: +80% | Stop: -40%\n" +
          "Size: " + str.tostring(position_size) + " lots",
          color=color.rgb(0, 150, 0), /* Darker Green for visibility */
          style=label.style_label_up, 
          textcolor=color.white, 
          size=size.normal)
    
    if barstate.islast
        alert("VOLUME SPIKE: BUY " + str.tostring(current_atm_strike) + "CE | Volume: " + 
              str.tostring(volume_ratio, "#.##") + "x", alert.freq_once_per_bar_close)

// === 3. GAMMA FLIP STRANGLE (8-9 AM) ===
if show_gamma_flip and current_hour >= 8 and current_hour < 9 and low_volatility
    call_strike = math.round(close * 1.02 / 100) * 100  // 2% OTM Call
    put_strike = math.round(close * 0.98 / 100) * 100   // 2% OTM Put
    
    risk_per_trade = capital * risk_percent / 100
    position_size = math.min(contract_size, math.floor(risk_per_trade / 600))
    
    label.new(bar_index, high, 
          "🔄 GAMMA FLIP\n" +
          "SELL " + str.tostring(call_strike) + " CE\n" +
          "SELL " + str.tostring(put_strike) + " PE\n" +
          "Credit: ₹900-1100\n" +
          "Target: 60% | Stop: 200%\n" +
          "Size: " + str.tostring(position_size) + " lots",
          color=color.rgb(200, 100, 0), /* Darker Orange for visibility */
          style=label.style_label_down, 
          textcolor=color.white, 
          size=size.normal)
    
    if barstate.islast
        alert("GAMMA FLIP: Sell Strangle " + str.tostring(call_strike) + "CE & " + 
              str.tostring(put_strike) + "PE", alert.freq_once_per_bar_close)

// === 4. IV CRUSH CONDOR (9-10 AM) ===
// Checks if volatility is contracting (ATR is shrinking)
iv_compression = ta.atr(14) < ta.atr(14)[1] and ta.atr(14)[1] < ta.atr(14)[2]
if show_iv_crush and current_hour >= 9 and current_hour < 10 and iv_compression
    // Defines the strikes for a short iron condor setup
    short_call = math.round(close * 1.03 / 100) * 100
    long_call = short_call + 200
    short_put = math.round(close * 0.97 / 100) * 100
    long_put = short_put - 200
    
    risk_per_trade = capital * risk_percent / 100
    position_size = math.min(contract_size, math.floor(risk_per_trade / 400))
    
    label.new(bar_index, high, 
          "📉 IV CRUSH CONDOR\n" +
          "SELL " + str.tostring(short_call) + "C/" + str.tostring(short_put) + "P\n" +
          "BUY " + str.tostring(long_call) + "C/" + str.tostring(long_put) + "P\n" +
          "Credit: ₹1400-1800\n" +
          "Size: " + str.tostring(position_size) + " lots",
          color=color.rgb(100, 0, 100), /* Darker Purple for visibility */
          style=label.style_label_down, 
          textcolor=color.white, 
          size=size.normal)
    
    if barstate.islast
        alert("IV CRUSH: Iron Condor " + str.tostring(short_call) + "C-" + 
              str.tostring(long_call) + "C & " + str.tostring(short_put) + "P-" + 
              str.tostring(long_put) + "P", alert.freq_once_per_bar_close)

// === 5. SIMPLE CORRELATION (6-10 AM) ===
if show_correlation and is_morning
    btc_trend = ta.ema(close, 10) > ta.ema(close, 30)
    momentum = ta.rsi(close, 14) > 55
    
    if btc_trend and momentum and price_change_30m > 0.3
        risk_per_trade = capital * risk_percent / 100
        position_size = math.min(contract_size, math.floor(risk_per_trade / 900))
        
        label.new(bar_index, low, 
              "📊 TREND MOMENTUM\n" +
              "BUY " + str.tostring(current_atm_strike) + " CE\n" +
              "RSI: " + str.tostring(ta.rsi(close, 14), "#.##") + "\n" +
              "Trend: Strong Up\n" +
              "Size: " + str.tostring(position_size) + " lots",
              color=color.rgb(0, 50, 150), /* Darker Blue for visibility */
              style=label.style_label_up, 
              textcolor=color.white, 
              size=size.normal)
        
        if barstate.islast
            alert("TREND MOMENTUM: BUY " + str.tostring(current_atm_strike) + "CE | RSI: " + 
                  str.tostring(ta.rsi(close, 14), "#.##"), alert.freq_once_per_bar_close)

// === RISK MANAGEMENT DISPLAY (Table) ===
// Creates a table in the top right corner of the chart
var table risk_table = table.new(position.top_right, 2, 10, 
      bgcolor=color.rgb(230, 230, 230), /* Very light gray background */
      border_width=1, 
      border_color=color.black)

if barstate.islast
    total_risk = capital * risk_percent / 100
    daily_risk = total_risk * 2
    margin_required = contract_size * 15000  // Approximate margin
    
    // Populates the table with risk metrics (Text color is dark black by default)
    table.cell(risk_table, 0, 0, "💰 RISK MANAGER", 
                bgcolor=color.rgb(255, 223, 0), text_color=color.black)
    table.cell(risk_table, 0, 1, "Capital: ₹" + str.tostring(capital), text_color=color.black)
    table.cell(risk_table, 0, 2, "Risk/Trade: ₹" + str.tostring(total_risk), text_color=color.black)
    table.cell(risk_table, 0, 3, "Daily Risk: ₹" + str.tostring(daily_risk), text_color=color.black)
    table.cell(risk_table, 0, 4, "Contracts: " + str.tostring(contract_size), text_color=color.black)
    table.cell(risk_table, 0, 5, "Margin: ₹" + str.tostring(margin_required), text_color=color.black)
    table.cell(risk_table, 0, 6, "Time: " + str.tostring(current_hour) + ":" + 
                str.tostring(current_minute), text_color=color.black)
    table.cell(risk_table, 0, 7, "Volatility: " + str.tostring(atr_percent, "#.##") + "%", text_color=color.black)
    table.cell(risk_table, 0, 8, "Volume: " + str.tostring(volume_ratio, "#.##") + "x", text_color=color.black)
    table.cell(risk_table, 0, 9, "Trades Today: 3-4", text_color=color.black)

// === VISUAL MARKERS & INFO LABELS ===
// Plotting shapes to visually confirm where the logic triggers
plotshape(show_oi_fade and is_early_morning and low_volatility, style=shape.triangleup, location=location.abovebar, color=color.red, size=size.small, title="OI Fade Signal")
plotshape(show_volume_spike and volume_spike and price_change_5m > 0.15, style=shape.circle, location=location.belowbar, color=color.green, size=size.small, title="Volume Spike")
plotshape(show_gamma_flip and current_hour >= 8 and current_hour < 9 and low_volatility, style=shape.diamond, location=location.abovebar, color=color.orange, size=size.small, title="Gamma Flip")
plotshape(show_iv_crush and current_hour >= 9 and current_hour < 10 and iv_compression, style=shape.square, location=location.abovebar, color=color.purple, size=size.small, title="IV Crush")
plot(close, "BTC Price", color=color.blue, linewidth=1)
plot(current_atm_strike, "ATM Strike", color=color.gray, linewidth=1, style=plot.style_circles)

if barstate.islast
    label.new(bar_index, low * 0.985,
          "⏰ NOTE: Set TradingView Timezone to Asia/Calcutta (IST)",
          color=color.rgb(200, 200, 200), /* Light Gray background for note */
          style=label.style_label_center,
          textcolor=color.black, /* Black text */
          size=size.normal,
          yloc=yloc.belowbar)
                

🛠️ Setup and Start Guide 🛠️ सेटअप आणि सुरुवात मार्गदर्शक

Step 1: Timezone Correction (Mandatory)

  1. Open your **TradingView chart** (e.g., BINANCE:BTCUSDT).
  2. Click on the **Settings** (gear icon) on the bottom bar.
  3. Navigate to **Chart Settings**.
  4. Find the **Timezone** option.
  5. Select **Asia/Calcutta**. This ensures the script's `6-10 AM` logic aligns with IST.

Step 2: Install the Pine Script

  1. Open the **Pine Editor** (you can press F4).
  2. Delete any existing code and paste the complete code block above.
  3. Click **"Add to Chart"**.
  4. Once loaded, go to the indicator's settings and customize your **Capital** and **Risk %** inputs under "Risk Management."

पायरी १: टाइम झोन दुरुस्ती (अनिवार्य)

  1. तुमचा **TradingView चार्ट** उघडा (उदा. BINANCE:BTCUSDT).
  2. तळाच्या बारवरील **सेटिंग्ज** (गियर आयकॉन) वर क्लिक करा.
  3. **चार्ट सेटिंग्ज** (Chart Settings) मध्ये जा.
  4. **वेळ क्षेत्र** (Timezone) पर्याय शोधा.
  5. **Asia/Calcutta** निवडा. यामुळे स्क्रिप्टचे `सकाळ 6-10` लॉजिक IST शी जुळेल.

पायरी २: पाइन स्क्रिप्ट इन्स्टॉल करा

  1. **पाइन एडिटर** (Pine Editor) उघडा (तुम्ही F4 दाबू शकता).
  2. कोणताही जुना कोड हटवा आणि वरील संपूर्ण कोड ब्लॉक पेस्ट करा.
  3. **"Add to Chart"** वर क्लिक करा.
  4. लोड झाल्यावर, इंडिकेटरच्या सेटिंग्जमध्ये जा आणि "Risk Management" अंतर्गत तुमचे **Capital** (भांडवल) आणि **Risk %** इनपुट सानुकूलित करा.

Daily Trading Schedule (IST) दैनंदिन ट्रेडिंग वेळापत्रक (IST)

  • **6:00 AM - 7:00 AM:** OI Wall Fade (Credit Spread)
  • **8:00 AM - 9:00 AM:** Gamma Flip (Short Strangle)
  • **9:00 AM - 10:00 AM:** IV Crush Condor (Iron Condor)
  • **6:00 AM - 10:00 AM (Ongoing):** Volume Spike & Trend Momentum (Long Options)

Roto Hedge Momentum v3.0 Trading Guide (Trade with Tradingview a simple indicator with BUY/ SELL signal)

Roto Hedge Momentum v3.0 Trading Guide

Roto Hedge Momentum v3.0: मराठी ट्रेडरचे संपूर्ण मार्गदर्शक 🇮🇳

🎯 ही Strategy काय करते? (Simple Marathi/English Mix)

तुमचा एक Smart Assistant जो:

  • Market trends automatically बघतो २४/७
  • बरोबर वेळेला Buy/Sell सांगतो
  • तुमचे पैसे Automatically संरक्षित करतो
  • Market नुसार Trade Size Adjust करतो

Indian Traders साठी Perfect:

  • Currency Pairs: USD/INR, EUR/INR, GBP/INR
  • Commodities: Gold (XAU/INR), Silver (XAG/INR)
  • Indices: Nifty, Bank Nifty (futures/options)
  • 1-तास किंवा 4-तास Timeframes वर सर्वोत्तम.

काय Expect करावे:

  • दर 100 Trades मधून 38 Profitable असतील
  • जिंकलेले Trades हरलेल्यापेक्षा जास्त Profit देतात
  • Maximum Loss तुमच्या Account च्या ७% पेक्षा कमी
  • जेव्हा Market Clear Trend मध्ये असेल तेव्हा Best काम करते

📊 Basic Signals समजून घ्या (खूप Easy)

दोन Lines (EMA) - "Trend Lines"

  • Fast EMA (९): लवकर React करते - Sports Car सारखी
  • Slow EMA (२१): हळू React करते - Truck सारखी

Buy आणि Sell Signals

Signal काय होतं काय करावं
BUY Fast Line Slow Line च्या वर येते BUY Trade लावावी
SELL Fast Line Slow Line च्या खाली येते SELL Trade लावावी

Extra Safety Check (ADX Filter)

ADX = "Trend Strength Meter"

  • ०-२५: कमजोर Trend = TRADING नाही (Parking Lot सारखं)
  • २५-५०: Strong Trend = TRADING साठी छान (Highway सारखं)
  • ५०+: खूप Strong Trend = सावधगिरी (Mountain Road सारखं)

ही Strategy फक्त ADX २५ पेक्षा जास्त असेल तेव्हाच Trade करते

💰 Money Protection System

The १% Rule

एका Trade वर तुमच्या Capital च्या १% पेक्षा जास्त Risk करू नका

  • ₹१,००,००० Account → Max ₹१,००० Risk Per Trade
  • ₹५,००,००० Account → Max ₹५,००० Risk Per Trade

Stop Loss (तुमची "Safety Net")

  • काय करतो: Loss Control करण्यासाठी Automatically Trade बंद करतो
  • कसे काम करतो: Entry पासून २x Average Daily Movement (ATR) अंतरावर Stop सेट करतो
  • *Example:* Buy at ₹१००, Stop at ₹९८ = ₹२ Risk

Take Profit (तुमचा "Profit Lock")

  • काय करतो: Target गाठल्यावर Automatically Winning Trade बंद करतो
  • कसे काम करतो: Entry पासून ३x Average Daily Movement (ATR) अंतरावर Target सेट करतो
  • *Example:* Buy at ₹१००, Target at ₹१०६ = ₹६ Profit

Extra Protection Features

  • Breakeven Stop: Profit आल्यावर Stop ला Entry वर आणतो
  • Trailing Stop: जसजसा Trade पुढे जातो, तसतसा Profit Lock करतो
  • Hedging: Market मध्ये जास्त अस्थिरता (Volatility) असल्यास, आपोआप लहान Size ने Trade करतो.

📈 Charts कसे वाचायचे - Visual Guide

तुमच्या Screen वर काय दिसेल

  • 🟢 Teal Line = Fast EMA (९)
  • 🟠 Orange Line = Slow EMA (२१)

Background Colors:

  • 🟩 Green Background = BUY Signal Bar
  • 🟥 Red Background = SELL Signal Bar
  • ⬜ No Color = No Signal

Information Box (Top Right):

💠 Roto Hedge v3.0
Equity: ₹१,०५,०००     ← तुमचं Account Balance
Risk: १.०%            ← प्रति Trade Risk
Market Strength: GOOD ← ADX Reading
Next Trade: ०.०८ Lots ← किती Trade करायचं
Protection: ×०.५      ← Risk Reduction Active
Total Profit: ₹५,००० ← एकूण Profit

Trade Labels:

  • 🟢 "BUY - Lot: ०.०८ - Hedge×०.५" Price Bars खाली
  • 🔴 "SELL - Lot: ०.०७ - Hedge×०.६" Price Bars वर

🚀 सुरूवात कशी करावी - Step by Step

Step १: TradingView वर Strategy Add करा

  1. **TradingView.com** वर जा
  2. Any Chart उघडा (USD/INR Try करा)
  3. तळी "Pine Editor" वर Click करा
  4. Strategy Code Paste करा (शेवटी दिलेला आहे)
  5. "Add to Chart" वर Click करा

Step २: तुमची Settings Set करा

  • Risk/Trade: ०.५% (Conservative Start साठी)
  • ADX Filter: ON (२५ ला Set करा)
  • Take Profit: ON (३.० ला Set करा)
  • Chart Timeframe: 1H किंवा 4H

Step ३: DEMO Account वर Practice करा

Real Money पूर्वी:

  • Any Broker कडून Demo Account उघडा
  • ₹१,००,००० Virtual Money ने Start करा
  • १०-२० Signals Follow करून शिका
  • Stops आणि Targets Set करण्याचा Practice करा

Step ४: पहिला Signal कसा वाचायचा

जेव्हा हे दिसेल:

  • Fast Teal Line Orange Line च्या वर येईल
  • Chart Bar Green होईल
  • Label वर "BUY" आणि Lot Size दिसेल
  • Information Box वर "Market Strength: GOOD" दिसेल

तुम्ही हे करा:

  • तुमच्या Trading Platform वर जा
  • Current Price वर BUY Order लावा
  • Red Dashed Line जिथे आहे तिथे Stop Loss लावा
  • Blue Dashed Line जिथे आहे तिथे Take Profit लावा
  • Label मध्ये दिसणारा Lot Size वापरा

📅 Daily Trading Routine (५ Minutes)

सकाळी Check:

  • Chart उघडा - Colored Backgrounds बघा
  • Information Box बघून Account Status तपासा
  • सध्या कोणतेही Trades Open आहेत का ते बघा

जेव्हा Signal येईल:

  • Confirm करा: Lines Cross झाल्या आहेत, Background Colored आहे
  • Check करा: Information Box वर "Market Strength: GOOD" आहे
  • Execute करा: तुमच्या Broker कडून Trade लावा
  • Set करा: Chart वर दिसणारे Stop Loss आणि Take Profit वापरा

Trade Management:

  • ✅ करा: Strategy ला Automatically Exits Handle करू द्या
  • ✅ करा: तुम्ही Test केलेल्या System वर Trust ठेवा
  • ❌ करू नका: घाबरून Trades लवकर बंद करू नका
  • ❌ करू नका: Loss मध्ये असलेल्या Trades मध्ये अजून पैसे टाकू नका (Averaging Down).

🛡️ Risk Management - तुमचे Protection Rules

Golden Rules:

  • एका Trade वर १% पेक्षा जास्त Risk करू नका
  • नेहमी Stop Losses वापरा
  • पहिल्यांदा Demo वर Practice करा
  • फक्त Calm Market Hours मध्ये Trade करा

Avoid करायचे Market Hours:

  • ❌ Major Economic News चे वेळ
  • ❌ Market Opening/Closing Times
  • ❌ Overnight Sessions (जर तुम्ही Day Trader असाल)

Position Sizing Examples:

Account Size ०.५% Risk १% Risk २% Risk
₹१,००,००० ₹५०० प्रति Trade ₹१,००० प्रति Trade ₹२,००० प्रति Trade
₹५,००,००० ₹२,५०० प्रति Trade ₹५,००० प्रति Trade ₹१०,००० प्रति Trade
₹१०,००,००० ₹५,००० प्रति Trade ₹१०,००० प्रति Trade ₹२०,००० प्रति Trade

Comfortable होईपर्यंत ०.५% ने Start करा

📊 तुमचे Results कसे समजून घ्यायचे

चांगले Results असे दिसतात:

  • ↗️ Total Profit काळानुसार वाढत आहे
  • ↘️ Max Drawdown १०% च्या खाली आहे
  • ⚖️ Profit Factor १.० पेक्षा जास्त आहे (जिंकल्यात जास्त, हरल्यात कमी)
  • 🎯 Consistent लहान Losses, Occasional मोठे Wins

Normal Trading Results:

  • ✅ ४-६ लगेच हरलेले Trades = NORMAL
  • ✅ ३८% Win Rate = GOOD (जर Winners मोठे असतील)
  • ✅ १०-२०% Drawdown = MANAGEABLE
  • ✅ दर आठवड्याला १-२ Trades = HEALTHY

जर Profitable नसाल:

  • तुम्ही Signals Exactly Follow करत आहात का ते तपासा
  • Proper Stop Losses वापरत आहात का ते Verify करा
  • Recommended Markets मध्ये Trade करत आहात का ते बघा
  • Risk ०.५% पर्यंत कमी करण्याचा विचार करा

🔧 Common Issues सोडवणे

"Signals दिसत नाहीत?"

  • ADX Filter Setting तपासा (२० पर्यंत कमी करून बघा)
  • 1H किंवा 4H Timeframe वर आहात ना ते तपासा
  • Strategy Properly Chart वर Added आहे का ते Verify करा

"Trades हरतच राहतात?"

  • हे Normal आहे - सर्व Strategies मध्ये हरलेले Period असतात
  • तुमचा Risk खूप जास्त नाही ना ते तपासा
  • News Events दरम्यान Trade करत नाही ना ते बघा

"Lot Sizes बद्दल Confusion आहे?"

  • Demo वर ०.०१ Lots ने Start करा
  • Labels मध्ये दिसणारे Sizes वापरा
  • लक्षात ठेवा: लहान Lots = लहान Risk

"Strategy काम करत नाही?"

  • Performance Judge करण्यासाठी किमान २० Trades द्या
  • काही Losses नंतर Settings बदलू नका
  • लक्षात ठेवा: Trading मध्ये Patience लागते

🎓 Beginner Success Checklist

Live Trading पूर्वी:

  • [ ] Demo वर २०+ Trades चा Practice करा
  • [ ] Buy/Sell Signals समजून घ्या
  • [ ] Stop Losses कसे Set करायचे ते शिका
  • [ ] तुमच्या Broker Platform सोबत Comfortable व्हा
  • [ ] Risk Management Plan तयार करा

पहिल्या महिन्याची Goals:

  • [ ] प्रत्येक Signal Follow करा (Skip करू नका)
  • [ ] Trading Journal ठेवा
  • [ ] ०.५-१% Risk ला Stick राहा
  • [ ] Losses दरम्यान Strategy सोडू नका
  • [ ] Weekly Performance Review करा

टाळायचे Common Beginner Mistakes:

Mistake का वाईट आहे Better Approach
Stops Skip करणे एक वाईट Trade सगळं उडवू शकते नेहमी Stops वापरा
खूप मोठे Trading Emotional Stress, मोठे Losses १% Rule ला Stick राहा
Losses Chase करणे बहुतेक वेळा वाईटच होते Losses Normal मानून घ्या
Signals Ignore करणे System Follow करत नाही तुमच्या Testing वर Trust ठेवा

📞 मदत कशी मिळवायची

जेव्हा अडचण येते:

  • हे Guide प्रथम तपासा - बहुतेक उत्तरे इथेच आहेत
  • Demo वर अजून Practice करा - Experience बहुतेक Issues सोडवते
  • TradingView Comments - इतर Users मदत करू शकतात
  • Journal ठेवा - काय काम करतंय आणि काय नाही ते Track करा

लक्षात ठेवा:

  • प्रत्येक Professional Trader एकदा Beginner होता
  • हरलेले Trades NORMAL आणि EXPECTED आहेत
  • Consistency प्रत्येक वेळी बरोबर असण्यापेक्षा Important आहे
  • Risk Management तुमचा Best Friend आहे

🚀 तुमची Quick Start Plan

  • **आठवडा १:** Demo Trading + Signals शिकणे
  • **आठवडा २:** Demo Trading + Risk Management Practice
  • **आठवडा ३:** छोटा Live Account (₹१०,०००-५०,०००) ०.५% Risk सोबत
  • **आठवडा ४:** Review, Adjust, Learning चालू ठेवा

तुम्हाला हे जमेल! हळूवार सुरूवात करा, Patient राहा आणि लक्षात ठेवा की Successful Trading ही Marathon आहे, Sprint नाही. 📈✨

Happy Trading! लक्षात ठेवा: Goal प्रत्येक वेळी बरोबर असणे नाही, तर Winning Trades वर जास्त आणि Losing Trades वर कमी पैसे कमवणे आहे. 🎯

📈 TradingView Strategy Code (TradingView Strategy कोड)

हा कोड TradingView च्या Pine Editor मध्ये पेस्ट करा. याच्या स्टेप्स वरील Step 1 मध्ये दिल्या आहेत.

//@version=5
strategy("Roto Hedge Momentum v3.0 [Alerts Fixed]", overlay=true,
default_qty_type=strategy.fixed, default_qty_value=0.01,
initial_capital=200, currency=currency.USD,
commission_type=strategy.commission.percent, commission_value=0.1,
pyramiding=0)
// === INPUTS ===
risk_per_trade = input.float(0.01, "Risk/Trade %", minval=0.005, maxval=0.05)
use_adx_filter = input.bool(true, "Use ADX Filter", inline="f")
adx_threshold = input.float(25.0, "ADX >", minval=15, maxval=40, inline="f")
use_tp = input.bool(true, "Use Take Profit (3x ATR)", inline="tp")
tp_mult = input.float(3.0, "TP Multiplier", minval=1.5, maxval=5.0, inline="tp")
// === CORE ===
ema_fast = ta.ema(close, 9)
ema_slow = ta.ema(close, 21)
atr = ta.atr(14)
// ADX via DMI
[diplus, diminus, adx] = ta.dmi(14, 14)
signal = ta.crossover(ema_fast, ema_slow) ? 1 : ta.crossunder(ema_fast, ema_slow) ? -1 : 0
// === SIZING (NA-Proof) ===
sl_distance = atr * 2
pip_value_per_lot = syminfo.pointvalue
risk_pips = sl_distance / syminfo.mintick
risk_per_lot = risk_pips * pip_value_per_lot
base_risk_usd = strategy.equity * risk_per_trade
lot_size = math.max(0.01, base_risk_usd / risk_per_lot)
lot_size := math.round(lot_size * 100) / 100
// Safe vol ratio
sma_tr = ta.sma(ta.tr, 20)
hedge_multiplier_base = ta.tr / nz(sma_tr, 1.0)
// Explicit if-else for hedge clamp
hedge_multiplier = 0.5  // Default
if not na(hedge_multiplier_base)
hedge_multiplier := math.max(0.3, math.min(0.7, hedge_multiplier_base))
net_lot_size = lot_size * (1 - hedge_multiplier)
net_lot_size := math.round(net_lot_size * 100) / 100
// Final NA safeguard
net_lot_size := na(net_lot_size) ? math.max(0.01, lot_size * 0.5) : net_lot_size
// === CONDITIONS ===
long_condition = signal == 1 and (not use_adx_filter or adx > adx_threshold) and strategy.position_size == 0
short_condition = signal == -1 and (not use_adx_filter or adx > adx_threshold) and strategy.position_size == 0
// === VARS ===
var float entry_price = na
var float sl_level = na
var float tp_level = na
// === ENTRIES ===
if (long_condition)
strategy.entry("Net Long", strategy.long, qty=net_lot_size)
entry_price := close
sl_level := entry_price - sl_distance
tp_level := use_tp ? entry_price + (atr * tp_mult) : na
// Fixed Line 118: Dynamic alert
alert("🟢 Roto Hedge LONG: BUY " + syminfo.ticker + " @ " + str.tostring(close, "#.#####") + " | Net Lot: " + str.tostring(net_lot_size, "#.##") + " | Hedge: ×" + str.tostring(hedge_multiplier, "#.#") + " | Risk: " + str.tostring(risk_per_trade * 100, "#.#") + "% | SL: " + str.tostring(sl_level, "#.#####"), alert.freq_once_per_bar)
if (short_condition)
strategy.entry("Net Short", strategy.short, qty=net_lot_size)
entry_price := close
sl_level := entry_price + sl_distance
tp_level := use_tp ? entry_price - (atr * tp_mult) : na
// Dynamic alert for short
alert("🔴 Roto Hedge SHORT: SELL " + syminfo.ticker + " @ " + str.tostring(close, "#.#####") + " | Net Lot: " + str.tostring(net_lot_size, "#.##") + " | Hedge: ×" + str.tostring(hedge_multiplier, "#.#") + " | Risk: " + str.tostring(risk_per_trade * 100, "#.#") + "% | SL: " + str.tostring(sl_level, "#.#####"), alert.freq_once_per_bar)
// === EXITS ===
trail_distance_ticks = math.round((atr * 1.5) / syminfo.mintick)
be_buffer = atr * 0.5
tp_param = use_tp ? tp_level : na
if (strategy.position_size > 0)
be_level = entry_price + be_buffer
if (close > entry_price + atr)
strategy.exit("BE/Trail/TP Long", "Net Long", stop=be_level, limit=tp_param, trail_price=close, trail_offset=trail_distance_ticks)
else
strategy.exit("SL/TP Long", "Net Long", stop=sl_level, limit=tp_param)
if (strategy.position_size < 0)
be_level = entry_price - be_buffer
if (close < entry_price - atr)
strategy.exit("BE/Trail/TP Short", "Net Short", stop=be_level, limit=tp_param, trail_price=close, trail_offset=trail_distance_ticks)
else
strategy.exit("SL/TP Short", "Net Short", stop=sl_level, limit=tp_param)
// === REVERSALS ===
if (signal == -1 and strategy.position_size > 0)
strategy.close_all(comment="↩ Reverse to SHORT")
alert("⚠️ Roto Hedge: REVERSE to SHORT - Closed Long @ " + str.tostring(close, "#.#####") + " | P/L: $" + str.tostring(strategy.closedtrades.profit(strategy.closedtrades - 1), "#.##"), alert.freq_once_per_bar)
if (signal == 1 and strategy.position_size < 0)
strategy.close_all(comment="↩ Reverse to LONG")
alert("⚠️ Roto Hedge: REVERSE to LONG - Closed Short @ " + str.tostring(close, "#.#####") + " | P/L: $" + str.tostring(strategy.closedtrades.profit(strategy.closedtrades - 1), "#.##"), alert.freq_once_per_bar)
// === VISUALS ===
plot(ema_fast, color=color.new(color.teal, 0), title="EMA 9", linewidth=2)
plot(ema_slow, color=color.new(color.orange, 0), title="EMA 21", linewidth=2)
plot(strategy.position_size != 0 ? sl_level : na, color=strategy.position_size > 0 ? color.new(color.green, 0) : color.new(color.red, 0), style=plot.style_linebr, title="Stop Loss", linewidth=2)
plot(use_tp and strategy.position_size != 0 ? tp_level : na, color=color.new(color.blue, 0), style=plot.style_linebr, title="Take Profit", linewidth=2)
bgcolor(long_condition ? color.new(color.green, 90) : short_condition ? color.new(color.red, 90) : na)
// === LABELS ===
if (long_condition)
label.new(bar_index, low - atr, text="🟢 BUY\nLot: " + str.tostring(net_lot_size, "#.##") + "\nHedge×" + str.tostring(hedge_multiplier, "#.#"), style=label.style_label_up, color=color.new(color.green, 10), textcolor=color.white, size=size.small)
if (short_condition)
label.new(bar_index, high + atr, text="🔴 SELL\nLot: " + str.tostring(net_lot_size, "#.##") + "\nHedge×" + str.tostring(hedge_multiplier, "#.#"), style=label.style_label_down, color=color.new(color.red, 10), textcolor=color.white, size=size.small)
// === INFO PANEL ===
var table infoPanel = table.new(position.top_right, 1, 9, border_width=2, frame_color=color.new(color.silver, 60))
if barstate.islast
table.cell(infoPanel, 0, 0, "💠 Roto Hedge v3.0", text_color=color.white, bgcolor=color.new(color.blue, 40))
table.cell(infoPanel, 0, 1, "Equity: $" + str.tostring(strategy.equity, "#.##"), text_color=strategy.equity >= 200 ? color.lime : color.orange)
table.cell(infoPanel, 0, 2, "Risk: " + str.tostring(risk_per_trade * 100, "#.#") + "%", text_color=color.yellow)
table.cell(infoPanel, 0, 3, "ADX: " + str.tostring(adx, "#.#") + (use_adx_filter ? " (ON)" : " (OFF)"), text_color=color.yellow)
table.cell(infoPanel, 0, 4, "ATR: " + str.tostring(atr, "#.####"), text_color=color.yellow)
table.cell(infoPanel, 0, 5, "Lot: " + str.tostring(net_lot_size, "#.##"), text_color=color.green)
table.cell(infoPanel, 0, 6, "Hedge ×" + str.tostring(hedge_multiplier, "#.#"), text_color=color.fuchsia)
table.cell(infoPanel, 0, 7, "TP: " + (use_tp ? "ON (" + str.tostring(tp_mult, "#.#") + "x)" : "OFF"), text_color=color.blue)
table.cell(infoPanel, 0, 8, "P/L: $" + str.tostring(strategy.netprofit, "#.##"), text_color=strategy.netprofit > 0 ? color.lime : color.red)
                        

Note: The Pine Script uses strategy.fixed for lot size default, but calculates the real lot size based on your equity and risk setting.

Powered by follow.it