See full code below...

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Terry
Sent: Friday, July 28, 2006 9:43 AM
To: [email protected]
Subject: RE: [amibroker] Interpreting A Code Segment

This is doing a RelStrength of each stock in the WatchList to the currently selected ticker. It is then doing the Guppy MMA against the resulting RelStrength. What it does next is not shown in the code posted. (Note: It is skipping comparing the current ticker to itself if that ticker is also in Watchlist, if(sym != Name()), because you'd just get all 1's.)

So, this code is dependent on the selected ticker for consistent results, depending on what the follow-on code does. 

 

Thanks for the explanation...I should have posted the full code which I have done so below.  I read the help definition, and guess that I am puzzled over the entire concept of the code.  This code combines relstrength with Guppy MMAs and is supposed to rank the stocks by their RS compared to the MMAs.  Somehow it is eluding me but I will keep studying and experimenting with it.

Here is the full code...maybe someone can explain it all more fully and get some use out of it.

Ken

Code follows (not my code, obviously)

/*
Simple Sector Rotation Model
This is a simple method for determining the strongest sectors at any given time. Use daily
mode for intermediate term, and weekly for longer term. The basis of it is Daryl Guppy's
Multiple Moving Averages (MMA) plot. Here, I seperate the moving averages into short term
and long term averages, and give a point for each moving average above all the long term averages.

I do this for every symbol in the watchlist except the index being scanned, then I generally
sort the results based on the RS reading. To use this, you need to create a watchlist of
symbols, and set WatchlistNum appropriately. Also, you want to define a filter so that you only
scan this watchlist.

This is intended only for sector rotation, and probably would not be terribly useful as a trading
system in and of itself. I use TC2000's MG* sector indexes personally.
*/

EnableRotationalTrading();
SetOption("WorstRankHeld", 5);
PositionSize = -100;
PositionScore = 0;
WatchlistNum = 1;
Filter=1;
NumColumns=0;

function CalculatePosition(st, Lt1, Lt2, Lt3, Lt4, Lt5, Lt6)
{
 score=0;

 if(st > Lt1) score++;
 if(st > Lt2) score++;
 if(st > Lt3) score++;
 if(st > Lt4) score++;
 if(st > Lt5) score++;
 if(st > Lt6) score++;
 return score;
}


// walk through the watchlist grabbing all the symbols to calculate RS vs ourself.
List = CategoryGetSymbols(categoryWatchlist, WatchlistNum);
for(i=0; (sym = StrExtract(List, i)) != "";i++)
{
 if(sym != Name())
 {
  f = RelStrength(sym);

  st3 = EMA(f, 3);
  st5 = EMA(f, 5);
  st8 = EMA(f, 8);
  st12 = EMA(f, 12);
  st15 = EMA(f, 15);

  Lt30 = EMA(f, 30);
  Lt35 = EMA(f, 35);
  Lt40 = EMA(f, 40);
  Lt45 = EMA(f, 45);
  Lt50 = EMA(f, 50);
  Lt60 = EMA(f, 60);

  z=BarCount - 1;
  // uncomment the following if you want to do some backtesting or if you like waiting around
  // a long time for the exploration to complete
  //for(z=0;z < BarCount;z++)
  {

  PositionScore[z] = PositionScore[z] + CalculatePosition(st3[z], Lt30[z], Lt35[z], Lt40[z], Lt45[z], Lt50[z], Lt60[z]);

  PositionScore[z] = PositionScore[z] + CalculatePosition(st5[z], Lt30[z], Lt35[z], Lt40[z], Lt45[z], Lt50[z], Lt60[z]);

  PositionScore[z] = PositionScore[z] + CalculatePosition(st8[z], Lt30[z], Lt35[z], Lt40[z], Lt45[z], Lt50[z], Lt60[z]);

  PositionScore[z] = PositionScore[z] + CalculatePosition(st12[z], Lt30[z], Lt35[z], Lt40[z], Lt45[z], Lt50[z], Lt60[z]);

  PositionScore[z] = PositionScore[z] + CalculatePosition(st15[z], Lt30[z], Lt35[z], Lt40[z], Lt45[z], Lt50[z], Lt60[z]);

 }
}
}

AddTextColumn(FullName(), "Name");
AddColumn(PositionScore[BarCount - 1], "RS");

__._,_.___

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 Real estate investment software Investment property software
Software support Real estate investment analysis software


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to