Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Trade Hour

A Pine Script v5 strategy built on CUM (hours_x*indicator) and RSI or MFI (close, 24). It has 2 order rules and no entry of its own. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 3 settings; defaults include Src close, Timezone UTC+0000 and Timeperiod 24.

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 Trade Hour repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Trade Hour 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 entry conditions never all held on this data. On BTCUSDT 4h it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
Does Trade Hour run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 43 before, 23 after on BTCUSDT 4h, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does Trade Hour use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Trade Hour run in Zeal Terminal?
Yes
It compiles in 26 ms and runs 1,000 bars in 42 ms, in the browser.

BTCUSDT · 1D · default settings

  • 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 (3)
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. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference.
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

    2 settings have no label

    In the settings dialog src (line 6), timezone (line 7) 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.

  • Note

    Uses an argument v6 removed

    when = on line 37, 38. The upgraded version below moves each call inside an if block.

Settings

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

SettingDefaultType and rangeFeeds
Src (no label in the script)closesourcebuy_indicator sell_indicator
Timezone (no label in the script)UTC+0000string · options ["UTC+0000","GMT+0000","America/New_York","America/Los_Angeles","America/Chicago","America/Phoenix","America/Toronto","America/Vancouver","America/Argentina" ,"America/El_Salvador","America/Sao_Paulo","America/Bogota","Europe/Moscow","Europe/Athens","Europe/Berlin","Europe/London","Europe/Madrid","Europe/Paris","Europe/Warsaw","Australia/Sydney","Australia/Brisbane","Australia/Adelaide","Australia/ACT","Asia/Almaty","Asia/Ashkhabad","Asia/Tokyo","Asia/Taipei","Asia/Singapore","Asia/Shanghai","Asia/Seoul","Asia/Tehran","Asia/Dubai","Asia/Kolkata","Asia/Hong_Kong","Asia/Bangkok","Pacific/Auckland","Pacific/Chatham","Pacific/Fakaofo","Pacific/Honolulu"]hours isLongBestHour isShortBestHour
Timeperiod24intbuy_indicator sell_indicator

What it calculates

  • CUMhours_x*indicatorhours_x_avg · line 20
  • CUMhours_y*indicatorhours_y_avg · line 21
  • RSI / MFISrc (close), Timeperiod (24)buy_indicator · line 23
  • RSI / MFI1/src, Timeperiod (24)sell_indicator · line 24

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.

closecloseprice datalengthTimeperiodsetting · 24timetimeprice datatimezoneTimezonesetting · UTC+0000hours_x_avgCUM→ hours_x_avghours_y_avgCUM→ hours_y_avgbuy_indicatorRSI / MFI→ buy_indicatorsell_indicatorRSI / MFI→ sell_indicatorresultresultvaluehourshoursvaluehours_y, hours_xhours_y · hours_x2 valueshours_avghours_avgvaluebuy_hourbuy_hourvaluesell_hoursell_hourvalueisLongBestHourisLongBestHourconditionisShortBestHourisShortBestHourconditionorder:buyorder buystrategy.orderorder:sellorder sellstrategy.orderplot:31Buy hourplotplot:32Sell hourplotbgcolor:35bgcolorbgcolorbgcolor:36bgcolorbgcolor

Order rules

OrderFires whenBy defaultLine
order buy longisLongBestHourmath.round(buy_hour) == hour(time,timezone)On37
order sell shortisShortBestHourmath.round(sell_hour) == hour(time,timezone)On38

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 4h+12.9%+5.5%4342%2.809.2%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.5%+8.4%4269%3.620.5%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%5060%6.270.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%2454%3.120.1%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
Trade Hour this page—v5 strategy0.0%00.0%
CCU MFI + RSI + STOCH RSI by Bangsoulmfi rsiv4 strategy+41.8%637.4%
Full CRYPTO pack macd, rsi, obv, ema strategy by SoftKill21rsi cumv4 strategyNo trades on this market
3 Indicator Strategy (StochRSI, MFI & EMA) With Safety Orders by ggekko21rsi mfiv5 strategyNo trades on this market

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.

  • 2 strategy calls use the when = argument (line 37, 38). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

Same 43 trades and the same P&L on BTCUSDT 4h, 1,000 bars, in Zeal Terminal's engine.

  • Line 37: when = isLongBestHour → if block
  • Line 38: when = isShortBestHour → if block
⋯bgcolor(isShortBestHour ? color.new(color.red,80) : na)-strategy.order("buy", strategy.long, when =isLongBestHour)+if isLongBestHour+    strategy.order("buy", strategy.long)-strategy.order("sell", strategy.short, when = isShortBestHour)+if isShortBestHour+    strategy.order("sell", strategy.short)

Does it run in Pine Script v6?

No

The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 43 before, 23 after on BTCUSDT 4h, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// based on idea of circular mean with atan2-//@version=5+//@version=6strategy("Trade Hour V4",overlay=false)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 26 msYes 1,000 bars in 42 msNot measured
PineTSNot testedNot testedNot measured

“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/// © mablue (Masoud Azizi)// based on idea of circular mean with atan2//@version=5strategy("Trade Hour V4",overlay=false)src = input.source(close)timezone = input.string("UTC+0000",options=["UTC+0000","GMT+0000","America/New_York","America/Los_Angeles","America/Chicago","America/Phoenix","America/Toronto","America/Vancouver","America/Argentina" ,"America/El_Salvador","America/Sao_Paulo","America/Bogota","Europe/Moscow","Europe/Athens","Europe/Berlin","Europe/London","Europe/Madrid","Europe/Paris","Europe/Warsaw","Australia/Sydney","Australia/Brisbane","Australia/Adelaide","Australia/ACT","Asia/Almaty","Asia/Ashkhabad","Asia/Tokyo","Asia/Taipei","Asia/Singapore","Asia/Shanghai","Asia/Seoul","Asia/Tehran","Asia/Dubai","Asia/Kolkata","Asia/Hong_Kong","Asia/Bangkok","Pacific/Auckland","Pacific/Chatham","Pacific/Fakaofo","Pacific/Honolulu"]   )length = input.int(24,"Timeperiod")arctan2(x,y)=>    if x>0 and y>0        result = math.atan(x/y)     else if y<0        result = math.atan(x/y) + math.pi    else if x<0 and y>0        result = math.atan(x/y) + 2*math.pibest_hour(indicator)=>    hours = (2*math.pi)*(hour(time,timezone)/24)    hours_y =  math.sin(hours)    hours_x =  math.cos(hours)    hours_x_avg = ta.cum(hours_x*indicator)/ta.cum(indicator)    hours_y_avg = ta.cum(hours_y*indicator)/ta.cum(indicator)    hours_avg = (arctan2(hours_y_avg,hours_x_avg)*24/(2*math.pi))%24buy_indicator = math.avg(ta.rsi(src,length),ta.mfi(src,length))sell_indicator = math.avg(ta.rsi(1/src,length),ta.mfi(1/src,length))// buy_indicator = ta.roc(src,length)// sell_indicator = ta.roc(1/src,length)// buy_indicator = ta.roc(src,length)// sell_indicator = ta.roc(1/src,length)buy_hour = best_hour(buy_indicator)sell_hour = best_hour(sell_indicator)plot(buy_hour,"Buy hour",color.green)plot(sell_hour,"Sell hour",color.red)bool isLongBestHour = math.round(buy_hour) == hour(time,timezone)bool isShortBestHour =   math.round(sell_hour) == hour(time,timezone)bgcolor(isLongBestHour ? color.new(color.green,80) : na)bgcolor(isShortBestHour ? color.new(color.red,80) : na)strategy.order("buy", strategy.long, when =isLongBestHour)strategy.order("sell", strategy.short, when = isShortBestHour)