PureBytes Links
Trading Reference Links
|
Dan,
You are obviously so far ahead of me in Amibroker it isn't even funny.
Give me a day or two to look this code over and think more about the
issue and I'll give you a heads up. I actually got Worden to add the
S&P Equal Weight index to their data which is why the history there is
too short to backtest. I asked them for that because Dorsey Wright
uses it for RS comparisons and often their RS buy signals on P&F
charts yield nice returns.
Thanks again,
Bret
--- In amibroker@xxxxxxxxxxxxxxx, "Dan Clark" <dan_public@xxxx> wrote:
> Quad,
>
>
>
> Below is the code that I use to plot sector comparisons. It plots
price,
> Relative Strength, RSI or ROC directly for each sector, OR it plots
the rank
> of a sector versus all sectors using RSI or ROC.
>
>
>
> I hope you find this interesting.
>
>
>
> Regards,
>
>
>
> Dan.
>
>
>
> //Code from the master sector pane:
>
> _SECTION_BEGIN("PlotSectors1");
>
> // This contains a the PlotSectors Procedure that plots that chart.
>
> #include <PlotSectors_Analysis.afl>
>
>
>
> /*
>
> ** Set up and save the parameters
>
> */
>
> //Price or Relative Strength Indicator
>
> cRCPriceChartType = ParamList("Chart Type", "Price|Rel
Strength|Rank", 2 ) ;
>
> if (cRCPriceChartType == "Price")
>
> cRSPriceChartTypeLocal = "Price";
>
> else
>
> if (cRCPriceChartType == "Rel Strength")
>
> cRSPriceChartTypeLocal = "RelStrength";
>
> else
>
> cRSPriceChartTypeLocal = "Rank";
>
>
>
> //Indicator Type for Relative Strength
>
> cRCRSIndicatorType = ParamList("Rel Strength Indicator", "RSI|ROC",
1 ) ;
>
> if (cRCRSIndicatorType == "RSI")
>
> cRSIndicatorTypeLocal = "RSI";
>
> else
>
> if (cRCRSIndicatorType == "ROC")
>
> cRSIndicatorTypeLocal = "ROC";
>
> else
>
> cRSIndicatorTypeLocal = "ROC";
>
>
>
> //Symbol used for Relative Strength
>
> cRSPriceChartSymbolLocal = ParamList("Rel Srength
> Symbol","SP-500|NYSE|NDX-X", 0 ) ;
>
>
>
> //Periods for Rel Strength Indicators
>
> iNumIndicatorPeriodsLocal = Param("Rel Strength Indicator Period", 9, 0,
> 250, 1);
>
>
>
> //Set Global Variables
>
> RC1 = StaticVarSetText( "cRSPriceChartSymbol",
cRSPriceChartSymbolLocal);
>
> RC2 = StaticVarSetText( "cRSPriceChartType", cRSPriceChartTypeLocal);
>
> RC3 = StaticVarSet( "iNumIndicatorPeriods", iNumIndicatorPeriodsLocal);
>
> RC4 = StaticVarSetText( "cRSIndicatorType", cRSIndicatorTypeLocal);
>
>
>
> // Get the Global Variables
>
> cRSPriceChartSymbol = StaticVarGet("cRSPriceChartSymbol");
>
> cRSPriceChartType = StaticVarGet("cRSPriceChartType");
>
> iNumIndicatorPeriods = StaticVarGet("iNumIndicatorPeriods");
>
> cRSIndicatorType = StaticVarGet("cRSIndicatorType");
>
>
>
> //Plot the Sectors
>
> cSectorSymbols = "MG130,MG110,MG120,MG910,MG770";
>
> PlotSectors( cSectorSymbols);
>
>
>
> cTitleHeader = StaticVarGet("cTitleHeader");
>
>
>
>
>
> _SECTION_END();
>
>
>
> //Procedure in the #include "PlotSectors_Analysis.afl":
>
> procedure PlotSectors( cSectorSymbols)
>
> {
>
> // Get the Global Variables
>
> cRSPriceChartType = StaticVarGet("cRSPriceChartType");
>
> cRSPriceChartSymbol = StaticVarGet("cRSPriceChartSymbol");
>
> iNumIndicatorPeriods = StaticVarGet("iNumIndicatorPeriods");
>
> iSectorListNum = StaticVarGet("iSectorListNum ");
>
> cRSIndicatorType = StaticVarGet("cRSIndicatorType");
>
> // _TRACE(cRSPriceChartSymbol);
>
> // _TRACE(NumToStr(iIndicatorStyle, 8.0, False));
>
>
>
> /*
>
> ** Parameters
>
> */
>
> //List Number for Sector - Default to 3
>
> iSectorListNum = Param("Sector WatchList Num", 3, 0, 50,
1);
>
> bPlotComparisonSymbol = ParamToggle("Plot Base RS Symbol?",
"Yes|No",
> 0);
>
>
>
> // Set the base RS Symbol
>
> SetForeign(cRSPriceChartSymbol);
>
>
>
> // Set and plot symbol used for basis of comparison
>
> if (bPlotComparisonSymbol == 0) // 0 = Yes
>
> Plot(C, FullName(), ParamColor(Name() + " Color" , colorYellow),
> styleLine | styleDashed | styleOwnScale);
>
>
>
> //Now plot each Sector line.
>
> iNextSymbol = 0;
>
> iContinue = 1; // True
>
>
>
> //Get the CSV list of symbols from Sector list
>
> cSectorsSymbolList = GetCategorySymbols( categoryWatchlist,
> iSectorListNum);
>
>
>
> do
>
> {
>
> cSectorSymbol = StrExtract( cSectorSymbols , iNextSymbol );
>
>
>
> if (cSectorSymbol != "")
>
> {
>
> //Plot the Puppy
>
> SetForeign(cSectorSymbol);
>
>
>
> if (cRSPriceChartType == "Price")
>
> {
>
> Plot(C, FullName(), ParamColor(Name() + " Color" ,
colorDefault),
> styleLine | styleOwnScale | styleNoLabel);
>
> cTitle_ChartType = "Price";
>
> cTitle_RSSymbol = "";
>
> cTitle_Indicator = "";
>
> }
>
> else
>
> {
>
> if(cRSPriceChartType == "RelStrength")
>
> {
>
> Plot((Foreign(cSectorSymbol
> ,"C")/Foreign(cRSPriceChartSymbol,"C")) * 1000 , " (" + Name() +
FullName()
> + "/" + cRSPriceChartSymbol+ ")", ParamColor(Name() + " Color" ,
> colorDefault), styleLine | styleOwnScale| styleNoLabel);
>
> cTitle_ChartType = "RS";
>
> cTitle_RSSymbol = cRSPriceChartSymbol;
>
> cTitle_Indicator = "";
>
> }
>
> else // Rank
>
> {
>
> cTitle_ChartType = "Rank";
>
> cTitle_RSSymbol = cRSPriceChartSymbol;
>
>
>
> //Get the rank for the Current Sector Symbol using the
chosen
> indicator
>
> if(cRSIndicatorType == "RSI")
>
> {
>
> //Set the RSI Indicator
>
> iCurrentSectorSymbolIndicatorValue =
> RSI(iNumIndicatorPeriods );
>
> //Set the Ind Title
>
> cTitle_Indicator = "RSI(" +
> NumToStr(iNumIndicatorPeriods) + ")";
>
> }
>
> else // ROC
>
> {
>
> //Set the ROC Indicator
>
> iCurrentSectorSymbolIndicatorValue = ROC(C,
> iNumIndicatorPeriods) ;
>
>
>
> //Set the Ind Title
>
> cTitle_Indicator = "ROC(" +
> NumToStr(iNumIndicatorPeriods) + ")";
>
>
>
> }
>
> // Now get the RSI rank for the watchlist
>
> iRank = -1; // Initialize the Rank
>
>
>
> for( i = 0; (cSectorListSymbol = StrExtract(
cSectorsSymbolList
> , i ) ) != ""; i++ )
>
> {
>
> SetForeign(cSectorListSymbol);
>
>
>
> if(cRSIndicatorType == "RSI")
>
> iSectorListSymbolIndicatorValue =
> RSI(iNumIndicatorPeriods ) ;
>
> else
>
> iSectorListSymbolIndicatorValue = ROC(C,
> iNumIndicatorPeriods) ;
>
>
>
> iRank = iRank + IIf(iCurrentSectorSymbolIndicatorValue <
> iSectorListSymbolIndicatorValue , -1, 0);
>
> }
>
>
>
> SetForeign(cSectorSymbol);
>
> Plot(iRank ,"Rank: (" + Name() + FullName() + ")",
> ParamColor(Name() + " Color", colorDefault), styleLine );
>
> //Plot(iRank ,"Sector Rank: (" + Name() + FullName() + "/" +
> cRSPriceChartSymbol+ ")", ParamColor(Name() + " Color", colorDefault),
> styleLine | styleNoLabel);
>
> }
>
> }
>
> }
>
> else // Stop. No more symbols
>
> {
>
> iContinue = 0;
>
> }
>
>
>
> // This is down here because the StrExtract function is Zero-based.
>
> iNextSymbol = iNextSymbol + 1;
>
>
>
> } while (iContinue == 1 OR iNextSymbol < 40); // Last Part is
prevent
> runaway loops
>
>
>
> cTitleHeaderLocal = cTitle_ChartType + "/" + cTitle_RSSymbol + "/" +
> cTitle_Indicator + " " ;
>
> RC = StaticVarSetText( "cTitleHeader ", cTitleHeaderLocal );
>
>
>
>
>
> }
>
> _____
>
> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]
On Behalf
> Of Dan Clark
> Sent: Saturday, July 09, 2005 11:00 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: RE: [amibroker] Question on RS, possibly for Tomasz
>
>
>
> Quad, Jason,
>
>
>
> I've been wrestling with almost the exact same issues for the past
couple of
> weeks. In fact, my post of 7:57 this morning is related to this
issue.
>
>
>
> Quad, regarding comparing Sector/Market Relative Strength against each
> other. Is this even valid? (No, I'm not trying to be rude.)
Here's my
> thinking.
>
>
>
> Unless I'm missing something, it seems that your underlying
questions are,
> "Which are the strongest and weakest Sectors?" and "How is Sector
strength
> changing over time?" (If so, these are my questions as well.)
If this
> is correct, why do we care about the comparative "Relative Strength to
> Market"?
>
>
>
> It seems to me that the combination of the Sectors IS the market.
Correct?
> If so, then the Sectors' comparative ROC or RSI is a valid measure. Or,
> perhaps calculating the rank of a Sector within all Sectors using ROC or
> RSI. Do my arguments make any sense?
>
>
>
> I'm using TC2005 data also and the Sectors/Industries are one of the key
> reasons that I used the data. I've got several indicators built that
> calculate Industry and Sector rank and comparative strength. I use
ROC and
> RSI for both. I'm VERY interested in improving this.
>
>
>
> Jason, this looks VERY interesting, but there are two issues:
>
>
>
> 1) When I tried to run an exploration with this, I got the error,
> "Relative strength base symbol not found" on all of the RelStrength
lines
> starting with:
>
>
>
> j1 = RelStrength("j");
>
>
>
> I'm using 4.70.5. Any idea why this happens? What did you
do at
> work to make it run?
>
>
>
> 2) I'm a little confused about using this as a scan. I.e. it
looks
> like the code computes the relative strength of the Nasdaq index to the
> S&P500 and it's changes over time. But that wouldn't that only
return one
> row?
>
>
>
> Inquiring minds want to know. :-)
>
>
>
> Regards,
>
>
>
> Dan.
>
>
>
> // Here's the code I'm using to compute Industry and Market Relative
> Strength to the current symbol. (Obviously this works only with a stock
> symbol which has an industry.)
>
>
>
> _SECTION_BEGIN("Relative Strength");
>
> // Get Symbols
>
> MktBaseSymbol = ParamStr("Mkt ticker", "SP-500" );
>
> IndustrySymbol = GetBaseIndex() ;
>
>
>
> StockToIndColor = ParamColor( "Stock to Industry Color", colorOrange );
>
> StockToIndStyle = ParamStyle("Stock To Industry Style", styleLine +
> styleNoLabel + styleOwnScale) | styleDots ;
>
>
>
> StockToMktColor = ParamColor( "Stock to Market Color", colorRed );
>
> StockToMktStyle = ParamStyle("Stock To Market Style", styleLine +
> styleNoLabel + styleOwnScale) ;
>
>
>
> IndToMktColor = ParamColor( "Industry to Market Color", colorGold );
>
> IndToMktStyle = ParamStyle("Industry To Market Style", styleLine +
> styleNoLabel + styleOwnScale) ;
>
>
>
> RelStrengthSymbolToIndustry = RelStrength(IndustrySymbol );
>
> RelStrengthSymbolToMarket= RelStrength(MktBaseSymbol );
>
>
>
> ShortMAPeriods = Param("Rel Strength Short MA Periods", 10, 1,
50, 1);
>
> LongMAPeriods = Param("Rel Strength Long MA Periods", 40, 1, 50, 1);
>
>
>
> cShortMAPeriods = NumToStr(ShortMAPeriods, 3.0);
>
> cLongMAPeriods = NumToStr(LongMAPeriods, 3.0);
>
>
>
> // Plot Relative Strength - Stock To Industry
>
> Plot( RelStrengthSymbolToIndustry , _SECTION_NAME() + " (" + Name()
+ " to "
> + IndustrySymbol + ")", StockToIndColor ,StockToIndStyle );
>
>
>
> // Plot Relative Strength - Stock To Market
>
> Plot( RelStrengthSymbolToMarket, " (" + Name() + " to " +
MktBaseSymbol +
> ")", StockToMktColor , StockToMktStyle );
>
>
>
> // Now plot relative Strength - Industry to Market
>
> RelStrengthIndustryToMarket =
> (Foreign(IndustrySymbol,"C")/Foreign(MktBaseSymbol,"C")) * 1000;
>
> Plot(RelStrengthIndustryToMarket , " (" + IndustrySymbol+ " to " +
Name()+
> ")", IndToMktColor , IndToMktStyle );
>
>
>
> if( Status("action")==actionCommentary )
>
> { printf("(Interpretation is not available yet)");}
>
> _SECTION_END();
>
> _____
>
> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]
On Behalf
> Of Jason Hart
> Sent: Saturday, July 09, 2005 9:18 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: Re: [amibroker] Question on RS, possibly for Tomasz
>
>
>
> Quad,
>
>
>
> I've got a number of different RS-type explorations that I've been
> experimenting with. Try this scan - it's by no means perfect, but
you can
> modify it to fit your criteria. A quick warning though, this
formula works
> fine on my home PC but at work I had to play around with "j" because it
> wasn't recognized as a valid symbol...strange.
>
>
>
> Jason
>
> Filter=C>0;
>
> x=RelStrength("!comp");
>
> j = Foreign("!spx", "c");
>
> j1 = RelStrength("j");
>
> j2 = RelStrength("j")/Ref(j1,-20);
>
> j3 = RelStrength("j")/Ref(j1,-30);
>
> j4 = RelStrength("j")/Ref(j1,-50);
>
> j5 = RelStrength("j")/Ref(j1,-100);
>
> j6 = RelStrength("j")/Ref(j1,-120);
>
> j7 = RelStrength("j")/Ref(j1,-150);
>
> j8 = RelStrength("j")/Ref(j1,-200);
>
> vol1 = StDev(log(C/Ref(C,-1)),720) * sqrt(260)*100;
>
> vol2 = StDev(log(C/Ref(C,-1)),20) * sqrt(260)*100;
>
> vol3 = StDev(log(C/Ref(C,-1)),50) * sqrt(260)*100;
>
> vol4 = StDev(log(C/Ref(C,-1)),90) * sqrt(260)*100;
>
> Vol5 = (Vol2 + Vol3+ Vol4)/3;
>
> Vol6 = Vol5-Vol1;
>
> Final = (j2*1) + (j3*1.2) + (j4*1.3)+(j5*1.4) + (j6*1.5) + (j7*1.7) +
> (j8*1.7);
>
> RSC=LinRegSlope(x,7);
>
> AddColumn(IIf(rsc>0,BarsSince(rsc<=0),BarsSince(rsc>=0)),"Cross",1.0);
>
> AddTextColumn(FullName(),"name",5);
>
> AddColumn(FINAL,"Today
>
RSC",1.2,colorDefault,IIf(final==0,colorBlue,IIf(final>Ref(final,-1),colorGr
> een,colorRed)));
>
> AddColumn(Ref(final,-1),"Yesterday
>
RSC",1.2,colorDefault,IIf(final==0,colorBlue,IIf(Ref(final,-1)>=Ref(final,-2
> ),colorGreen,colorRed)));
>
> AddColumn(Ref(final,-2),"2
>
days",1.2,colorDefault,IIf(final==0,colorBlue,IIf(Ref(final,-2)>=Ref(final,-
> 3),colorGreen,colorRed)));
>
> AddColumn(Ref(final,-3),"3
>
days",1.2,colorDefault,IIf(final==0,colorBlue,IIf(Ref(final,-3)>=Ref(final,-
> 4),colorGreen,colorRed)));
>
> AddColumn(Ref(final,-4),"4
>
days",1.2,colorDefault,IIf(final==0,colorBlue,IIf(Ref(final,-4)>=Ref(final,-
> 5),colorGreen,colorRed)));
>
> AddColumn(Ref(final,-5),"5
>
days",1.2,colorDefault,IIf(final==0,colorBlue,IIf(Ref(final,-5)>=Ref(final,-
> 6),colorGreen,colorRed)));
>
> AddColumn(Ref(final,-6),"6
>
days",1.2,colorDefault,IIf(final==0,colorBlue,IIf(Ref(final,-6)>=Ref(final,-
> 7),colorGreen,colorRed)));
>
> AddColumn(Ref(final,-7),"7
>
days",1.2,colorDefault,IIf(final==0,colorBlue,IIf(Ref(final,-7)>=Ref(final,-
> 8),colorGreen,colorRed)));
>
> AddColumn(Ref(final,-8),"8
>
days",1.2,colorDefault,IIf(final==0,colorBlue,IIf(Ref(final,-8)>=Ref(final,-
> 9),colorGreen,colorRed)));
>
> AddColumn(Ref(final,-9),"9
>
days",1.2,colorDefault,IIf(final==0,colorBlue,IIf(Ref(final,-9)>=Ref(final,-
> 10),colorGreen,colorRed)));
>
> AddColumn(Ref(final,-10),"10
>
days",1.2,colorDefault,IIf(final==0,colorBlue,IIf(Ref(final,-10)>=Ref(final,
> -11),colorGreen,colorRed)));
>
>
>
> Quad Rate Serial Abby <quad_pumped_abby@xxxx> wrote:
>
> I would like to do an exploration for the change in RS of a sector
> over various periods, say one week, two weeks, etc. I extracted the
> RS of the sector versus the S&P Equal Weight Index using:
>
> Strength = RelStrength ( "SPEW-X", fixup = 1 );
>
> Then I found the change over the time periods in question.
>
> Of course, when you look at a plot of the RS for a symbol or sector it
> appears the numerical value of the RS is directly correlated to the
> price of the underlying. Thus, the numerical change in RS would be
> meaningless against a different priced sector.
>
> I thought the simple solution was to divide the RS value by the
> closing price, thus normalizing the results. But this caused the RS
> charts and values to be identical for every sector.
>
> Is what I'm trying to do an impossibility with Amibroker or is my
> approach all wrong? Any help would be appreciated.
>
> Thanks,
>
> Bret
>
>
>
>
> 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
>
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> 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
>
>
>
>
>
> SPONSORED LINKS
>
>
> Investment
>
<http://groups.yahoo.com/gads?t=ms&k=Investment+management+software&w1=Inves
>
tment+management+software&w2=Investment+property+software&w3=Investment+soft
>
ware&w4=Investment+tracking+software&w5=Return+on+investment+software&w6=Sto
> ck+investment+software&c=6&s=195&.sig=f7GzIv9NJMWrH8f5eIxZQQ>
management
> software
>
> Investment
>
<http://groups.yahoo.com/gads?t=ms&k=Investment+property+software&w1=Investm
>
ent+management+software&w2=Investment+property+software&w3=Investment+softwa
>
re&w4=Investment+tracking+software&w5=Return+on+investment+software&w6=Stock
> +investment+software&c=6&s=195&.sig=fBbyjQAf07KrkKtKejJqSg> property
> software
>
> Investment
>
<http://groups.yahoo.com/gads?t=ms&k=Investment+software&w1=Investment+manag
>
ement+software&w2=Investment+property+software&w3=Investment+software&w4=Inv
>
estment+tracking+software&w5=Return+on+investment+software&w6=Stock+investme
> nt+software&c=6&s=195&.sig=JfxNHYIXqCuLAnnc8YN4_A> software
>
>
> Investment
>
<http://groups.yahoo.com/gads?t=ms&k=Investment+tracking+software&w1=Investm
>
ent+management+software&w2=Investment+property+software&w3=Investment+softwa
>
re&w4=Investment+tracking+software&w5=Return+on+investment+software&w6=Stock
> +investment+software&c=6&s=195&.sig=SgkrPC352yiiN_zJGzIM9Q> tracking
> software
>
> Return
>
<http://groups.yahoo.com/gads?t=ms&k=Return+on+investment+software&w1=Invest
>
ment+management+software&w2=Investment+property+software&w3=Investment+softw
>
are&w4=Investment+tracking+software&w5=Return+on+investment+software&w6=Stoc
> k+investment+software&c=6&s=195&.sig=L-DlQNXfuFeH8Mu0waS7qw> on
investment
> software
>
> Stock
>
<http://groups.yahoo.com/gads?t=ms&k=Stock+investment+software&w1=Investment
>
+management+software&w2=Investment+property+software&w3=Investment+software&
>
w4=Investment+tracking+software&w5=Return+on+investment+software&w6=Stock+in
> vestment+software&c=6&s=195&.sig=0oBPv1BELuBmfls_PcSgGg> investment
> software
>
>
>
>
>
> 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
>
>
>
> * Visit your group "amibroker
> <http://groups.yahoo.com/group/amibroker> " on the web.
>
> * To unsubscribe from this group, send an email to:
> amibroker-unsubscribe@xxxxxxxxxxxxxxx
> <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe>
>
> * Your use of Yahoo! Groups is subject to the Yahoo!
> <http://docs.yahoo.com/info/terms/> Terms of Service.
>
>
>
> _____
------------------------ Yahoo! Groups Sponsor --------------------~-->
Try Online Currency Trading with GFT. Free 50K Demo. Trade
24 Hours. Commission-Free.
http://us.click.yahoo.com/DldnlA/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~->
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
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|