0

How to access next candles data in trading view by using pine script. For example access historical close price in pine we use close[1],close[2],close[3],close[4],close[5] what I am looking for is opposite of this.

For me to test efficiency of strategy need to find candles close price which hit target without hitting stop lose. For example how to find a entry candle whose close price will rise up 5% without hit 2% stop loss for long position and down 5% without hit 2% stop loss for short position.

Jake
  • 155
  • 4
  • 14

1 Answers1

0

You cannot access future data.

You should start from somewhere and see what happens after that candle.

In your case, if close[5] is your entry, then close[4], is your "next" candle.

So, figure out where your entry is, then start your calculations after that candle.

vitruvius
  • 15,740
  • 3
  • 16
  • 26
  • And how do I make close[5] is my entry? I would prefer to make realtime/last history bar make my entry and iterate all over the series to identify swing bars - how do I do that ? Thank you – Arregator Nov 01 '22 at 11:32
  • 5 is just a random number. The important thing here is knowing the entry bar index. – vitruvius Nov 01 '22 at 13:35