| 
 PureBytes Links 
Trading Reference Links 
 | 
Hello,
The error is in the MatriceMMA function but AB will not report an 
error unless you call the function.
As an example of what I mean:
This snippet contains syntax error but checking it with 'verify 
syntax' will OK it:
function test( a )
{
  x = 0;
  if( a > C ) x = 1;// <-- error!
  return x;
}
but if I add a function call:
function test( a )
{
  x = 0;
  if( a > C ) x = 1;// <-- error!
  return x;
}
test( 45 );
the error will be reported.
The error you made is in this line, MMA[ i ]  =  MA( f, Duree );
The left hand side is an array *element* , the right is an array, 
thus the type mismatch error.
Try this for the MatriceMMA function:
function MatriceMMA( ListNum, Index, Duree )
{
  Liste = CategoryGetSymbols( categoryWatchlist, ListNum );
  for( i = nb = 0; ( Sym = StrExtract( Liste, i ) ) != ""; i++ )
    {
      f = Foreign( Sym, "C" );
      MMA = MA( f, Duree );
      nb = nb + ( f > MMA );
    }
  f = Foreign( Index, "C" );
  MMAInd = MA( f, Duree );
  nb = nb + ( f > MMAInd );
  return nb / ( i + 1 ) * 100;
}
Johan
--- In amibroker@xxxxxxxxxxxxxxx, Bernard Bourée <bernard@xxxx> 
wrote:
> I have the following Indicator which call an include file.
> When checking the syntax in the Fonctions.afl, I get no error.
> When I check it on my indicator I get the following error:
> Line 1, Col:659:Error 8
> Error 8. Type mismatch, the value assigned to the array element 
has to 
> be a number. You can not use array on the right-side of this 
assignment.
> 
> Can someone help me to find where the error is ?
> ========================
> #include <Fonctions.afl>
> periods = Param("Periods", 20, 1, 200, 1 );
> WL=Param("WatchList number",0,0,63,1);
> Indice=ParamStr("Ticker","^FCHI");
> Plot( MatriceMMA(WL,Indice, periods), _DEFAULT_NAME(), ParamColor( 
> "Color", colorCycle ), ParamStyle("Style")  );
> ============================
> The file Fonctions.afl contains the following function
> function MatriceMMA( ListNum, Index, Duree )
> {
>     Liste = CategoryGetSymbols( categoryWatchlist, ListNum );
>    MMA[0] = 0; // just in case there are no watch list members
>     Nb=0;
>     for( i = 0; ( Sym = StrExtract( Liste, i ) ) != ""; i++ )
>    {
>           f = Foreign( Sym, "C" );
>          MMA[i] = MA(f,Duree);
>         if (f>MMA[i]) nb=nb+1;
>     }
>     f = Foreign( Index, "C" );
>     MMAInd=MA(F,Duree);
>     if(f>MMAInd) nb=nb+1;
>    
>    return nb/(i+1)*100; 
>    
> }
> 
> 
> 
> -- 
> Bernard Bourée
> bernard@xxxx
> Mob: +33 6 09 11 05 91
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com
For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links
<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 
 |