Index is an array with CLOSE prices of NDX symbol (ticker)
IndexMAoptimized would be a number from 1...12 while running optimizer, default to 1
IndexMA is a simple moving average (SMA) of Index and this number 1...12.
Is awkward to optimize a SMA from 1 ... but ... not my code
Using a more descriptive title for the original post will help draw attention from the experts you are looking for. Include the development platform the code will run in. This appears to AmiBroker code. If it is, there is already a very active AmiBroker thread. Post the question there.