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

Re: [amibroker] Re: Question about LinearReg



PureBytes Links

Trading Reference Links

Hi all,

This is what i have so far.  When I have these two filters together, AB takes a long time to scan through entire database.  So i had to separate them into two different scans.  I first filter the stocks based on my criteria and then apply my own linreg scan.  Is there a more efficient way to do this in one simple code? Like filtering and then copy results into watchlist (list 0) and overwriting every time I run it.

thank you for your time

tony
qitrader

//*Filtering
Filter = Close > 10 AND V >= 500000 AND EMA (V, 30) >= 300000 AND ATR (15) >= 1.2;
ATR15 = ATR (15);
EMA30 = EMA (V, 30);AddColumn (C, "Close");
AddColumn (V, "Volume");
AddColumn (ATR15, "Average True Range");
AddColumn (EMA30, "30 Day Average Volume");
//*
//*LinReg Scan

LinRegVal = LinearReg ( Close, 3 ) ;
LinRegChanVal=LinearReg (Close, 23);
LinRegChanSlope = LinRegSlope (Close, 23);

SDev=StDev (Close,23);
LowerLinRegChanVal=LinRegChanVal-.85*SDev;
UpperLinRegChanVal=LinRegChanVal+.85*SDev;

Cond1 = LinearReg(Close,3) > Ref(LinearReg(Close,3),-1) AND LinRegSlope(Close,23) >= 0 AND Close < LowerLinRegChanVal;

Cond2 = LinearReg(Close,3) < Ref(LinearReg(Close,3),-1) AND LinRegSlope(Close,23) <= 0 AND Close > UpperLinRegChanVal;

Filter = Cond1 OR Cond2;

Buy = Cond1;
Short = Cond2;

ATR15 = ATR (15);
EMA30 = EMA (V, 30);
AddColumn (C, "Close");
AddColumn( Buy, "Buy", 1, colorDefault, IIf( Cond1 == 1, colorGreen, Null ) );
AddColumn( Short, "Short", 1, colorDefault, IIf( Cond2 == 1, colorRed, Null ) );
AddColumn (V, "Volume");
AddColumn (ATR15, "Average True Range");
AddColumn (EMA30, "30 Day Average Volume");
//*


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