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

Re: [amibroker] Re: Is there an easier way?



PureBytes Links

Trading Reference Links

Dimitris,

Nice but still for loop is shorter especially when there
are more ranges to scan.

Once can of course use your ROC() approach to shorten even for loop.
Whats more for loop makes it possible to parametrize:

startl = Param("Lookback start", 16, 1, 100, 1 );
endl = Param("Lookback end", 30, 1, 100, 1 );

SumChange = 0;
for( lookback = startl; lookback <= endl; lookback++ )
{
   Change = ROC( Close, -lookback );
   SumChange = ( Change > 0 ) - ( Change < 0 );
 }


Best regards,
Tomasz Janeczko
amibroker.com


----- Original Message ----- 
From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Monday, April 21, 2003 9:24 PM
Subject: [amibroker] Re: Is there an easier way?


> Eugene,
> Your variable
> x16=IIf(C>Ref(C,-16),1,IIf(C==Ref(C,-16),0,-1));
> is equivalent to the 
> x16A=(ROC(C,16)>0)-(ROC(C,16)<0);
> Your sum (x16+x17+x18+x19) is equivalent to the (x16A+x17A+x18A+x19A) 
> and it is
> S=(ROC(C,16)>0)-(ROC(C,16)<0)+
> (ROC(C,17)>0)-(ROC(C,17)<0)+
> (ROC(C,18)>0)-(ROC(C,18)<0)+
> (ROC(C,19)>0)-(ROC(C,19)<0);
> If you need it, it is not that complicated !!
> Note that S is a daily function and you may use it in IB
> 
> S=(ROC(C,16)>0)-(ROC(C,16)<0)+
> (ROC(C,17)>0)-(ROC(C,17)<0)+
> (ROC(C,18)>0)-(ROC(C,18)<0)+
> (ROC(C,19)>0)-(ROC(C,19)<0);
> Plot(S,"My sum",4,8);
> 
> or in AA
> 
> S=(ROC(C,16)>0)-(ROC(C,16)<0)+
> (ROC(C,17)>0)-(ROC(C,17)<0)+
> (ROC(C,18)>0)-(ROC(C,18)<0)+
> (ROC(C,19)>0)-(ROC(C,19)<0);
> Filter=S>=3;
> AddColumn...
> 
> Dimitris Tsokakis
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx> 
> wrote:
> > Hello,
> > 
> > Using most latest betas (4.31.x or higher) you can use this code:
> > 
> > SumChange = 0;
> > for( lookback = 16; lookback <= 20; lookback++ )
> > {
> >    Change = Close - Ref( Close, -lookback );
> > 
> >    SumChange = IIF( Change > 0, 1,
> >                          IIF( Change < 0, -1, 0 ) );
> > }
> > 
> > 
> > 
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> > ----- Original Message ----- 
> > From: "Eugene" <johngalt1234@xxxx>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Monday, April 21, 2003 6:04 PM
> > Subject: [amibroker] Is there an easier way?
> > 
> > 
> > > I am working with a mutual fund and am trying the following:
> > > 
> > > iif(close>ref(c,-16),1,iif(c=ref(c,-16),0,-1))
> > > 
> > > am comparing the close today to the close 16 days earlier and
> > > assigning a +1 if it is greater, 0 if it is equal and -1 if it is 
> lower.
> > > 
> > > I want to compare todays price with the price 16,17,18,19 and 20 
> days
> > > earlier. and repeat the same with prices for the preceeding 5 
> days.
> > > and sum all the values obtained. 
> > > 
> > > Not being a programmer, I see that I have to write a lot of 
> lines. Is
> > > there a simpler way?
> > > 
> > > TIA
> > > 
> > > 
> > > 
> > > 
> > > Send BUG REPORTS to bugs@xxxx
> > > Send SUGGESTIONS to suggest@xxxx
> > > -----------------------------------------
> > > 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/ 
> > > 
> > > 
> > >
> 
> 
> 
> 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 ---------------------~-->
Make Money Online Auctions! Make $500.00 or We Will Give You Thirty Dollars for Trying!
http://us.click.yahoo.com/yMx78A/fNtFAA/i5gGAA/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/