p:: Programming Language
//@version=5
strategy("Strategy", overlay = true, initial_capital = 1000, default_qty_type = strategy.cash, default_qty_value = 100)
// === INPUT BACKTEST RANGE ===
fromMonth = input.int(defval = 12, title = "From Month", minval = 1, maxval = 12)
fromDay = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)
fromYear = input.int(defval = 2022, title = "From Year", minval = 1970)
thruMonth = input.int(defval = 12, title = "Thru Month", minval = 1, maxval = 12)
thruDay = input.int(defval = 31, title = "Thru Day", minval = 1, maxval = 31)
thruYear = input.int(defval = 2022, title = "Thru Year", minval = 1970)
// === FUNCTION EXAMPLE ===
start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start window
finish = timestamp(thruYear, thruMonth, thruDay, 23, 59) // backtest finish window
window() => time >= start and time <= finish ? true : false // create function "within window of time"
if (window())
strategy.entry("ID", strategy.long)
strategy.close("ID")