Zeal Terminal Open Zeal Terminal

Pine Script v4 · Strategy

Time of Day and Day of Week Buying and Selling Strategy

A Pine Script v4 strategy with no technical-analysis calculation. It has 3 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 13 settings; defaults include From Month 1, From day 1 and From Year 2021.

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 Time of Day and Day of Week Buying and Selling Strategy repaint?
No
No repainting patterns were found in the source.
Can Time of Day and Day of Week Buying and Selling Strategy be converted to Pine Script v5?
Not tested
The steps are shown below, but the original does not run in Zeal Terminal's engine, so they could not be checked.
Does Time of Day and Day of Week Buying and Selling Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Time of Day and Day of Week Buying and Selling Strategy run in Zeal Terminal?
No
Not yet: Pine Script v4 Error at @L127:C22: 'str.split' is not available in Pine Script v4. It was added in a later version.
Does not run in Zeal Terminal yetPine Script v4 Error at @L127:C22: 'str.split' is not available in Pine Script v4. It was added in a later version. The settings, logic and review below are read from the source, which does not need a run.

Review

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

  • 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

    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 150, 152. The upgraded version below moves each call inside an if block.

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

  • Upgrading to v5 renames tostring → str.tostring, min → math.min, max → math.max.
  • 2 strategy calls use the when = argument (line 150, 152). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Not verified

The v4 script does not run in Zeal Terminal's engine (Pine Script v4 Error at @L127:C22: 'str.split' is not available in Pine Script v4. It was added in a later version.), so this step could not be checked.

  • Line 2: //@version=4 → //@version=5
  • Line 10: input(type = input.bool) → input.bool()
  • Line 11: input(type = input.bool) → input.bool()
  • Line 12: input(type = input.bool) → input.bool()
  • Line 13: input(type = input.bool) → input.bool()
  • Line 14: input(type = input.bool) → input.bool()
9 more edits
  • Line 15: input(type = input.bool) → input.bool()
  • Line 16: input(type = input.bool) → input.bool()
  • Line 123: tostring → str.tostring
  • Line 123: tostring → str.tostring
  • Line 124: tostring → str.tostring
  • Line 124: tostring → str.tostring
  • Line 129: min → math.min
  • Line 129: max → math.max
  • Line 137: max → math.max
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/-//@version=4+//@version=5strategy("Timeframe Time of Day and Day of Week Buying and Selling Strategy", overlay=true)⋯toyear = input(defval = 2100, minval = 1900, maxval = 2100, title = "To Year")-sun = input(defval=true, title='Sunday', type = input.bool)+sun = input.bool(defval=true, title='Sunday')-mon = input(defval=true, title='Monday', type = input.bool)+mon = input.bool(defval=true, title='Monday')-tue = input(defval=true, title='Tueday', type = input.bool)+tue = input.bool(defval=true, title='Tueday')-wed = input(defval=true, title='Wednesday', type = input.bool)+wed = input.bool(defval=true, title='Wednesday')-thu = input(defval=true, title='Thurday', type = input.bool)+thu = input.bool(defval=true, title='Thurday')-fri = input(defval=true, title='Friday', type = input.bool)+fri = input.bool(defval=true, title='Friday')-sat = input(defval=true, title='Saturday', type = input.bool)+sat = input.bool(defval=true, title='Saturday')sunFilter = sun and ((dayofweek==7 and hour==23 and minute>30) or (dayofweek==1 and (hour <23 or (hour == 23 and minute<=30))))⋯array.set(timeframes_options,47, input(defval='None', options=['Long','Short','None'], title='2330-0000'))-string_hour = hour<10?'0'+tostring(hour):tostring(hour)+string_hour = hour<10?'0'+str.tostring(hour):str.tostring(hour)-string_minute = minute<10?'0'+tostring(minute):tostring(minute)+string_minute = minute<10?'0'+str.tostring(minute):str.tostring(minute)current_time = string_hour+string_minute⋯    int _len = array.size(_chars)-    int _end = min(_len, max(0, _n))+    int _end = math.min(_len, math.max(0, _n))    string[] _substr = array.new_string(0)⋯    int _len = array.size(_chars)-    int _beg = max(0, _len - _n)+    int _beg = math.max(0, _len - _n)    string[] _substr = array.new_string(0)⋯

Clean v5

Not verified

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

  • Line 4: input() → input.int()
  • Line 5: input() → input.int()
  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 8: input() → input.int()
  • Line 9: input() → input.int()
50 more edits
  • Line 28: input() → input.string()
  • Line 30: input() → input.string()
  • Line 32: input() → input.string()
  • Line 34: input() → input.string()
  • Line 36: input() → input.string()
  • Line 38: input() → input.string()
  • Line 40: input() → input.string()
  • Line 42: input() → input.string()
  • Line 44: input() → input.string()
  • Line 46: input() → input.string()
  • Line 48: input() → input.string()
  • Line 50: input() → input.string()
  • Line 52: input() → input.string()
  • Line 54: input() → input.string()
  • Line 56: input() → input.string()
  • Line 58: input() → input.string()
  • Line 60: input() → input.string()
  • Line 62: input() → input.string()
  • Line 64: input() → input.string()
  • Line 66: input() → input.string()
  • Line 68: input() → input.string()
  • Line 70: input() → input.string()
  • Line 72: input() → input.string()
  • Line 74: input() → input.string()
  • Line 76: input() → input.string()
  • Line 78: input() → input.string()
  • Line 80: input() → input.string()
  • Line 82: input() → input.string()
  • Line 84: input() → input.string()
  • Line 86: input() → input.string()
  • Line 88: input() → input.string()
  • Line 90: input() → input.string()
  • Line 92: input() → input.string()
  • Line 94: input() → input.string()
  • Line 96: input() → input.string()
  • Line 98: input() → input.string()
  • Line 100: input() → input.string()
  • Line 102: input() → input.string()
  • Line 104: input() → input.string()
  • Line 106: input() → input.string()
  • Line 108: input() → input.string()
  • Line 110: input() → input.string()
  • Line 112: input() → input.string()
  • Line 114: input() → input.string()
  • Line 116: input() → input.string()
  • Line 118: input() → input.string()
  • Line 120: input() → input.string()
  • Line 122: input() → input.string()
  • Line 150: when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 00, 00)) → if block
  • Line 152: when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 00, 00)) → if block
⋯strategy("Timeframe Time of Day and Day of Week Buying and Selling Strategy", overlay=true)-frommonth = input(defval = 1, minval = 01, maxval = 12, title = "From Month")+frommonth = input.int(defval = 1, minval = 01, maxval = 12, title = "From Month")-fromday = input(defval = 1, minval = 01, maxval = 31, title = "From day")+fromday = input.int(defval = 1, minval = 01, maxval = 31, title = "From day")-fromyear = input(defval = 2021, minval = 1900, maxval = 2100, title = "From Year")+fromyear = input.int(defval = 2021, minval = 1900, maxval = 2100, title = "From Year")-tomonth = input(defval = 12, minval = 01, maxval = 12, title = "To Month")+tomonth = input.int(defval = 12, minval = 01, maxval = 12, title = "To Month")-today = input(defval = 31, minval = 01, maxval = 31, title = "To day")+today = input.int(defval = 31, minval = 01, maxval = 31, title = "To day")-toyear = input(defval = 2100, minval = 1900, maxval = 2100, title = "To Year")+toyear = input.int(defval = 2100, minval = 1900, maxval = 2100, title = "To Year")sun = input.bool(defval=true, title='Sunday')⋯array.set(timeframes,0,'2330-0000')-array.set(timeframes_options,0, input(defval='None', options=['Long','Short','None'], title='0000-0030'))+array.set(timeframes_options,0, input.string(defval='None', options=['Long','Short','None'], title='0000-0030'))array.set(timeframes,1,'0000-0030')-array.set(timeframes_options,1, input(defval='None', options=['Long','Short','None'], title='0030-0100'))+array.set(timeframes_options,1, input.string(defval='None', options=['Long','Short','None'], title='0030-0100'))array.set(timeframes,2,'0030-0100')-array.set(timeframes_options,2, input(defval='None', options=['Long','Short','None'], title='0100-0130'))+array.set(timeframes_options,2, input.string(defval='None', options=['Long','Short','None'], title='0100-0130'))array.set(timeframes,3,'0100-0130')-array.set(timeframes_options,3, input(defval='None', options=['Long','Short','None'], title='0130-0200'))+array.set(timeframes_options,3, input.string(defval='None', options=['Long','Short','None'], title='0130-0200'))array.set(timeframes,4,'0130-0200')-array.set(timeframes_options,4, input(defval='None', options=['Long','Short','None'], title='0200-0230'))+array.set(timeframes_options,4, input.string(defval='None', options=['Long','Short','None'], title='0200-0230'))array.set(timeframes,5,'0200-0230')-array.set(timeframes_options,5, input(defval='None', options=['Long','Short','None'], title='0230-0300'))+array.set(timeframes_options,5, input.string(defval='None', options=['Long','Short','None'], title='0230-0300'))array.set(timeframes,6,'0230-0300')-array.set(timeframes_options,6, input(defval='None', options=['Long','Short','None'], title='0300-0330'))+array.set(timeframes_options,6, input.string(defval='None', options=['Long','Short','None'], title='0300-0330'))array.set(timeframes,7,'0300-0330')-array.set(timeframes_options,7, input(defval='None', options=['Long','Short','None'], title='0330-0400'))+array.set(timeframes_options,7, input.string(defval='None', options=['Long','Short','None'], title='0330-0400'))array.set(timeframes,8,'0330-0400')-array.set(timeframes_options,8, input(defval='None', options=['Long','Short','None'], title='0400-0430'))+array.set(timeframes_options,8, input.string(defval='None', options=['Long','Short','None'], title='0400-0430'))array.set(timeframes,9,'0400-0430')-array.set(timeframes_options,9, input(defval='None', options=['Long','Short','None'], title='0430-0500'))+array.set(timeframes_options,9, input.string(defval='None', options=['Long','Short','None'], title='0430-0500'))array.set(timeframes,10,'0430-0500')-array.set(timeframes_options,10, input(defval='None', options=['Long','Short','None'], title='0500-0530'))+array.set(timeframes_options,10, input.string(defval='None', options=['Long','Short','None'], title='0500-0530'))array.set(timeframes,11,'0500-0530')-array.set(timeframes_options,11, input(defval='None', options=['Long','Short','None'], title='0530-0600'))+array.set(timeframes_options,11, input.string(defval='None', options=['Long','Short','None'], title='0530-0600'))array.set(timeframes,12,'0530-0600')-array.set(timeframes_options,12, input(defval='None', options=['Long','Short','None'], title='0600-0630'))+array.set(timeframes_options,12, input.string(defval='None', options=['Long','Short','None'], title='0600-0630'))array.set(timeframes,13,'0600-0630')-array.set(timeframes_options,13, input(defval='None', options=['Long','Short','None'], title='0630-0700'))+array.set(timeframes_options,13, input.string(defval='None', options=['Long','Short','None'], title='0630-0700'))array.set(timeframes,14,'0630-0700')-array.set(timeframes_options,14, input(defval='None', options=['Long','Short','None'], title='0700-0730'))+array.set(timeframes_options,14, input.string(defval='None', options=['Long','Short','None'], title='0700-0730'))array.set(timeframes,15,'0700-0730')-array.set(timeframes_options,15, input(defval='None', options=['Long','Short','None'], title='0730-0800'))+array.set(timeframes_options,15, input.string(defval='None', options=['Long','Short','None'], title='0730-0800'))array.set(timeframes,16,'0730-0800')-array.set(timeframes_options,16, input(defval='None', options=['Long','Short','None'], title='0800-0830'))+array.set(timeframes_options,16, input.string(defval='None', options=['Long','Short','None'], title='0800-0830'))array.set(timeframes,17,'0800-0830')-array.set(timeframes_options,17, input(defval='None', options=['Long','Short','None'], title='0830-0900'))+array.set(timeframes_options,17, input.string(defval='None', options=['Long','Short','None'], title='0830-0900'))array.set(timeframes,18,'0830-0900')-array.set(timeframes_options,18, input(defval='None', options=['Long','Short','None'], title='0900-0930'))+array.set(timeframes_options,18, input.string(defval='None', options=['Long','Short','None'], title='0900-0930'))array.set(timeframes,19,'0900-0930')-array.set(timeframes_options,19, input(defval='None', options=['Long','Short','None'], title='0930-1000'))+array.set(timeframes_options,19, input.string(defval='None', options=['Long','Short','None'], title='0930-1000'))array.set(timeframes,20,'0930-1000')-array.set(timeframes_options,20, input(defval='None', options=['Long','Short','None'], title='1000-1030'))+array.set(timeframes_options,20, input.string(defval='None', options=['Long','Short','None'], title='1000-1030'))array.set(timeframes,21,'1000-1030')-array.set(timeframes_options,21, input(defval='None', options=['Long','Short','None'], title='1030-1100'))+array.set(timeframes_options,21, input.string(defval='None', options=['Long','Short','None'], title='1030-1100'))array.set(timeframes,22,'1030-1100')-array.set(timeframes_options,22, input(defval='None', options=['Long','Short','None'], title='1100-1130'))+array.set(timeframes_options,22, input.string(defval='None', options=['Long','Short','None'], title='1100-1130'))array.set(timeframes,23,'1100-1130')-array.set(timeframes_options,23, input(defval='None', options=['Long','Short','None'], title='1130-1200'))+array.set(timeframes_options,23, input.string(defval='None', options=['Long','Short','None'], title='1130-1200'))array.set(timeframes,24,'1130-1200')-array.set(timeframes_options,24, input(defval='None', options=['Long','Short','None'], title='1200-1230'))+array.set(timeframes_options,24, input.string(defval='None', options=['Long','Short','None'], title='1200-1230'))array.set(timeframes,25,'1200-1230')-array.set(timeframes_options,25, input(defval='None', options=['Long','Short','None'], title='1230-1300'))+array.set(timeframes_options,25, input.string(defval='None', options=['Long','Short','None'], title='1230-1300'))array.set(timeframes,26,'1230-1300')-array.set(timeframes_options,26, input(defval='None', options=['Long','Short','None'], title='1300-1330'))+array.set(timeframes_options,26, input.string(defval='None', options=['Long','Short','None'], title='1300-1330'))array.set(timeframes,27,'1300-1330')-array.set(timeframes_options,27, input(defval='None', options=['Long','Short','None'], title='1330-1400'))+array.set(timeframes_options,27, input.string(defval='None', options=['Long','Short','None'], title='1330-1400'))array.set(timeframes,28,'1330-1400')-array.set(timeframes_options,28, input(defval='None', options=['Long','Short','None'], title='1400-1430'))+array.set(timeframes_options,28, input.string(defval='None', options=['Long','Short','None'], title='1400-1430'))array.set(timeframes,29,'1400-1430')-array.set(timeframes_options,29, input(defval='None', options=['Long','Short','None'], title='1430-1500'))+array.set(timeframes_options,29, input.string(defval='None', options=['Long','Short','None'], title='1430-1500'))array.set(timeframes,30,'1430-1500')-array.set(timeframes_options,30, input(defval='None', options=['Long','Short','None'], title='1500-1530'))+array.set(timeframes_options,30, input.string(defval='None', options=['Long','Short','None'], title='1500-1530'))array.set(timeframes,31,'1500-1530')-array.set(timeframes_options,31, input(defval='None', options=['Long','Short','None'], title='1530-1600'))+array.set(timeframes_options,31, input.string(defval='None', options=['Long','Short','None'], title='1530-1600'))array.set(timeframes,32,'1530-1600')-array.set(timeframes_options,32, input(defval='None', options=['Long','Short','None'], title='1600-1630'))+array.set(timeframes_options,32, input.string(defval='None', options=['Long','Short','None'], title='1600-1630'))array.set(timeframes,33,'1600-1630')-array.set(timeframes_options,33, input(defval='None', options=['Long','Short','None'], title='1630-1700'))+array.set(timeframes_options,33, input.string(defval='None', options=['Long','Short','None'], title='1630-1700'))array.set(timeframes,34,'1630-1700')-array.set(timeframes_options,34, input(defval='None', options=['Long','Short','None'], title='1700-1730'))+array.set(timeframes_options,34, input.string(defval='None', options=['Long','Short','None'], title='1700-1730'))array.set(timeframes,35,'1700-1730')-array.set(timeframes_options,35, input(defval='None', options=['Long','Short','None'], title='1730-1800'))+array.set(timeframes_options,35, input.string(defval='None', options=['Long','Short','None'], title='1730-1800'))array.set(timeframes,36,'1730-1800')-array.set(timeframes_options,36, input(defval='None', options=['Long','Short','None'], title='1800-1830'))+array.set(timeframes_options,36, input.string(defval='None', options=['Long','Short','None'], title='1800-1830'))array.set(timeframes,37,'1800-1830')-array.set(timeframes_options,37, input(defval='None', options=['Long','Short','None'], title='1830-1900'))+array.set(timeframes_options,37, input.string(defval='None', options=['Long','Short','None'], title='1830-1900'))array.set(timeframes,38,'1830-1900')-array.set(timeframes_options,38, input(defval='None', options=['Long','Short','None'], title='1900-0930'))+array.set(timeframes_options,38, input.string(defval='None', options=['Long','Short','None'], title='1900-0930'))array.set(timeframes,39,'1900-0930')-array.set(timeframes_options,39, input(defval='None', options=['Long','Short','None'], title='1930-2000'))+array.set(timeframes_options,39, input.string(defval='None', options=['Long','Short','None'], title='1930-2000'))array.set(timeframes,40,'1930-2000')-array.set(timeframes_options,40, input(defval='None', options=['Long','Short','None'], title='2000-2030'))+array.set(timeframes_options,40, input.string(defval='None', options=['Long','Short','None'], title='2000-2030'))array.set(timeframes,41,'2000-2030')-array.set(timeframes_options,41, input(defval='None', options=['Long','Short','None'], title='2030-2100'))+array.set(timeframes_options,41, input.string(defval='None', options=['Long','Short','None'], title='2030-2100'))array.set(timeframes,42,'2030-2100')-array.set(timeframes_options,42, input(defval='None', options=['Long','Short','None'], title='2100-2130'))+array.set(timeframes_options,42, input.string(defval='None', options=['Long','Short','None'], title='2100-2130'))array.set(timeframes,43,'2100-2130')-array.set(timeframes_options,43, input(defval='None', options=['Long','Short','None'], title='2130-2200'))+array.set(timeframes_options,43, input.string(defval='None', options=['Long','Short','None'], title='2130-2200'))array.set(timeframes,44,'2130-2200')-array.set(timeframes_options,44, input(defval='None', options=['Long','Short','None'], title='2200-2230'))+array.set(timeframes_options,44, input.string(defval='None', options=['Long','Short','None'], title='2200-2230'))array.set(timeframes,45,'2200-2230')-array.set(timeframes_options,45, input(defval='None', options=['Long','Short','None'], title='2230-2300'))+array.set(timeframes_options,45, input.string(defval='None', options=['Long','Short','None'], title='2230-2300'))array.set(timeframes,46,'2230-2300')-array.set(timeframes_options,46, input(defval='None', options=['Long','Short','None'], title='2300-2330'))+array.set(timeframes_options,46, input.string(defval='None', options=['Long','Short','None'], title='2300-2330'))array.set(timeframes,47,'2300-2330')-array.set(timeframes_options,47, input(defval='None', options=['Long','Short','None'], title='2330-0000'))+array.set(timeframes_options,47, input.string(defval='None', options=['Long','Short','None'], title='2330-0000'))string_hour = hour<10?'0'+str.tostring(hour):str.tostring(hour)⋯        if array.get(timeframes_options, i) == 'Long'-            strategy.entry("Long", strategy.long, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 00, 00)))+            if (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 00, 00))+                strategy.entry("Long", strategy.long)        else if array.get(timeframes_options, i) == 'Short'-            strategy.entry("Short", strategy.short, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 00, 00)))+            if (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 00, 00))+                strategy.entry("Short", strategy.short)

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.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/-//@version=5+//@version=6strategy("Timeframe Time of Day and Day of Week Buying and Selling Strategy", overlay=true)⋯

Settings

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

SettingDefaultType and rangeFeeds
From Month1int · min 01 · max 12entry Long entry Short
From day1int · min 01 · max 31entry Long entry Short
From Year2021int · min 1900 · max 2100entry Long entry Short
To Month12int · min 01 · max 12close_all line 146 entry Long entry Short
To day31int · min 01 · max 31close_all line 146 entry Long entry Short
To Year2100int · min 1900 · max 2100close_all line 146 entry Long entry Short
SundaytrueboolsunFilter
MondaytrueboolmonFilter
TuedaytruebooltueFilter
WednesdaytrueboolwedFilter
ThurdaytrueboolthuFilter
FridaytrueboolfriFilter
SaturdaytrueboolsatFilter

What it calculates

No technical-analysis calculation: the script works on prices and settings directly.

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.

toyearTo Yearsetting · 2100tomonthTo Monthsetting · 12todayTo daysetting · 31timetimeprice datafromyearFrom Yearsetting · 2021frommonthFrom Monthsetting · 1fromdayFrom daysetting · 1string_hour, string_minute, _chars, start_time, end_timestring_hour · string_mi…5 valuescurrent_timecurrent_timevalue_len_lenvalue_end, _beg_end · _beg2 values_substr_substrvalue_return_returnvaluesunFilter, monFilter, tueFilter, wedFilter, thuFilter, friFilter, satFilter, dayOfWeekFiltersunFilter · monFilter +68 conditionsclose_all:close_all strategy.close_allentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entry

Order rules

OrderFires whenBy defaultLine
Close current_time == end_time and array.get(timeframes_options, i)!='None' and array.get(timeframes_options, i) != array.get(timeframes_options, i==47?0:i+1) and timestamp(toyear, tomonth, today, 00, 00)On147
Open Long long(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 00, 00))On150
Open Short short(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 00, 00))On152

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.

The live replay needs a run, and this script does not run in Zeal Terminal yet; the answer comes from the checks on the source alone.

  • 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.

Similar scripts

No other indicator or strategy here shares enough of its calculations.

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2No Pine Script v4 Error at @L127:C22: 'str.split' is not available in Pine Script v4. It was added in a later version.Not measured
PineTSNo v5 and v6 only—Not 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. PineTS runs Pine Script v5 and v6 only.

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///@version=4strategy("Timeframe Time of Day and Day of Week Buying and Selling Strategy", overlay=true)frommonth = input(defval = 1, minval = 01, maxval = 12, title = "From Month")fromday = input(defval = 1, minval = 01, maxval = 31, title = "From day")fromyear = input(defval = 2021, minval = 1900, maxval = 2100, title = "From Year")tomonth = input(defval = 12, minval = 01, maxval = 12, title = "To Month")today = input(defval = 31, minval = 01, maxval = 31, title = "To day")toyear = input(defval = 2100, minval = 1900, maxval = 2100, title = "To Year")sun = input(defval=true, title='Sunday', type = input.bool)mon = input(defval=true, title='Monday', type = input.bool)tue = input(defval=true, title='Tueday', type = input.bool)wed = input(defval=true, title='Wednesday', type = input.bool)thu = input(defval=true, title='Thurday', type = input.bool)fri = input(defval=true, title='Friday', type = input.bool)sat = input(defval=true, title='Saturday', type = input.bool)sunFilter = sun and ((dayofweek==7 and hour==23 and minute>30) or (dayofweek==1 and (hour <23 or (hour == 23 and minute<=30))))monFilter = mon and ((dayofweek==1 and hour==23 and minute>30) or (dayofweek==2 and (hour <23 or (hour == 23 and minute<=30))))tueFilter = tue and ((dayofweek==2 and hour==23 and minute>30) or (dayofweek==3 and (hour <23 or (hour == 23 and minute<=30))))wedFilter = wed and ((dayofweek==3 and hour==23 and minute>30) or (dayofweek==4 and (hour <23 or (hour == 23 and minute<=30))))thuFilter = thu and ((dayofweek==4 and hour==23 and minute>30) or (dayofweek==5 and (hour <23 or (hour == 23 and minute<=30))))friFilter = fri and ((dayofweek==5 and hour==23 and minute>30) or (dayofweek==6 and (hour <23 or (hour == 23 and minute<=30))))satFilter = sat and ((dayofweek==6 and hour==23 and minute>30) or (dayofweek==7 and (hour <23 or (hour == 23 and minute<=30))))dayOfWeekFilter = sunFilter or monFilter or tueFilter or wedFilter or thuFilter or friFilter or satFiltertimeframes = array.new_string(48, '')timeframes_options = array.new_string(49, 'None')array.set(timeframes,0,'2330-0000')array.set(timeframes_options,0, input(defval='None', options=['Long','Short','None'], title='0000-0030'))array.set(timeframes,1,'0000-0030')array.set(timeframes_options,1, input(defval='None', options=['Long','Short','None'], title='0030-0100'))array.set(timeframes,2,'0030-0100')array.set(timeframes_options,2, input(defval='None', options=['Long','Short','None'], title='0100-0130'))array.set(timeframes,3,'0100-0130')array.set(timeframes_options,3, input(defval='None', options=['Long','Short','None'], title='0130-0200'))array.set(timeframes,4,'0130-0200')array.set(timeframes_options,4, input(defval='None', options=['Long','Short','None'], title='0200-0230'))array.set(timeframes,5,'0200-0230')array.set(timeframes_options,5, input(defval='None', options=['Long','Short','None'], title='0230-0300'))array.set(timeframes,6,'0230-0300')array.set(timeframes_options,6, input(defval='None', options=['Long','Short','None'], title='0300-0330'))array.set(timeframes,7,'0300-0330')array.set(timeframes_options,7, input(defval='None', options=['Long','Short','None'], title='0330-0400'))array.set(timeframes,8,'0330-0400')array.set(timeframes_options,8, input(defval='None', options=['Long','Short','None'], title='0400-0430'))array.set(timeframes,9,'0400-0430')array.set(timeframes_options,9, input(defval='None', options=['Long','Short','None'], title='0430-0500'))array.set(timeframes,10,'0430-0500')array.set(timeframes_options,10, input(defval='None', options=['Long','Short','None'], title='0500-0530'))array.set(timeframes,11,'0500-0530')array.set(timeframes_options,11, input(defval='None', options=['Long','Short','None'], title='0530-0600'))array.set(timeframes,12,'0530-0600')array.set(timeframes_options,12, input(defval='None', options=['Long','Short','None'], title='0600-0630'))array.set(timeframes,13,'0600-0630')array.set(timeframes_options,13, input(defval='None', options=['Long','Short','None'], title='0630-0700'))array.set(timeframes,14,'0630-0700')array.set(timeframes_options,14, input(defval='None', options=['Long','Short','None'], title='0700-0730'))array.set(timeframes,15,'0700-0730')array.set(timeframes_options,15, input(defval='None', options=['Long','Short','None'], title='0730-0800'))array.set(timeframes,16,'0730-0800')array.set(timeframes_options,16, input(defval='None', options=['Long','Short','None'], title='0800-0830'))array.set(timeframes,17,'0800-0830')array.set(timeframes_options,17, input(defval='None', options=['Long','Short','None'], title='0830-0900'))array.set(timeframes,18,'0830-0900')array.set(timeframes_options,18, input(defval='None', options=['Long','Short','None'], title='0900-0930'))array.set(timeframes,19,'0900-0930')array.set(timeframes_options,19, input(defval='None', options=['Long','Short','None'], title='0930-1000'))array.set(timeframes,20,'0930-1000')array.set(timeframes_options,20, input(defval='None', options=['Long','Short','None'], title='1000-1030'))array.set(timeframes,21,'1000-1030')array.set(timeframes_options,21, input(defval='None', options=['Long','Short','None'], title='1030-1100'))array.set(timeframes,22,'1030-1100')array.set(timeframes_options,22, input(defval='None', options=['Long','Short','None'], title='1100-1130'))array.set(timeframes,23,'1100-1130')array.set(timeframes_options,23, input(defval='None', options=['Long','Short','None'], title='1130-1200'))array.set(timeframes,24,'1130-1200')array.set(timeframes_options,24, input(defval='None', options=['Long','Short','None'], title='1200-1230'))array.set(timeframes,25,'1200-1230')array.set(timeframes_options,25, input(defval='None', options=['Long','Short','None'], title='1230-1300'))array.set(timeframes,26,'1230-1300')array.set(timeframes_options,26, input(defval='None', options=['Long','Short','None'], title='1300-1330'))array.set(timeframes,27,'1300-1330')array.set(timeframes_options,27, input(defval='None', options=['Long','Short','None'], title='1330-1400'))array.set(timeframes,28,'1330-1400')array.set(timeframes_options,28, input(defval='None', options=['Long','Short','None'], title='1400-1430'))array.set(timeframes,29,'1400-1430')array.set(timeframes_options,29, input(defval='None', options=['Long','Short','None'], title='1430-1500'))array.set(timeframes,30,'1430-1500')array.set(timeframes_options,30, input(defval='None', options=['Long','Short','None'], title='1500-1530'))array.set(timeframes,31,'1500-1530')array.set(timeframes_options,31, input(defval='None', options=['Long','Short','None'], title='1530-1600'))array.set(timeframes,32,'1530-1600')array.set(timeframes_options,32, input(defval='None', options=['Long','Short','None'], title='1600-1630'))array.set(timeframes,33,'1600-1630')array.set(timeframes_options,33, input(defval='None', options=['Long','Short','None'], title='1630-1700'))array.set(timeframes,34,'1630-1700')array.set(timeframes_options,34, input(defval='None', options=['Long','Short','None'], title='1700-1730'))array.set(timeframes,35,'1700-1730')array.set(timeframes_options,35, input(defval='None', options=['Long','Short','None'], title='1730-1800'))array.set(timeframes,36,'1730-1800')array.set(timeframes_options,36, input(defval='None', options=['Long','Short','None'], title='1800-1830'))array.set(timeframes,37,'1800-1830')array.set(timeframes_options,37, input(defval='None', options=['Long','Short','None'], title='1830-1900'))array.set(timeframes,38,'1830-1900')array.set(timeframes_options,38, input(defval='None', options=['Long','Short','None'], title='1900-0930'))array.set(timeframes,39,'1900-0930')array.set(timeframes_options,39, input(defval='None', options=['Long','Short','None'], title='1930-2000'))array.set(timeframes,40,'1930-2000')array.set(timeframes_options,40, input(defval='None', options=['Long','Short','None'], title='2000-2030'))array.set(timeframes,41,'2000-2030')array.set(timeframes_options,41, input(defval='None', options=['Long','Short','None'], title='2030-2100'))array.set(timeframes,42,'2030-2100')array.set(timeframes_options,42, input(defval='None', options=['Long','Short','None'], title='2100-2130'))array.set(timeframes,43,'2100-2130')array.set(timeframes_options,43, input(defval='None', options=['Long','Short','None'], title='2130-2200'))array.set(timeframes,44,'2130-2200')array.set(timeframes_options,44, input(defval='None', options=['Long','Short','None'], title='2200-2230'))array.set(timeframes,45,'2200-2230')array.set(timeframes_options,45, input(defval='None', options=['Long','Short','None'], title='2230-2300'))array.set(timeframes,46,'2230-2300')array.set(timeframes_options,46, input(defval='None', options=['Long','Short','None'], title='2300-2330'))array.set(timeframes,47,'2300-2330')array.set(timeframes_options,47, input(defval='None', options=['Long','Short','None'], title='2330-0000'))string_hour = hour<10?'0'+tostring(hour):tostring(hour)string_minute = minute<10?'0'+tostring(minute):tostring(minute)current_time = string_hour+string_minutef_strLeft(_str, _n) =>    string[] _chars = str.split(_str, "")    int _len = array.size(_chars)    int _end = min(_len, max(0, _n))    string[] _substr = array.new_string(0)    if _end <= _len        _substr := array.slice(_chars, 0, _end)    string _return = array.join(_substr, "")f_strRight(_str, _n) =>    string[] _chars = str.split(_str, "")    int _len = array.size(_chars)    int _beg = max(0, _len - _n)    string[] _substr = array.new_string(0)    if _beg < _len        _substr := array.slice(_chars, _beg, _len)    string _return = array.join(_substr, "")for i = 0 to array.size(timeframes) - 1    start_time = f_strLeft(array.get(timeframes, i), 4)    end_time = f_strRight(array.get(timeframes, i), 4)        if current_time == end_time and array.get(timeframes_options, i)!='None' and array.get(timeframes_options, i) != array.get(timeframes_options, i==47?0:i+1) and timestamp(toyear, tomonth, today, 00, 00)        strategy.close_all()    if current_time == start_time and dayOfWeekFilter and array.get(timeframes_options, i)!='None' and array.get(timeframes_options, i) != array.get(timeframes_options, i==0?47:i-1)        if array.get(timeframes_options, i) == 'Long'            strategy.entry("Long", strategy.long, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 00, 00)))        else if array.get(timeframes_options, i) == 'Short'            strategy.entry("Short", strategy.short, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 00, 00)))