OPEN-SOURCE SCRIPT

Volume Spike & RSI Scalping (Session Restricted)

//version=6
strategy("Volume Spike & RSI Scalping (Session Restricted)", overlay=true)

// Inputs
rsi_length = input(14, title="RSI Length")
overSold = input(30, title="RSI Oversold Level")
overBought = input(70, title="RSI Overbought Level")
volume_threshold = input(1.5, title="Volume Spike Multiplier (e.g., 1.5x avg volume)")
risk_reward_ratio = input(2.0, title="Risk-Reward Ratio (1:X)")
atr_length = input(14, title="ATR Length")
session_start_london = input.time(timestamp("0000-01-01 08:00 +0000"), title="London Session Start (UTC)")
session_end_london = input.time(timestamp("0000-01-01 16:00 +0000"), title="London Session End (UTC)")
session_start_ny = input.time(timestamp("0000-01-01 13:00 +0000"), title="New York Session Start (UTC)")
session_end_ny = input.time(timestamp("0000-01-01 21:00 +0000"), title="New York Session End (UTC)")

// Helper Functions
is_session = (time >= session_start_london and time <= session_end_london) or (time >= session_start_ny and time <= session_end_ny)

// RSI Calculation
vrsi = ta.rsi(close, rsi_length)

// Volume Spike Detection
avg_volume = ta.sma(volume, 20)
volume_spike = volume > avg_volume * volume_threshold

// Entry Signals Based on RSI and Volume
long_condition = is_session and volume_spike and vrsi < overSold and close > open // Bullish price action
short_condition = is_session and volume_spike and vrsi > overBought and close < open // Bearish price action

// Execute Trades
if (long_condition)
stop_loss = low - ta.atr(atr_length)
take_profit = close + (close - stop_loss) * risk_reward_ratio
strategy.entry("Buy", strategy.long, comment="Buy Signal")
strategy.exit("Take Profit/Stop Loss", "Buy", stop=stop_loss, limit=take_profit)

if (short_condition)
stop_loss = high + ta.atr(atr_length)
take_profit = close - (stop_loss - close) * risk_reward_ratio
strategy.entry("Sell", strategy.short, comment="Sell Signal")
strategy.exit("Take Profit/Stop Loss", "Sell", stop=stop_loss, limit=take_profit)

// Background Highlighting for Signals
bgcolor(long_condition ? color.new(color.green, 85) : na, title="Long Signal Background")
bgcolor(short_condition ? color.new(color.red, 85) : na, title="Short Signal Background")
Bands and ChannelsBill Williams IndicatorsBreadth Indicators

סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יוכלו להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אבל השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

רוצה להשתמש בסקריפ זה בגרף?

כתב ויתור