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

Re: [amibroker] Function call Question



PureBytes Links

Trading Reference Links

Robert,

This line in your plugin causes problems:
for (i=BarIndex(); i<BarIndex()-100 OR i<1; i--)

because BarIndex() returns ARRAY of numbers.

for loop needs a single number for STARTING point
and single value for ENDING point. And then it will
iterate from starting point to ending point.

Correct for example is:
for( i = 0; i < BarCount; i++ )


Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "Robert Nemeth" <rjnemeth@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Wednesday, July 09, 2003 6:08 PM
Subject: [amibroker] Function call Question


> I need to know something simple, like how to call a
> function. I have written a function to replace
> troughbars that will work with negative numbers and
> not look into the future. I now get an error where I
> try to call the function.
> 
> I try to get the returned value with:
> FReturn=0;
> FReturn=  TrBars(C0,30,2);
> 
> Then in a buy statement I use:
> AND HHV(C0,FReturn)<0
> 
> The function looks like this:
> function TrBars(I1,ChgAmount,Nodes)
> {
>  TrCnt=0; 
>  TrBars=0;
>  for (i=BarIndex(); i<BarIndex()-100 OR i<1; i--)
>   {  
>    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 (i=BarIndex();i<BarIndex()-100 OR i<1; i--)
>  {
>   if (AfterTr[i]==1)
>      TrCnt=TrCnt+1;
>   TrBars=TrBars+1;
>   if (TrCnt==Nodes)
>     i=0 ;
>  }
>  return TrBars;
> }
> 
> This is my first try at functions so any hints and
> suggestions would be appreciated.
> 
> Robert
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
> 
> 
> 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/ 
> 
> 
> 

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Coral Calcium for Greater Health - $23.95
http://www.challengerone.com/t/l.asp?cid=2805&lp=calcium2.asp
http://us.click.yahoo.com/MmkSQC/NTVGAA/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/