error message: 'the study references too many candles in history (5235)'

Viewed 58

I am trying to solve this error couple of months I will be very thankful if you help me with that and guide where the problem could be

if confirm9E

mark_long  = 0
mark_short = 0

for i=0 to 9

    if transport_buy[i]
        mark_long  := 1

    if transport_sell[i]
        mark_short := 1

if not mark_long
    final_long_backtest:=0

if not mark_short
    final_short_backtest:=0

when I turn on the "confirm9E" I get that error

1 Answers

With for loops you will usually run into this issue.

Your script will be executed on each bar and when it is being executed for the first few bars, you won't have any historical data to access to in your for loop.

If you want to check if transport_buy was true within the last 10 bars, you can either use a counter or use ta.barssince().

mark_long = ta.barssince(transport_buy) > 10
Related