Timestamp feature
Posted: Fri Aug 06, 2021 2:37 am
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)
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)