Out of range access, was: How to initialize array?

TTMColor = 0;
TTMColor[0] = 0;
2020-06-19_12-38-36

why TTMColor[0] has error?

if I enclosed it in a function why it works?

function fun_name( arg1, arg2 )
{
TTMColor = 0;
TTMColor[0] = 0;
return result;
}

2020-06-19_13-32-27

Also I have issue with #include line
Why it error as array?
Error 10. Subscript out of range. You must not access array elements outside 0..(BarCount-1) range

Error 10. Subscript out of range. You must not access array elements outside 0..(BarCount-1) range

Why don't you just hit F1 key in AmiBroker or double click on the error line?

It will display you ALL explanations you need and won't need to ask for help.
This looks like you were running on symbol with no quotes.
You should always check the BarCount:
http://www.amibroker.com/kb/2014/09/22/do-not-make-assumptions-on-number-of-bars/

and you should never access bars outside 0...(BarCount-1) range as error says.

Thank you for fast response. I think the problem I found is that "I am running on symbol with no quotes" as you suspect.

But How would I know which symbol the system is selecting to debug? Because I can open chart just fine?

Hi.
why don't you just put the Name() variable to test in the watch window when using debug? it is very simple.

CurSymbol = Name();

From what i understand, it depends on the current selected chart or the symbol that appears in the ticker dropdown.
You can also set the chart interval to be used from Preferences.