Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Trading Day and Time Session

A Pine Script v5 strategy built on VWMA (hl2, maLength), Rising (wma, 5) and Falling (wma, 5). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 15 settings; defaults include From 1, From Month 1 and From Year 2010.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does Trading Day and Time Session repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Trading Day and Time Session do on BTCUSDT 1D with default settings?
Not measured
It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
Does Trading Day and Time Session run in Pine Script v6?
Not tested
Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download.
Does Trading Day and Time Session use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Trading Day and Time Session run in Zeal Terminal?
Yes
It compiles in 21 ms and runs 1,000 bars in 46 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (15)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,000,000$2,025,273Equity from $1,000,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
Net profit
0.00%
$0.00
Buy and hold
+102.5%
same period
Closed trades
0
0 won · 0 lost
Profitable
0.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.00%
$0.00

One run with the author's default settings, $1,000,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Check

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Note

    5 settings have no label

    In the settings dialog fromMonth (line 7), fromYear (line 8), toMonth (line 10), toYear (line 11), i_sess (line 15) show an empty name. The labels on this page come from the variable names.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Trade Session
From1int · min 1 · max 31startDate
From Month (no label in the script)1int · min 1 · max 12startDate
From Year (no label in the script)2010int · min 1970startDate
To31int · min 1 · max 31finishDate
To Month (no label in the script)12int · min 1 · max 12finishDate
To Year (no label in the script)2099int · min 1970finishDate
I sess (no label in the script)0400-1900sessiontime_cond
UTC Offset3int · min -10 · max 13UTC_string
Trade Monday?trueboolline 27
Trade Tuesday?trueboolline 29
Trade Wednesday?trueboolline 31
Trade Thursday?trueboolline 33
Trade Friday?trueboolline 35
Trade Saturday?falseboolline 37
Trade Sunday?falseboolline 39

What it calculates

  • VWMAhl2, maLengthwma · line 45
  • Risingwma, 5uptrend · line 46
  • Fallingwma, 5downtrend · line 47

Signal flow

How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

hl2hl2price datafromYearFrom Yearsetting · 2010fromMonthFrom Monthsetting · 1fromDayFromsetting · 1toYearTo Yearsetting · 2099toMonthTo Monthsetting · 12toDayTosetting · 31UTC_offsetUTC Offsetsetting · 3i_sessI sesssetting · 0400-1900timetimeprice datawmaVWMA→ wmauptrendRising→ uptrenddowntrendFalling→ downtrendstartDatestartDatevaluefinishDatefinishDatevalueUTC_stringUTC_stringvaluetime_condtime_condvaluedate_conddate_condconditionfinal_time_condfinal_time_condconditionentry:BuyOpen Buystrategy.entryclose:BuyClose Buystrategy.closebgcolor:41bgcolorbgcolorplot:48plotplot

Order rules

OrderFires whenBy defaultLine
Open Buy longuptrendOn51
Close BuyuptrendOn53

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

No

No repainting patterns in the source.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—0.0%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
Trading Day and Time Session this page—v5 strategy0.0%00.0%
Quarterly Returns in Strategies vs Buy & Hold by Dannnnnnnyvwma rising fallingv4 strategy+80.2%410.7%
Swing Trading SPX Correlation by exlux99vwma risingv5 strategyNo trades on this market
PMA Strategy Idea by QuantCTrising fallingv4 strategy+51.7%12930.8%
Trendelicious Strategy by levieuxrising fallingv5 strategy−12.8%941.4%
Linear On MACD by stocktechbotrising falling vwmav5 strategy+1.5%165.6%

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • 7 settings use the untyped input() (line 19, 20, 21, 22, 23, 24, 25). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 19: input() → input.bool()
  • Line 20: input() → input.bool()
  • Line 21: input() → input.bool()
  • Line 22: input() → input.bool()
  • Line 23: input() → input.bool()
  • Line 24: input() → input.bool()
  • Line 25: input() → input.bool()
⋯time_cond = time(timeframe.period, i_sess, UTC_string)-is_trade_mon = input(true, title="Trade Monday?", group='Trade Session')+is_trade_mon = input.bool(true, title="Trade Monday?", group='Trade Session')-is_trade_tue = input(true, title="Trade Tuesday?", group='Trade Session')+is_trade_tue = input.bool(true, title="Trade Tuesday?", group='Trade Session')-is_trade_wed = input(true, title="Trade Wednesday?", group='Trade Session')+is_trade_wed = input.bool(true, title="Trade Wednesday?", group='Trade Session')-is_trade_thu = input(true, title="Trade Thursday?", group='Trade Session')+is_trade_thu = input.bool(true, title="Trade Thursday?", group='Trade Session')-is_trade_fri = input(true, title="Trade Friday?", group='Trade Session')+is_trade_fri = input.bool(true, title="Trade Friday?", group='Trade Session')-is_trade_sat = input(false, title="Trade Saturday?", group='Trade Session')+is_trade_sat = input.bool(false, title="Trade Saturday?", group='Trade Session')-is_trade_sun = input(false, title="Trade Sunday?", group='Trade Session')+is_trade_sun = input.bool(false, title="Trade Sunday?", group='Trade Session')day_cond = false⋯

Does it run in Pine Script v6?

Not tested

Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © Dannnnnnny-//@version=5+//@version=6strategy(title="Trade Day-Time Session", overlay = true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 21 msWith a workaround 1,000 bars in 46 msNot measured
PineTSNot testedNot testedNot measured

The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © Dannnnnnny//@version=5strategy(title="Trade Day-Time Session", overlay = true)//Session=====================================================================fromDay = input.int(defval = 1, title = "From", minval = 1, maxval = 31, inline="1", group='Trade Session')fromMonth = input.int(defval = 1, title = "", minval = 1, maxval = 12,inline="1", group='Trade Session')fromYear = input.int(defval = 2010, title = "", minval = 1970, inline="1", group='Trade Session')toDay = input.int(defval = 31, title = "To", minval = 1, maxval = 31, inline="2", group='Trade Session')toMonth = input.int(defval = 12, title = "", minval = 1, maxval = 12, inline="2",group='Trade Session')toYear = input.int(defval = 2099, title = "", minval = 1970, inline="2",group='Trade Session')startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)finishDate = timestamp(toYear, toMonth, toDay, 00, 00)date_cond = time >= startDate and time <= finishDatei_sess = input.session("0400-1900", "Trade time", group='Trade Session')UTC_offset = input.int(3, title='UTC Offset', minval=-10, maxval=13, group='Trade Session')UTC_string = 'UTC' + (UTC_offset > 0 ? '+' : '') + (UTC_offset != 0 ? str.tostring(UTC_offset) : '')time_cond = time(timeframe.period, i_sess, UTC_string)is_trade_mon = input(true, title="Trade Monday?", group='Trade Session')is_trade_tue = input(true, title="Trade Tuesday?", group='Trade Session')is_trade_wed = input(true, title="Trade Wednesday?", group='Trade Session')is_trade_thu = input(true, title="Trade Thursday?", group='Trade Session')is_trade_fri = input(true, title="Trade Friday?", group='Trade Session')is_trade_sat = input(false, title="Trade Saturday?", group='Trade Session')is_trade_sun = input(false, title="Trade Sunday?", group='Trade Session')day_cond = falseif(dayofweek(time_cond, UTC_string) == dayofweek.monday and is_trade_mon)    day_cond := trueelse if(dayofweek(time_cond, UTC_string) == dayofweek.tuesday and is_trade_tue)    day_cond := trueelse if(dayofweek(time_cond, UTC_string) == dayofweek.wednesday and is_trade_wed)    day_cond := trueelse if(dayofweek(time_cond, UTC_string) == dayofweek.thursday and is_trade_thu)    day_cond := trueelse if(dayofweek(time_cond, UTC_string) == dayofweek.friday and is_trade_fri)    day_cond := trueelse if(dayofweek(time_cond, UTC_string) == dayofweek.saturday and is_trade_sat)    day_cond := trueelse if(dayofweek(time_cond, UTC_string) == dayofweek.sunday and is_trade_sun)    day_cond := truebgcolor(time == time_cond and day_cond ? color.new(color.gray,90) : na)final_time_cond = time == time_cond and day_cond and date_cond//=====================================================================maLength= 400wma= ta.vwma(hl2,maLength)uptrend= ta.rising(wma, 5)downtrend= ta.falling(wma,5)plot(wma)if(final_time_cond)    if uptrend        strategy.entry("Buy", strategy.long)    else        strategy.close("Buy")