A test strategy from a reference corpus that builds a VWAP restarted on the first bar of each trading session, using typical price times volume during market hours.
// TV_RUN_NEEDED: tv_trades.csv missing — capture in TradingView:
// Symbol: SPY TF: 5m Range: 2024-01-02..2024-03-29
// Save List of Trades → tv_trades.csv in this directory.
//@version=6
strategy("Session isfirstbar VWAP anchor", overlay=true,
default_qty_type=strategy.fixed, default_qty_value=1)
// Anchor VWAP to the first bar of each trading session using session.isfirstbar.
// Buy when close crosses above session VWAP; sell when it crosses below.
var float cum_pv = 0.0
var float cum_vol = 0.0
if session.isfirstbar
cum_pv := 0.0
cum_vol := 0.0
if session.ismarket
cum_pv := cum_pv + hlc3 * volume
cum_vol := cum_vol + volume
session_vwap = cum_vol > 0 ? cum_pv / cum_vol : close
if session.ismarket
if ta.crossover(close, session_vwap)
strategy.entry("Long", strategy.long)
if ta.crossunder(close, session_vwap)
strategy.close("Long")
Overview
Session Isfirstbar VWAP Anchor buys one unit when the close crosses above this session VWAP and closes the long when the close crosses below. There is no stop loss or take profit. It was written for SPY on a 5-minute chart to check engine session variables and is a code example rather than a tuned system.
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.
This overlay strategy plots previous-day high and low, the daily open, and fair value gap zones on the price chart. It takes entries on a selectable timeframe when the FVG requirement and an optional session window allow them, then uses an ATR or fixed pip sto
This script monitors opening gap conditions and breakout behavior relative to the first candle's range across up to twenty configurable stock tickers. It detects whether following bars remain inside the opening range before breaking out, displaying the status
This overlay strategy targets one-minute ATOM scalps. It tracks pivot highs and lows as resistance and support, compares a three-period EMA with a multi-stage smoothed close, and flags long or short when price crosses that curve in the matching direction. Dail
P404 Smoke is a price-chart strategy that sequences an optional higher-timeframe EMA bias, a liquidity range from recent pivots, a sweep of buy-side or sell-side liquidity, and a market structure shift within a set bar window. Comments state it then looks for
This strategy plots a Fibonacci retracement of the previous day's high-low range on the price chart. It places a single long limit order at that level when the bar hour matches the chosen entry hour and the close is below the level. Position size follows the l
This intraday strategy implements session-based trading rules tailored for gold on short timeframes. It tracks the Asian session price range, VWAP, 20-period EMA, and previous day high and low levels to identify liquidity sweeps during London and New York trad