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

[amibroker] Re: Question on RS, Dan and Jason



PureBytes Links

Trading Reference Links

I guess looking at the rate of change was what I was missing as a way
to explore.  I am still making a comparison to the SPEW-X, but the
results should be consistant.  

This is a simple exploration code allowing you to sort by column for
time frames.  Just set the filter to Group > Industry Group Average. 
The buy routine is what I was using on individual stocks.  Once you
find the better performing sectors you can then run a buy scan on each
sector and see which stocks meet the buy criteria.  This should give
you a few stocks to look at in the better sectors whenever you run it
and seems to pick up a lot of Dorsey Wright RS buy signals before they
show up there.  The additional buy criteria were to try and filter out
some of the hits when I was scanning a large database.  It seemed to
work pretty well on stocks but the numerical values of the sectors
makes the spread between the EMA's of the RS useless.  I never
intended it to work for sectors when I made it.  I was just looking
for a way to buy stocks with increasing RS.  My theory was that I only
wanted to look at stocks where the EMA 10 had crossed above the EMA
25, and were also increasing the spread between them.  This filtered
out the "fake" crosses that quickly reverse.  I thought this would
find stocks that were outperfroming the market and also starting to
outperform their own recent RS if this makes sense.  The fixed rate of
return will keep you out of all stocks if you get RS hits in a bad
market, and perhaps this should be increased above 20%.  

This can't be backtested because there is no price history on the
SPEW-X available through Worden, but you chould change the comparison
to the SP-500 and try it or come up with other buy rules.  I never
added sell rules.  If you get any ideas on how to improve it, let me
know, and thanks again for the help.

Bret

Version 4.70:

_SECTION_BEGIN("SPXEW RSI Expl.");
GraphXSpace = 5;
Strength1 = RelStrength ( "SPEW-X", fixup = 1 );
Strength2 = RelStrength ( "FX20", fixup = 1 );
Plot ( Strength1, _DEFAULT_NAME(), ParamColor ( "Color", 2 ),
ParamStyle ( "Style" ));
_SECTION_END();

_SECTION_BEGIN("SPXEW RSI Explore");
One_Week_Change = ROC ( Strength1, 5, False );
Two_Week_Change = ROC ( Strength1, 10, False );
One_Month_Change = ROC ( Strength1, 20, False );

Filter = Strength1;
Filter = One_Week_Change;
Filter = Two_Week_Change;
Filter = One_Month_Change;

AddTextColumn (SectorID ( 1 ), "Sector name" );
AddColumn ( Strength1, "Rel. Str." );
AddColumn ( One_Week_Change, "One Week RSI Change" );
AddColumn ( Two_Week_Change, "Two Week RSI Change" );
AddColumn ( One_Month_Change, "One Month RSI Change" );
_SECTION_END();

_SECTION_BEGIN("Buy Routine");
Strength1_Difference = EMA ( Strength1, 10 ) - EMA ( Strength1, 25 );
Momentum = MA ( Close - Ref ( Close, -20 ), 1 );
Test = Min (( 1 / ( 0.20 * C )), 0.20 ); 
Buy = IIf ( Strength1_Difference >= Test AND Ref (
Strength1_Difference, -1 ) < Test AND Strength1 > Strength2 AND
Momentum > EMA ( Momentum, 20 ), 1, 0 );
_SECTION_END();

_SECTION_BEGIN("EMA1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color",
colorCycle ), ParamStyle("Style") ); 
_SECTION_END();

_SECTION_BEGIN("EMA2");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color",
colorCycle ), ParamStyle("Style") ); 
_SECTION_END();


--- In amibroker@xxxxxxxxxxxxxxx, Jason Hart <jayhart_1972@xxxx> wrote:
> Dan,
>  
> I have the same issue on my work PC, but this very formula works
fine on my home PC (don't ask!).  I'll send the revised formula that's
on my work PC Monday morning.
>  
> Jason  
> 
> Dan Clark <dan_public@xxxx> wrote:
> v\:* {behavior:url(#default#VML);}o\:*
{behavior:url(#default#VML);}w\:* {behavior:url(#default#VML);}.shape
{behavior:url(#default#VML);}st1\:*{behavior:url(#default#ieooui) }
> 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.  J
> 
>  
> 
> 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),colorGreen,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 management software 
> 
> Investment property software 
> 
> Investment software 
> 
> Investment tracking software 
> 
> Return on investment software 
> 
> Stock 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" on the web.
>   
>     To unsubscribe from this group, send an email to:
>  amibroker-unsubscribe@xxxxxxxxxxxxxxx
>   
>     Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service. 
> 
> 
> ---------------------------------
> 
> 
> 
> 
> 		
> ---------------------------------
> Do you Yahoo!?
>  Read only the mail you want - Yahoo! Mail SpamGuard.




------------------------ 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/