Alert not displaying after for loop

 

I am stuck with a very weird problem. I have the following script:


double value[10];
int i=0;
  
void OnStart()
{
  
  //double max;
  for(i=0;i<=10;i++)
   value[i]=(iCustom(NULL,0,"Traders_Dynamic_Index",13,0,24,2,0,7,0,2,i));

  

  Alert(value[ArrayMaximum(value,WHOLE_ARRAY,0)]);
  
  
}

What i want is to see the maximum value of the custom indicator in the last 20 candles and display it.  But when I am running this code the Alert doesnt pop up.


When I do this:

double value[10];
int i=0;
  
void OnStart()
{
  
  //double max;
  for(i=0;i<=10;i++)
  {
   value[i]=(iCustom(NULL,0,"Traders_Dynamic_Index",13,0,24,2,0,7,0,2,i));
   Alert(value[ArrayMaximum(value,WHOLE_ARRAY,0)]);
  }

}

The alert pops out. Can someone tell me what I am doing wrong?

 

I quote

"Without curly braces, only the first statement following the loop definition is considered to belong to the loop body."- A guy from Stack Overflow


then,

What i want is to see the maximum value of the custom indicator in the last 20 candles and display it.

You are saying that you want to measure last 20 candles? but you are counting from candles 0 to 10. How would you expect to measure last 20 candles?


Maybe you should read more about:

CHART_FIRST_VISIBLE_BAR.




Reason: