[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Function Call passed variables question



PureBytes Links

Trading Reference Links

I have tuned up my function but gat a "Type mismatch"
in Explore & Plot. I get "Syntax" error when enabling
the Buy/Sell lines.

My question is what gets passed to and returned from a
function?

Example 1 in ReadMe file has:
passed to = "Close" array
Returned from = array of smoothed close

I think the code shown below has:
passed to = indicator array
return from = number of bars back for indicator dip &
recover as array

I'm wondering if the type mismatch is on the passed to
or return data from the function. Can HHV pick out the
current days value to use as DaysBack parameter?

Here is the code that can be run in
explore/indicator/backtest but it is not necessary if
someone can give me direction in my confusion.

C0=CCI(14);

/* Functions*/
function TrBars(I1,ChgAmount,Nodes)
/* Return number of bars since number of troughs ago
*/
/* Zero returned if requested trough not found */
{
 TrCnt=0;     //Trough count
 TrBar[0]=0; //First couple of bars initialize
 TrBar[1]=0; //Bars since trough variable
 for (i=2; i<BarCount; i++) //Check for trough of
specified magnitude
  {  
   AfterTR[i]=(I1[i]>Ref(I1[i],-1) AND
Ref(I1[i],-1)<Ref(I1[i],-2) AND 
I1[i]-Ref(I1[i],-1)>=ChgAmount AND
Ref(I1[i],-2)-Ref(I1[i],-1)>=ChgAmount); //Flag set
one period after low which meets criteria
  }

for (k=2; k<BarCount; k++) //Loop through all bars in
chart
{
 TrCnt=0; 
 TrBar[k]=0;
   for (i=k;i<1; i--)     // Find specified trough to
save count of days since
    {
     if (AfterTr[i]==1)
      TrCnt=TrCnt+1;
     TrBar[k]=TrBar[k]+1;
     if (TrCnt==Nodes)  //Did we find the requested
trough?
     i=0 ;
    }
   if (TrCnt!=Nodes)   //In case we don't find trough
and run out of data
     TrBar[k]=0 ;
}
 return TrBar;
}

//buy=HHV(C0,TrBars(C0,30,2))<0 and
llV(C0,TrBars(C0,30,2)<100;
//Sell=C>200;

Filter=1;
AddColumn(TrBars(C0,30,2),"Troughbar",6.0); //Type
mismatch this line in EXPLORE
plot(TrBars(C0,30,2),"TRBAR",colorred);

Robert



__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy 1, Get 1 FREE
Control Cravings & Hunger EZ! Fast Acting Natural Oral Spray - $19.97
http://www.challengerone.com/t/l.asp?cid=2866&lp=ezappetite3.html
http://us.click.yahoo.com/rJIe0D/99VGAA/ySSFAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/