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

[amibroker] Stock Specific Indicator Settings



PureBytes Links

Trading Reference Links





I've being working with our more recent 
features of StrExtract and StrToNum functions and have come up with what I think 
are some Novel uses.  This is the first post of several describing these 
uses.  These AFL examples are my stepping stones toward some more advanced 
uses of this concept.
This example shows how we can set 
up Stock specific indicator settings.  Below I've borrowed the 
StochRSI and modified it so that we can set the "Period" and "Smooth" 
factors automatically for a list of tickers.  When one of these tickers is 
displayed, your settings are automatically applied.  If a ticker is not in 
that list, default values are used (in this case variable by use of Param 
function).  The list is a comma separated list built by the 
addition in order of Ticker, Period value,Smooth value ( <FONT 
face="Times New Roman" color=#008000>"Ticker1,Period1,Smooth1,Ticker2,period2 
...etc ).  This list can be modified on the 
Fly from within the Indicator Window,  by just right mouse click -> edit 
formula -> then add new "....Ticker,Period,Smooth" to the end of your 
list.  This concept can easily be modified for any indicator with user 
defined values.
Enjoy, and watch for those line 
wraps.  
Andrew
ps. I'm sure its obvious but if your 
not using Australian Tickers, change the CustomStochRSIList to reflect your 
own.
  
// Stock Specific StochRSI settings - by Andrew Perrin.
// This AFL allows user defined settings to be automatically applied to 
selected Tickers.
// Build custom list - "Ticker1,Period1,Smooth1,Ticker2,period2 
...etc
CustomStochRSIList = <FONT face="Courier New" color=#ff00ff 
size=1>"NAB,25,2,ANZ,40,5,CBA,6,2,NCPDP,40,15"<FONT face="Courier New" 
size=1>;
Period = <FONT face="Courier New" color=#0000ff 
size=1>Param(<FONT 
face="Courier New" color=#ff00ff size=1>"Periods"<FONT face="Courier New" 
size=1>,33<FONT 
face="Courier New" size=1>,<FONT face="Courier New" color=#ff00ff 
size=1>5,<FONT face="Courier New" 
color=#ff00ff size=1>40,<FONT 
face="Courier New" color=#ff00ff size=1>1<FONT face="Courier New" 
size=1>); //default period 
value for tickers not in custom 
list
Smooth = <FONT face="Courier New" color=#0000ff 
size=1>Param(<FONT 
face="Courier New" color=#ff00ff size=1>"Smoothing"<FONT 
face="Courier New" size=1>,<FONT face="Courier New" color=#ff00ff 
size=1>5,<FONT face="Courier New" 
color=#ff00ff size=1>2,<FONT 
face="Courier New" color=#ff00ff size=1>15<FONT face="Courier New" 
size=1>,1<FONT 
face="Courier New" size=1>); <FONT face="Courier New" color=#008000 
size=1>//default smooth value
Custom = 0<FONT 
face="Courier New" size=1>;<FONT face="Courier New" color=#800000 
size=1>
for( i = <FONT 
face="Courier New" color=#ff00ff size=1>0<FONT face="Courier New" 
size=1>; ( sym = <FONT face="Courier New" color=#0000ff 
size=1>StrExtract( CustomStochRSIList, i 
) ) != ""<FONT 
face="Courier New" size=1>; i=i+<FONT face="Courier New" color=#ff00ff 
size=1>3)
{
if(<FONT face="Courier New" 
color=#0000ff size=1>Name()==sym)
{
Period = <FONT face="Courier New" color=#0000ff 
size=1>StrToNum(<FONT 
face="Courier New" color=#0000ff size=1>StrExtract<FONT 
face="Courier New" size=1>(CustomStochRSIList, i+<FONT face="Courier New" 
color=#ff00ff size=1>1));
Smooth = <FONT face="Courier New" color=#0000ff 
size=1>StrToNum(<FONT 
face="Courier New" color=#0000ff size=1>StrExtract<FONT 
face="Courier New" size=1>(CustomStochRSIList, i+<FONT face="Courier New" 
color=#ff00ff size=1>2));
Custom = 1<FONT 
face="Courier New" size=1>; 
}
}
storsi =Nz<FONT 
face="Courier New" size=1>( ( <FONT face="Courier New" color=#0000ff 
size=1>RSI( period) - <FONT 
face="Courier New" color=#0000ff size=1>LLV<FONT face="Courier New" 
size=1>( RSI<FONT 
face="Courier New" size=1>(period) ,period) ) / ( ( <FONT 
face="Courier New" color=#0000ff size=1>HHV<FONT face="Courier New" 
size=1>( RSI<FONT 
face="Courier New" size=1>(period) ,period) ) - <FONT face="Courier New" 
color=#0000ff size=1>LLV(<FONT 
face="Courier New" color=#0000ff size=1>RSI<FONT face="Courier New" 
size=1>(period),period) ) ); <FONT face="Courier New" color=#0000ff 
size=1>
Plot(<FONT face="Courier New" 
color=#0000ff size=1>EMA<FONT face="Courier New" 
size=1>(storsi,<FONT face="Courier New" color=#ff00ff 
size=1>5),<FONT face="Courier New" 
color=#0000ff size=1>EncodeColor<FONT face="Courier New" 
size=1>(colorWhite)+Period+<FONT face="Courier New" color=#ff00ff 
size=1>" period Sto Rsi."<FONT face="Courier New" 
size=1>,colorBlue,<FONT face="Courier New" color=#ff00ff 
size=1>1); <FONT 
face="Courier New" color=#0000ff size=1>
Plot(<FONT face="Courier New" 
color=#0000ff size=1>EMA(<FONT 
face="Courier New" color=#0000ff size=1>EMA<FONT face="Courier New" 
size=1>(storsi,<FONT face="Courier New" color=#ff00ff 
size=1>5),smooth),<FONT 
face="Courier New" color=#ff00ff size=1>""<FONT face="Courier New" 
size=1>+smooth+" period 
smoothing."<FONT face="Courier New" 
size=1>,colorYellow,<FONT face="Courier New" color=#ff00ff 
size=1>1); <FONT 
face="Courier New" color=#0000ff size=1>
Plot(.30,<FONT 
face="Courier New" color=#ff00ff size=1>""<FONT face="Courier New" 
size=1>,colorRed,<FONT face="Courier New" color=#ff00ff 
size=1>1); <FONT 
face="Courier New" color=#0000ff size=1>
Plot(.80,<FONT 
face="Courier New" color=#ff00ff size=1>""<FONT face="Courier New" 
size=1>,colorGreen,<FONT face="Courier New" color=#ff00ff 
size=1>1); 
Buy=<FONT face="Courier New" color=#0000ff 
size=1>Cross(<FONT 
face="Courier New" color=#0000ff size=1>EMA<FONT face="Courier New" 
size=1>(storsi,<FONT face="Courier New" color=#ff00ff 
size=1>5),<FONT face="Courier New" 
color=#0000ff size=1>EMA(<FONT 
face="Courier New" color=#0000ff size=1>EMA<FONT face="Courier New" 
size=1>(storsi,<FONT face="Courier New" color=#ff00ff 
size=1>5),smooth)); 
Sell=<FONT face="Courier New" color=#0000ff 
size=1>Cross(<FONT 
face="Courier New" color=#0000ff size=1>EMA<FONT face="Courier New" 
size=1>(EMA<FONT 
face="Courier New" size=1>(storsi,<FONT face="Courier New" color=#ff00ff 
size=1>5),smooth),<FONT 
face="Courier New" color=#0000ff size=1>EMA<FONT face="Courier New" 
size=1>(storsi,<FONT face="Courier New" color=#ff00ff 
size=1>5)); 
Title = <FONT face="Courier New" color=#0000ff 
size=1>WriteIf(Custom == <FONT 
face="Courier New" color=#ff00ff size=1>1<FONT face="Courier New" 
size=1>,"StochRSI 
"+<FONT face="Courier New" 
color=#0000ff size=1>EncodeColor<FONT face="Courier New" 
size=1>(colorRed)+<FONT face="Courier New" color=#ff00ff 
size=1>"(List Defined values.)"<FONT face="Courier New" 
size=1>,"StochRSI 
"+<FONT face="Courier New" 
color=#0000ff size=1>EncodeColor<FONT face="Courier New" 
size=1>(colorYellow)+<FONT face="Courier New" color=#ff00ff 
size=1>"(Default values)")+ <FONT 
face="Courier New" color=#0000ff size=1>EncodeColor<FONT 
face="Courier New" size=1>(colorBlack)+<FONT face="Courier New" 
color=#ff00ff size=1>"(Periods = "<FONT face="Courier New" 
size=1>+Period+". Smoothing 
= "+Smooth+<FONT 
face="Courier New" color=#ff00ff size=1>" periods.)"<FONT 
face="Courier New" size=1>;<FONT face="Courier New" color=#0000ff 
size=1>
PlotShapes(<FONT 
face="Courier New" color=#0000ff size=1>IIf<FONT face="Courier New" 
size=1>(Buy,shapeUpArrow,shapeNone) 
,colorBrightGreen,<FONT face="Courier New" color=#ff00ff 
size=1>0,Graph0,-<FONT 
face="Courier New" color=#ff00ff size=1>30<FONT face="Courier New" 
size=1>); 
PlotShapes(<FONT 
face="Courier New" color=#0000ff size=1>IIf<FONT face="Courier New" 
size=1>(Sell,shapeDownArrow,shapeNone),colorRed,<FONT 
face="Courier New" color=#ff00ff size=1>0<FONT face="Courier New" 
size=1>,Graph1,-<FONT face="Courier New" color=#ff00ff 
size=1>15); 
GraphXSpace=<FONT face="Courier New" color=#ff00ff 
size=1>10;






Yahoo! Groups Sponsor












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 the Yahoo! Terms of Service.