mrrichardtodd
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: July 29th, 2021

Timestamp feature

Hello everyone

So ive recently completed the basic course and now am happy playing away with different scripts. The below script i have for using the timestamp and to select a large range for my back testing. Any advice on this would be great as without using this timestamp my backtesting doesnt go back to far on smaller time periods like 5m candles. Any advice to increase backtesting to get more trades would be great

//Setting date and time
i_startTime = input (defval = timestamp("01 Jan 2015 08:00 +0000"), title = "Start Time", type = input.time)
i_endTime = input (defval = timestamp("01 Aug 2021 08:00 +0000"), title = "End Time", type = input.time)
i_length = input (defval = 20, title = "Length", type = input.integer)

inDateRange = time >= i_startTime and time <= i_endTime
inCondition = not na(close[i_length])

hh = highest(high, i_length)
ll = lowest(low, i_length)

if (inCondition and inDateRange)
strategy.entry("Go Long", strategy.long, when = long, stop = hh)
strategy.exit("Long Exit", "Go Long", profit = close * + 0.04 / syminfo.mintick, loss = close * 0.04/ syminfo.mintick)

Return to “Pine Script Q&A”