Strategy · Pine Script v5 · On the chart

Session Wicks

by g-moe· code credited to goodgains

Session Wicks is a price-chart strategy that combines a Heikin Ashi weighted moving average, an RSI compared with its moving average, and a smoothed stochastic.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code101
Settings13inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago27 May 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

101 lines of Pine Script v5 from Tradingview/session-wicks-v3.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

session-wicks-v3.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © goodgains


//@version=5
strategy("Session Wicks", overlay=true, margin_long=100, margin_short=100)

// @keywords: session-wicks-v3, session-wicks-strategy, heikin-ashi-wma, rsi-ma-cross, slow-stochastic, ha-candle-average, multi-filter-entry, long-short-strategy, trading-hours-filter, strategy-start-date, chart-bull-bear, ha-moving-average, rsi-inverse-filter, stoch-k-d-cross, request-security-tf, wma-ha-trend, session-wick-exits, ha-rsi-stoch-combo, position-close-exit, timeframe-security-ohlc

ma(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "Bollinger Bands" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)

symbol_tf = input.timeframe('', title = 'Timeframe to Use', group = 'Settings')

source_open = request.security(syminfo.tickerid, symbol_tf, symbol_tf == '' ? open : open[1], lookahead = barmerge.lookahead_on)
source_high = request.security(syminfo.tickerid, symbol_tf, symbol_tf == '' ? high : high[1], lookahead = barmerge.lookahead_on)
source_low = request.security(syminfo.tickerid, symbol_tf, symbol_tf == '' ? low : low[1], lookahead = barmerge.lookahead_on)
source_close = request.security(syminfo.tickerid, symbol_tf, symbol_tf == '' ? close : close[1], lookahead = barmerge.lookahead_on)

// RSI
chart_rsiLengthInput = input.int(14, minval=1, title="RSI Length", group = 'Settings')
chart_rsiSourceInput = source_close
chart_maTypeInput = input.string("SMA", title="RSI MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = 'Settings')
chart_maLengthInput = input.int(14, title="RSI MA Length", group = 'Settings')

chart_up = ta.rma(math.max(ta.change(chart_rsiSourceInput), 0), chart_rsiLengthInput)
chart_down = ta.rma(-math.min(ta.change(chart_rsiSourceInput), 0), chart_rsiLengthInput)
chart_rsi = chart_down == 0 ? 100 : chart_up == 0 ? 0 : 100 - (100 / (1 + chart_up / chart_down))
chart_rsiMA = ma(chart_rsi, chart_maLengthInput, chart_maTypeInput)

inversersi_bull = chart_rsi > chart_rsiMA
inversersi_bear = chart_rsi < chart_rsiMA

// HA
chart_len = input.int(10, minval=1, maxval=500, title="HA Length", group = 'Settings')
chart_haClose = (source_open + source_high + source_low + source_close) / 4
chart_haOpen = float(na)
chart_haOpen := na(chart_haOpen[1]) ? (source_open + source_close) / 2 : (nz(chart_haOpen[1]) + nz(chart_haClose[1])) / 2
chart_haHigh = math.max(source_high, math.max(chart_haOpen, chart_haClose))
chart_haLow = math.min(source_low, math.min(chart_haOpen, chart_haClose))

// STOCH
chart_periodK = input.int(14, title="Stoch %K Length", minval=1, group = 'Settings')
chart_smoothK = input.int(3, title="Stock %K Smoothing", minval=1, group = 'Settings')
chart_periodD = input.int(3, title="Stock %D Smoothing", minval=1, group = 'Settings')
chart_k = ta.sma(ta.stoch(source_close, source_high, source_low, chart_periodK), chart_smoothK)
chart_d = ta.sma(chart_k, chart_periodD)

// // //
chart_avg = math.avg(chart_haOpen,chart_haHigh,chart_haLow,chart_haClose)
chart_HA_movingAverage = ta.wma(chart_avg, chart_len)

chartha_bull = chart_HA_movingAverage <= chart_HA_movingAverage[1]
chartha_bear = chart_HA_movingAverage > chart_HA_movingAverage[1]

chart_bull = chart_HA_movingAverage <= chart_HA_movingAverage[1] and chart_rsi < chart_rsiMA and chart_k < chart_d
chart_bear = chart_HA_movingAverage > chart_HA_movingAverage[1] and chart_rsi > chart_rsiMA and chart_k > chart_d
// 


// --STRATEGY INPUTS-- //
strategy_start = input.time(timestamp("01 January 2020 00:00:00 UTC-5"), "Strategy Start Date", group = "StrategySettings", inline = '1')
use_trading_hours = input.bool(false, title = "Use Trading Hours", tooltip = "This is ignored if the chart timeframe is greater than or equal to the daily timeframe.", group = "StrategySettings", inline = '2')
trading_time = input.session("0930-1600", title = " ", tooltip = "This uses Eastern Time Zone or U.S. NY Market Hours.", group = "StrategySettings", inline = '2')
trading_hours_cond = not use_trading_hours or time("",trading_time, "America/New_York")

long_trades = input.bool(true, title = "Long Trades", tooltip = "Do we want to take long trades?" , group = "StrategySettings", inline = '3')
short_trades = input.bool(true, title = "Short Trades", tooltip = "Do we want to take short trades?" , group = "StrategySettings", inline = '4')

long_entry = long_trades and trading_hours_cond and chart_bull
long_exit = long_trades and chartha_bull[1] and not chartha_bull

short_entry = short_trades and trading_hours_cond and  chart_bear
short_exit = short_trades and chartha_bear[1] and not chartha_bear

past_strategy_start_date = time >= strategy_start ? true : false
// --STRATEGY INPUTS-- //


// --ORDERS-- //
if past_strategy_start_date
    if long_exit
        strategy.close("LE", comment = 'LX')

    if short_exit
        strategy.close("SS_E", comment = 'SS_X')

    if long_entry
        strategy.entry("LE", strategy.long)

    if short_entry
        strategy.entry("SS_E", strategy.short)


// --ORDERS-- //

Overview

Bullish and bearish states come from the Heikin Ashi average falling or rising and from RSI sitting above or below its average. Users can choose the calculation timeframe, RSI and stochastic lengths, moving-average type, a start date, and optional session hours, and can enable long or short trades. The supplied code defines no stop loss.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Oscillators & momentum, Moving averages, Sessions & time

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Timeframe to Usetimeframesymbol_tf
RSI Lengthint14chart_rsiLengthInput
RSI MA TypestringSMAchart_maTypeInput
RSI MA Lengthint14chart_maLengthInput
HA Lengthint10chart_len
Stoch %K Lengthint14chart_periodK
Stock %K Smoothingint3chart_smoothK
Stock %D Smoothingint3chart_periodD
Strategy Start Datetimetimestamp("01 January 2020 00:00:00 UTC-5")strategy_start
Use Trading Hoursboolfalseuse_trading_hours
session0930-1600trading_time
Long Tradesbooltruelong_trades
Show all 13 settings
SettingTypeDefaultVariable
Short Tradesbooltrueshort_trades
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

106 stars

This intraday strategy enters positions based on an alignment of trend, momentum, and oscillator indicators. It triggers long entries when the Commodity Channel Index is above a positive threshold, a fast Relative Strength Index crosses above a slow RSI, price

Strategy v5 TrendOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of CCI + EMA with RSI Cross Strategy
10 stars

The Reverse RSI Strategy is a scalping system designed for forex pairs during specific trading sessions. It combines a smoothed RSI indicator with five Exponential Moving Averages to identify mean-reversion trade opportunities. Position sizing dynamically adju

Strategy v4 Oscillators & momentumMoving averages
Updated 3 years ago · GPL-3.0 GitHub repository of Strategy - Reverse RSI
4 stars

This strategy calculates fast and slow exponential moving averages, the Relative Strength Index, and the Average True Range directly on the price chart. It enters long positions when the fast EMA crosses above the slow EMA with RSI above the minimum threshold

Strategy v6 TrendMoving averages
Updated 2 months ago · MIT GitHub repository of NQ Nasdaq Strategy [trugurpala]
4 stars

This intraday strategy executes trades using dual EMA crossovers and RSI mean-reversion near VWAP. Designed primarily for 5-minute index futures charts like ES and MES, it offers momentum entries on fast and slow EMA crosses confirmed by VWAP, as well as count

Strategy v6 Moving averagesOscillators & momentum
Updated yesterday · None stated GitHub repository of Ultimate Combo v2 (Relaxed)
2 stars

Gold Multi-TF NYSE Scalper v2 is an intraday trading strategy for XAUUSD that seeks momentum entries by aligning RSI and EMA bias across multiple timeframes. It filters trades using an optional NYSE session clock and an ATR volatility spike check. Entries exit

Strategy v6 Oscillators & momentumVolatility & bands
Updated 7 days ago · None stated GitHub repository of Gold Multi-TF NYSE Scalper v2

Gap and Go

by Basant1Saini
1 stars

This strategy trades opening gap continuation on the price chart. It measures the gap between the daily open and the prior daily close, then enters long after a qualifying gap up or short after a qualifying gap down when price stays beyond the open and a trend

Strategy v5 BreakoutOscillators & momentum Repaints
Updated 7 months ago · None stated GitHub repository of Gap and Go

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers