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

[amibroker] Re: Tips for reducing CPU load



PureBytes Links

Trading Reference Links



Nice example Bruce - compact and powerful!

Here's my riff on it to add multiple calculations and color:

/*
   Osc_Pctl_02.afl

   Finds *for every bar* which was the value of Osc(x) that was exceeded for a
   limit % number of times over a percentile lookback period.

   e.g.:  On this bar, what is the value of Osc(14) which was exceeded 5% of the time over the last 100 bars

   "For each bar in an array, find the value of Osc(x) over a lookback period that represents
   a given percentile rank of the min/max range over the same lookback period."

   Versions

   _01       Bruce R      http://finance.groups.yahoo.com/group/amibroker/message/142760

   _02         Progster      progster@xxxxxxxxxxxxxxxxxx

   Separated high/low percentile specification settings, made percentile lookback explicit in bars,
   changed variable names, added color, added 2nd calc (CCI) and 3rd calc (ADX).
                     
   
*/


Osc_LB = Param( "Osc_LB", 14, 1, 200, 1 );            //   Oscillator LookBack
LowPctl = Param( "LowPctl", 5, 1, 100, 1 );
HighPctl = Param( "HighPctl", 95, 1, 100, 1 );
Pctl_LB = Param( "Pctl_LB", 50, 50, 5000, 50 );         //   Percentile LookBack

ShowPctlSpecs= ParamToggle( "ShowPctlSpecs?", "No|Yes", 0 ) ;   //   turn on morestuff in the display for tutorial/verification purposes


//  Ceil() and Floor() below are used to generate "nearest integer" values

Calc_01 = RSI( Osc_LB );
ValAtLowPctl_01 = ceil( Percentile( Calc_01, Pctl_LB, LowPctl ) );
ValAtHighPctl_01 = floor( Percentile( Calc_01, Pctl_LB, HighPctl ) );

Calc_02 = CCI( Osc_LB );
ValAtLowPctl_02 = ceil( Percentile( Calc_02, Pctl_LB, LowPctl ) );
ValAtHighPctl_02 = floor( Percentile( Calc_02, Pctl_LB, HighPctl ) );

Calc_03 = ADX( Osc_LB );
ValAtLowPctl_03 = ceil( Percentile( Calc_03, Pctl_LB, LowPctl ) );
ValAtHighPctl_03 = floor( Percentile( Calc_03, Pctl_LB, HighPctl ) );


Filter = 1;

if (ShowPctlSpecs) {   
   AddColumn( BarIndex(), "Bar", 8.0, colorDefault, colorDefault, 50 );
   AddColumn( LowPctl, "LowPctl", 2.0, colorDefault, colorDefault, 50 );
}

if (ShowPctlSpecs) {      AddColumn( ValAtLowPctl_01, "ValAtLP", 5.1, colorDefault, colorDefault, 60 );   }
AddColumn(Calc_01, "RSI", 6.2, colorDefault, IIf( Calc_01 >= ValAtHighPctl_01,colorGreen, IIf(Calc_01 <= ValAtLowPctl_01, colorRed, colorDefault)), 50) ;
if (ShowPctlSpecs) {      AddColumn( ValAtHighPctl_01, "ValAtHP", 5.1, colorDefault, colorDefault, 60 );   }

if (ShowPctlSpecs) {      AddColumn( ValAtLowPctl_02, "ValAtLP", 5.1, colorDefault, colorDefault, 60 );   }
AddColumn(Calc_02, "CCI", 6.2, colorDefault, IIf( Calc_02 >= ValAtHighPctl_02,colorGreen, IIf(Calc_02 <= ValAtLowPctl_02, colorRed, colorDefault)), 50) ;
if (ShowPctlSpecs) {      AddColumn( ValAtHighPctl_02, "ValAtHP", 5.1, colorDefault, colorDefault, 60 );   }

if (ShowPctlSpecs) {      AddColumn( ValAtLowPctl_03, "ValAtLP", 5.1, colorDefault, colorDefault, 60 );   }
AddColumn(Calc_03, "ADX", 6.2, colorDefault, IIf( Calc_03 >= ValAtHighPctl_03,colorGreen, IIf(Calc_03 <= ValAtLowPctl_03, colorRed, colorDefault)), 50) ;
if (ShowPctlSpecs) {      AddColumn( ValAtHighPctl_03, "ValAtHP", 5.1, colorDefault, colorDefault, 60 );   }

if (ShowPctlSpecs) {   
   AddColumn( HighPctl, "HighPctl", 2.0, colorDefault, colorDefault, 58 );
}

Pictures of the output, and code that can be cut/pasted cleanly have been posted in the CFT Forum at 

http://www.codefortraders.com/phpBB3/viewtopic.php?f=60&t=605





__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___