Free Pine Script Resources

Download free Pine Script templates, indicators, and code snippets for TradingView. Learn by example with production-ready code.

📊 Free Indicator Templates

Indicator Template

Multi-Timeframe RSI Indicator

Enhanced RSI indicator showing multiple timeframes simultaneously. Includes overbought/oversold levels, divergence detection, and customizable alerts.

//@version=5 indicator("Multi-Timeframe RSI", overlay=false) // Inputs rsiLength = input.int(14, "RSI Length", minval=1) overbought = input.int(70, "Overbought", minval=50, maxval=100) oversold = input.int(30, "Oversold", minval=0, maxval=50) htf1 = input.timeframe("60", "Higher Timeframe 1") htf2 = input.timeframe("240", "Higher Timeframe 2") // Calculations rsiCurrent = ta.rsi(close, rsiLength) rsiHTF1 = request.security(syminfo.tickerid, htf1, ta.rsi(close, rsiLength)) rsiHTF2 = request.security(syminfo.tickerid, htf2, ta.rsi(close, rsiLength)) // Plots plot(rsiCurrent, "Current TF RSI", color.blue, 2) plot(rsiHTF1, "HTF1 RSI", color.orange, 1) plot(rsiHTF2, "HTF2 RSI", color.red, 1) hline(overbought, "Overbought", color.red, hline.style_dotted) hline(oversold, "Oversold", color.green, hline.style_dotted) hline(50, "Midline", color.gray, hline.style_solid) // Alerts alertcondition(ta.crossover(rsiCurrent, overbought), "RSI Overbought", "RSI crossed above {{plot_0}}") alertcondition(ta.crossunder(rsiCurrent, oversold), "RSI Oversold", "RSI crossed below {{plot_0}}")
Features:
  • Compare 3 timeframes simultaneously
  • Customizable overbought/oversold levels
  • Built-in alert conditions
  • Clean, commented code
Indicator Template

Volume-Weighted Moving Average System

Advanced moving average system using volume weighting. Includes trend detection, dynamic coloring, and cross alerts.

//@version=5 indicator("VWMA System", overlay=true) // Inputs fastLength = input.int(9, "Fast VWMA", minval=1) slowLength = input.int(21, "Slow VWMA", minval=1) showCrosses = input.bool(true, "Show Crossover Signals") // Calculate VWMAs fastVWMA = ta.vwma(close, fastLength) slowVWMA = ta.vwma(close, slowLength) // Trend detection bullish = fastVWMA > slowVWMA bearish = fastVWMA < slowVWMA // Crossover detection bullCross = ta.crossover(fastVWMA, slowVWMA) bearCross = ta.crossunder(fastVWMA, slowVWMA) // Plot VWMAs with dynamic colors plot(fastVWMA, "Fast VWMA", bullish ? color.green : color.red, 2) plot(slowVWMA, "Slow VWMA", color.orange, 2) // Plot crossover signals plotshape(showCrosses and bullCross, "Buy Signal", shape.triangleup, location.belowbar, color.green, size=size.small) plotshape(showCrosses and bearCross, "Sell Signal", shape.triangledown, location.abovebar, color.red, size=size.small) // Background color for trend bgcolor(bullish ? color.new(color.green, 95) : color.new(color.red, 95)) // Alerts alertcondition(bullCross, "Bullish Cross", "Fast VWMA crossed above Slow VWMA") alertcondition(bearCross, "Bearish Cross", "Fast VWMA crossed below Slow VWMA")
Features:
  • Volume-weighted for accuracy
  • Dynamic color based on trend
  • Visual crossover signals
  • Background trend highlighting
Indicator Template

Automatic Support & Resistance Levels

Automatically detects and draws key support and resistance levels based on pivot highs and lows. Updates dynamically.

//@version=5 indicator("S/R Levels", overlay=true) // Inputs leftBars = input.int(10, "Left Bars", minval=1) rightBars = input.int(10, "Right Bars", minval=1) maxLevels = input.int(5, "Max Levels to Show", minval=1, maxval=10) // Detect pivot points pivotHigh = ta.pivothigh(high, leftBars, rightBars) pivotLow = ta.pivotlow(low, leftBars, rightBars) // Store resistance levels var float[] resistanceLevels = array.new_float(0) var float[] supportLevels = array.new_float(0) // Add new levels if not na(pivotHigh) array.push(resistanceLevels, pivotHigh) if array.size(resistanceLevels) > maxLevels array.shift(resistanceLevels) if not na(pivotLow) array.push(supportLevels, pivotLow) if array.size(supportLevels) > maxLevels array.shift(supportLevels) // Plot levels for i = 0 to array.size(resistanceLevels) - 1 level = array.get(resistanceLevels, i) line.new(bar_index - 50, level, bar_index, level, color=color.red, width=1, style=line.style_dashed) for i = 0 to array.size(supportLevels) - 1 level = array.get(supportLevels, i) line.new(bar_index - 50, level, bar_index, level, color=color.green, width=1, style=line.style_dashed) // Alert when price touches levels nearResistance = false nearSupport = false threshold = close * 0.001 // 0.1% threshold for i = 0 to array.size(resistanceLevels) - 1 if math.abs(close - array.get(resistanceLevels, i)) < threshold nearResistance := true for i = 0 to array.size(supportLevels) - 1 if math.abs(close - array.get(supportLevels, i)) < threshold nearSupport := true alertcondition(nearResistance, "Near Resistance", "Price approaching resistance level") alertcondition(nearSupport, "Near Support", "Price approaching support level")
Features:
  • Automatic level detection
  • Configurable sensitivity
  • Alerts when price nears levels
  • Visual level plotting

📈 Free Strategy Templates

These strategy templates provide a solid foundation for building your own trading systems. Each includes backtesting, risk management, and performance tracking.

⚠️ Strategy Template Disclaimer

These templates are for educational purposes only. Past performance does not guarantee future results. Always test strategies thoroughly before risking real capital. Not financial advice.

📧 Want the Full Strategy Templates?

Complete strategy templates with entry/exit logic, position sizing, and stop-loss management are available. Contact me to receive:

  • Mean Reversion Strategy Template
  • Trend Following Strategy Template
  • Breakout Strategy Template
  • Complete documentation and usage guide
Request Strategy Templates

💻 Useful Code Snippets

Candle Pattern Detection

Detect common candlestick patterns (Doji, Hammer, Shooting Star)

// Doji detection bodySize = math.abs(close - open) doji = bodySize <= (high - low) * 0.1 // Hammer detection lowerWick = open < close ? open - low : close - low hammer = lowerWick > bodySize * 2 and (high - math.max(close, open)) < bodySize // Shooting Star upperWick = high - math.max(close, open) shootingStar = upperWick > bodySize * 2 and lowerWick < bodySize

ATR-Based Stop Loss & Take Profit

Dynamic stop loss and take profit based on volatility (ATR)

// Calculate ATR atrLength = input.int(14, "ATR Length") atrMultiplier = input.float(2.0, "ATR Multiplier", step=0.1) atr = ta.atr(atrLength) // For long positions longStopLoss = close - (atr * atrMultiplier) longTakeProfit = close + (atr * atrMultiplier * 2) // 2:1 reward ratio // For short positions shortStopLoss = close + (atr * atrMultiplier) shortTakeProfit = close - (atr * atrMultiplier * 2)

Trading Session Time Filter

Only trade during specific hours (useful for avoiding spreads during low liquidity)

// Session time filter startHour = input.int(9, "Start Hour (24h)", minval=0, maxval=23) endHour = input.int(16, "End Hour (24h)", minval=0, maxval=23) // Check if current time is within trading hours currentHour = hour(time) inSession = currentHour >= startHour and currentHour < endHour // Use in strategy if buyCondition and inSession strategy.entry("Long", strategy.long)

📚 Learning Resources

Check out our comprehensive blog guides to master Pine Script development:

Complete Guide to Pine Script v5 for Beginners →

Learn Pine Script from scratch with this comprehensive tutorial.

How to Create Custom Indicators in TradingView →

Step-by-step guide to building your own custom indicators.

View All Blog Articles →

Explore all Pine Script tutorials and guides.

Need Custom Pine Script Development?

These templates are great for learning, but if you need a custom indicator or strategy tailored to your specific trading needs, I can help.

Hire Me for Custom Development View Portfolio