0

Can anyone guide me on what code I can use in PineEditor to change the time the daily candle opens and close in TradingView?

Instead of my trades being executed and backtested on candle close that is closed in standard 00:00 UTC I want my daily candles to open/close at 05:00 AM UTC instead.



I want to keep it simple, here is the script I want to add this to:


default_qty_type=strategy.percent_of_equity)


// TIMESTAMP input - to choose strategy testing timeframe
i_startTime = input(defval = timestamp("20 Mar 2020 00:00 +0000"), title = "Start Time", type = input.time)
i_endTime = input(defval = timestamp("01 Jan 2023 00: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)


// compute the indicators
smaInput = input(title="SMA", type=input.integer, defval=1)
indicator1 = sma(close,smaInput)



// plot the indicators
plot(indicator1, title="Indicator1", color=color.red, linewidth=2)



// Trading Logic

EnterLong = crossover(close,indicator1) 
ExitLong = crossunder(close,indicator1) 


// Execution Logic - Placing Orders
if (inCondition and inDateRange)
    strategy.entry("LONG", strategy.long, when=EnterLong)
    strategy.close("LONG", when=ExitLong)
    
// Background color backtesting period
bgcolor(inDateRange ? color.green : na, 90)
Rafal
  • 37
  • 1
  • 11

0 Answers0