找回密码
 注册
搜索
查看: 4474|回复: 17

[操作技巧] Sector Rotation Amibroker code

[复制链接]
发表于 2010-1-9 03:40 PM | 显示全部楼层 |阅读模式


本帖最后由 Ave 于 2010-1-9 15:26 编辑

为感谢老蛇,Coolmax, PPteam, Yaobuyao, 队长,还有其他版主的辛勤工作, 贡献一下我用来判别sector rotation的程序。Code 是我从amibroker library下的,经过简单修改。我只track主要sector, 你可以自己加入其他的sector, 就是图会越来越乱了。选股的时候,只做上升的sector. Buy dip。 或者sector启动之后,一般龙头先涨,这时挖掘同sector其他股票,找补涨对象。例外,对于我这样的青蛙来说,我只做FA过关的股票。

从图上来看,现在上升的是Energy, Finance, Materials, 和Industrial. 其中 Industrial 刚刚启动不久,还有空间。 Utility 接近oversold, Health 可能要抬头,这是大盘要 pull back 的先兆吧。

//------------------------------------------------------------------------------
//
//  Formula Name:    Sector Tracking
//
//------------------------------------------------------------------------------
//
//  Tracks normalized sector performance
//  Performance is tracked by a 13 day exp moving average
//  and finally the sum of 9 days to smooth out the data.
//
//  CAUTION: You may need to edit the symbol for SP 500 index if different
//  for your data source
//------------------------------------------------------------------------------

// Plot the 13 week EMA of incremental differences
// This is useful for finding strengthening sectors / industries
// Normalize data


Title = "Sectors: Energy(BrightBlue)-Tech(White)-Finance(Red)-Materials(BrightGreen)-Health(Yellow)-Utility(Pink)-Gold(DSS)-Purple(Staples)-Brick(Industry)-DarkGreen(HomeBuilding)-Grey(Retail)";

Sum_Filter = 9;

Energy                     = Foreign("XLE","Close",fixup=1);
Tech                       = Foreign("XLK","Close",fixup=1);
Finance                    = Foreign("XLF","Close",fixup=1);
Materials                  = Foreign("XLB","Close",fixup=1);
Health                            = Foreign("XLV","Close",fixup=1);
Utility                    = Foreign("XLU","Close",fixup=1);
ConsumerDSS           = Foreign("XLY","Close",fixup=1);
Industry                        = Foreign("XLI","Close",fixup=1);
ConsumerStaples  = Foreign("XLP","Close",fixup=1);
HomeBuilding           = Foreign("XHB","Close",fixup=1);
Retail                           = Foreign("XRT","Close",fixup=1);
SP500                           = Foreign("^GSPC","close");

Energy_Perf       = EMA(ROC(Energy,1), 13);
Tech_Perf         = EMA(ROC(Tech,1), 13);
Finance_Perf      = EMA(ROC(Finance,1), 13);
Materials_Perf    = EMA(ROC(Materials,1),13);
Health_Perf       = EMA(ROC(Health,1),13);
Utility_Perf      = EMA(ROC(Utility,1),13);
ConsumerDSS_Perf  = EMA(ROC(ConsumerDSS,1),13);
Industry_Perf     = EMA(ROC(Industry,1),13);
ConsumerStaples_Perf  = EMA(ROC(ConsumerStaples,1),13);
HomeBuilding_Perf  = EMA(ROC(HomeBuilding,1),13);
Retail_Perf                   = EMA(ROC(Retail,1),13);
SP500_Perf                   = EMA(ROC(SP500,1),13);

//SP500_ref = MA(SP500_Perf,Sum_filter);

Energy_Sum        = MA(Energy_Perf,Sum_Filter) * 100;
Tech_Sum          = MA(Tech_Perf,Sum_Filter)* 100;
Finance_Sum       = MA(Finance_Perf,Sum_Filter)* 100;
Materials_Sum     = MA(Materials_Perf,Sum_Filter)* 100;
Health_Sum        = MA(Health_Perf,Sum_Filter)* 100;
Utility_Sum     = MA(Utility_Perf,Sum_Filter)* 100;
ConsumerDSS_Sum     = MA(ConsumerDSS_Perf,Sum_Filter)* 100;
ConsumerStaples_Sum     = MA(ConsumerStaples_Perf,Sum_Filter)* 100;
Industry_Sum     = MA(Industry_Perf,Sum_Filter)* 100;
HomeBuilding_Sum     = MA(HomeBuilding_Perf,Sum_Filter)* 100;
Retail_Sum     = MA(Retail_Perf,Sum_Filter)* 100;

/*
Backtest performance by selectig top sector to buy
Buy when rel performance above 0 and slope maximum
Sell when slope decreass relative to another sector
Always be in the market
*/

Filter = Close > 0;
NumColumns = 11;
Column0Name = "Energy";
Column0     = Energy_Sum;
Column1Name = "Tech";
Column1     = Tech_Sum;
Column2Name = "Finance";
Column2     = Finance_Sum;
Column3Name = "Materials";
Column3     = MAterials_Sum;
Column4Name = "Health";
Column4     = Health_Sum;
Column5Name = "Utility";
Column5     = Utility_Sum;
Column6Name = "ConsumerDSS";
Column6     = ConsumerDSS_Sum;
Column7Name = "ConsumerStaples";
Column7     = ConsumerStaples_Sum;
Column8Name = "Industry";
Column8     = Industry_Sum;
Column9Name = "HomeBuilding";
Column9     = HomeBuilding_Sum;
Column10Name = "Retail";
Column10     = Retail_Sum;

MaxGraph = 11;
Graph0 = Energy_Sum;
Graph0Color = 10;      //Blue - Energy
Graph1 = Tech_Sum;   
Graph1Color = 2;      //White - Tech
Graph2 = Finance_Sum;
Graph2Color = 4;      //Red - Finance
Graph3 = Materials_Sum;
Graph3Color = 5;      //Green - Mater.
Graph4 = Health_Sum;
Graph4Color = 7;      //Yellow - Health
Graph5 = Utility_Sum;
Graph5Color = 11;      //Green - Utility
Graph6 = ConsumerDSS_Sum;
Graph6Color = 9;      //Gold - ConsumerDSS
Graph7 = ConsumerStaples_Sum;
Graph7Color = 12;      //Purple - ConsumerStaples
Graph8 = Industry_Sum;
Graph8Color = 15;      //Brick - Industry
Graph9 = HomeBuilding_Sum;
Graph9Color = 19;      //DarkGreen - HomeBuilding
Graph10 = Retail_Sum;
Graph10Color = 39;      //Grey - Retail


Graph0Style = 4;
Graph1Style = 4;
Graph2Style = 4;
Graph3Style = 4;
Graph4Style = 4;
Graph5Style = 4;
Graph6Style = 4;
Graph7Style = 4;
Graph8Style = 4;
Graph9Style = 4;
Graph10Style = 4;
Sector_Rotation.png

评分

4

查看全部评分

发表于 2010-1-9 04:28 PM | 显示全部楼层
回复 鲜花 鸡蛋

使用道具 举报

发表于 2010-1-9 04:33 PM | 显示全部楼层
本帖最后由 sandera 于 2010-1-9 15:39 编辑

选股的时候,只做上升的sector. Buy dip。 或者sector启动之后,一般龙头先涨,这时挖掘同sector其他股票,找补涨对象。例外,对于我这样的青蛙来说,我只做FA过关的股票。




我是小蝌蚪, 看不懂你的图,贴子里这几句话还是看懂了.
回复 鲜花 鸡蛋

使用道具 举报

 楼主| 发表于 2010-1-9 04:51 PM | 显示全部楼层
3# sandera

刚刚又从新改了一下code. 加入了用Expressing geometric relative return方法计算各sector相对spx的强弱。大于0代表强于大盘。

//------------------------------------------------------------------------------
//
//  Formula Name:    Sector Tracking
//
//------------------------------------------------------------------------------
//
//  Tracks normalized sector performance
//  Performance is tracked by a 13 day exp moving average
//  and finally the sum of 9 days to smooth out the data.
//
//  CAUTION: You may need to edit the symbol for SP 500 index if different
//  for your data source
//------------------------------------------------------------------------------

// Plot the 13 week EMA of incremental differences
// This is useful for finding strengthening sectors / industries
// Normalize data


Title = "Sectors: Energy(BrightBlue)-Tech(White)-Finance(Red)-Materials(BrightGreen)-Health(Yellow)-Utility(Pink)-Gold(DSS)-Purple(Staples)-Brick(Industry)-DarkGreen(HomeBuilding)-Grey(Retail)";

Sum_Filter = 9;

Energy                     = Foreign("XLE","Close",fixup=1);
Tech                       = Foreign("XLK","Close",fixup=1);
Finance                    = Foreign("XLF","Close",fixup=1);
Materials                  = Foreign("XLB","Close",fixup=1);
Health                            = Foreign("XLV","Close",fixup=1);
Utility                    = Foreign("XLU","Close",fixup=1);
ConsumerDSS           = Foreign("XLY","Close",fixup=1);
Industry                        = Foreign("XLI","Close",fixup=1);
ConsumerStaples  = Foreign("XLP","Close",fixup=1);
HomeBuilding           = Foreign("XHB","Close",fixup=1);
Retail                           = Foreign("XRT","Close",fixup=1);
SP500                           = Foreign("^GSPC","close");

Energy_Perf       = EMA(ROC(Energy,1), 13);
Tech_Perf         = EMA(ROC(Tech,1), 13);
Finance_Perf      = EMA(ROC(Finance,1), 13);
Materials_Perf    = EMA(ROC(Materials,1),13);
Health_Perf       = EMA(ROC(Health,1),13);
Utility_Perf      = EMA(ROC(Utility,1),13);
ConsumerDSS_Perf  = EMA(ROC(ConsumerDSS,1),13);
Industry_Perf     = EMA(ROC(Industry,1),13);
ConsumerStaples_Perf  = EMA(ROC(ConsumerStaples,1),13);
HomeBuilding_Perf  = EMA(ROC(HomeBuilding,1),13);
Retail_Perf                   = EMA(ROC(Retail,1),13);
SP500_Perf                   = EMA(ROC(SP500,1),13);

SP500_ref = MA(SP500_Perf,Sum_filter);

Energy_Sum        = (1 + MA(Energy_Perf,Sum_Filter))/(1 + SP500_ref)-1;
Tech_Sum          = (1 + MA(Tech_Perf,Sum_Filter))/(1 + SP500_ref)-1;
Finance_Sum       = (1 + MA(Finance_Perf,Sum_Filter))/(1 + SP500_ref)-1;
Materials_Sum     = (1 + MA(Materials_Perf,Sum_Filter))/(1 + SP500_ref)-1;
Health_Sum        = (1 + MA(Health_Perf,Sum_Filter))/(1 + SP500_ref)-1;
Utility_Sum       = (1 + MA(Utility_Perf,Sum_Filter))/(1 + SP500_ref)-1;
ConsumerDSS_Sum   = (1 + MA(ConsumerDSS_Perf,Sum_Filter))/(1 + SP500_ref)-1;
ConsumerStaples_Sum = (1 + MA(ConsumerStaples_Perf,Sum_Filter))/(1 + SP500_ref)-1;
Industry_Sum      = (1 + MA(Industry_Perf,Sum_Filter))/(1 + SP500_ref)-1;
HomeBuilding_Sum  = (1 + MA(HomeBuilding_Perf,Sum_Filter))/(1 + SP500_ref)-1;
Retail_Sum        = (1 + MA(Retail_Perf,Sum_Filter))/(1 + SP500_ref)-1;

/*
Backtest performance by selectig top sector to buy
Buy when rel performance above 0 and slope maximum
Sell when slope decreass relative to another sector
Always be in the market
*/

Filter = Close > 0;
NumColumns = 11;
Column0Name = "Energy";
Column0     = Energy_Sum;
Column1Name = "Tech";
Column1     = Tech_Sum;
Column2Name = "Finance";
Column2     = Finance_Sum;
Column3Name = "Materials";
Column3     = MAterials_Sum;
Column4Name = "Health";
Column4     = Health_Sum;
Column5Name = "Utility";
Column5     = Utility_Sum;
Column6Name = "ConsumerDSS";
Column6     = ConsumerDSS_Sum;
Column7Name = "ConsumerStaples";
Column7     = ConsumerStaples_Sum;
Column8Name = "Industry";
Column8     = Industry_Sum;
Column9Name = "HomeBuilding";
Column9     = HomeBuilding_Sum;
Column10Name = "Retail";
Column10     = Retail_Sum;

MaxGraph = 11;
Graph0 = Energy_Sum;
Graph0Color = 10;      //Blue - Energy
Graph1 = Tech_Sum;   
Graph1Color = 2;      //White - Tech
Graph2 = Finance_Sum;
Graph2Color = 4;      //Red - Finance
Graph3 = Materials_Sum;
Graph3Color = 5;      //Green - Mater.
Graph4 = Health_Sum;
Graph4Color = 7;      //Yellow - Health
Graph5 = Utility_Sum;
Graph5Color = 11;      //Green - Utility
Graph6 = ConsumerDSS_Sum;
Graph6Color = 9;      //Gold - ConsumerDSS
Graph7 = ConsumerStaples_Sum;
Graph7Color = 12;      //Purple - ConsumerStaples
Graph8 = Industry_Sum;
Graph8Color = 15;      //Brick - Industry
Graph9 = HomeBuilding_Sum;
Graph9Color = 19;      //DarkGreen - HomeBuilding
Graph10 = Retail_Sum;
Graph10Color = 39;      //Grey - Retail


Graph0Style = 4;
Graph1Style = 4;
Graph2Style = 4;
Graph3Style = 4;
Graph4Style = 4;
Graph5Style = 4;
Graph6Style = 4;
Graph7Style = 4;
Graph8Style = 4;
Graph9Style = 4;
Graph10Style = 4;
Sector_Rotation.png

评分

2

查看全部评分

回复 鲜花 鸡蛋

使用道具 举报

发表于 2010-1-9 04:57 PM | 显示全部楼层
回复 鲜花 鸡蛋

使用道具 举报

发表于 2010-1-9 05:05 PM | 显示全部楼层
3# sandera

刚刚又从新改了一下code. 加入了用Expressing geometric relative return方法计算各sector相对spx的强弱。大于0代表强于大盘。

//------------------------------------------------------------ ...
Ave 发表于 2010-1-9 15:51


谢谢了.

我要好好看看这个新图.
回复 鲜花 鸡蛋

使用道具 举报

发表于 2010-1-9 06:10 PM | 显示全部楼层
thanks for sharing
回复 鲜花 鸡蛋

使用道具 举报

发表于 2010-1-9 07:13 PM | 显示全部楼层
回复 鲜花 鸡蛋

使用道具 举报

发表于 2010-1-9 07:56 PM | 显示全部楼层
回复 鲜花 鸡蛋

使用道具 举报

发表于 2010-1-9 08:29 PM | 显示全部楼层
回复 鲜花 鸡蛋

使用道具 举报

发表于 2010-1-10 02:37 AM | 显示全部楼层
Good stuff, understand the code now. But I don't have amibrocker
回复 鲜花 鸡蛋

使用道具 举报

发表于 2010-1-10 02:41 AM | 显示全部楼层
4# Ave

Your title colors and your comment colors and your real colors used in code/graph are different. But I suspect nobody will really match those...

回复 鲜花 鸡蛋

使用道具 举报

发表于 2010-1-10 03:22 AM | 显示全部楼层
many thanks!
回复 鲜花 鸡蛋

使用道具 举报

发表于 2010-1-10 10:45 AM | 显示全部楼层
本帖最后由 大泡泡 于 2010-1-10 09:56 编辑

4# Ave

Nice code. Thanks.

A little change to the color title to make it clear.


//------------------------------------------------------------------------------
//
//  Formula Name:    Sector Tracking
//
//------------------------------------------------------------------------------
//
//  Tracks normalized sector performance
//  Performance is tracked by a 13 day exp moving average
//  and finally the sum of 9 days to smooth out the data.
//
//  CAUTION: You may need to edit the symbol for SP 500 index if different
//  for your data source
//------------------------------------------------------------------------------

// Plot the 13 week EMA of incremental differences
// This is useful for finding strengthening sectors / industries
// Normalize data


//Title = "Sectors: Energy(BrightBlue)-Tech(White)-Finance(Red)-Materials(BrightGreen)-Health(Yellow)-Utility(Pink)-Gold(DSS)-Purple(Staples)-Brick(Industry)-DarkGreen(HomeBuilding)-Grey(Retail)";

Sum_Filter = 9;

Energy                     = Foreign("XLE","Close",fixup=1);
Tech                       = Foreign("XLK","Close",fixup=1);
Finance                    = Foreign("XLF","Close",fixup=1);
Materials                  = Foreign("XLB","Close",fixup=1);
Health                            = Foreign("XLV","Close",fixup=1);
Utility                    = Foreign("XLU","Close",fixup=1);
ConsumerDSS           = Foreign("XLY","Close",fixup=1);
Industry                        = Foreign("XLI","Close",fixup=1);
ConsumerStaples  = Foreign("XLP","Close",fixup=1);
HomeBuilding           = Foreign("XHB","Close",fixup=1);
Retail                           = Foreign("XRT","Close",fixup=1);
SP500                           = Foreign("^GSPC","close");

Energy_Perf       = EMA(ROC(Energy,1), 13);
Tech_Perf         = EMA(ROC(Tech,1), 13);
Finance_Perf      = EMA(ROC(Finance,1), 13);
Materials_Perf    = EMA(ROC(Materials,1),13);
Health_Perf       = EMA(ROC(Health,1),13);
Utility_Perf      = EMA(ROC(Utility,1),13);
ConsumerDSS_Perf  = EMA(ROC(ConsumerDSS,1),13);
Industry_Perf     = EMA(ROC(Industry,1),13);
ConsumerStaples_Perf  = EMA(ROC(ConsumerStaples,1),13);
HomeBuilding_Perf  = EMA(ROC(HomeBuilding,1),13);
Retail_Perf                   = EMA(ROC(Retail,1),13);
SP500_Perf                   = EMA(ROC(SP500,1),13);

SP500_ref = MA(SP500_Perf,Sum_filter);

Energy_Sum        = (1 + MA(Energy_Perf,Sum_Filter))/(1 + SP500_ref)-1;
Tech_Sum          = (1 + MA(Tech_Perf,Sum_Filter))/(1 + SP500_ref)-1;
Finance_Sum       = (1 + MA(Finance_Perf,Sum_Filter))/(1 + SP500_ref)-1;
Materials_Sum     = (1 + MA(Materials_Perf,Sum_Filter))/(1 + SP500_ref)-1;
Health_Sum        = (1 + MA(Health_Perf,Sum_Filter))/(1 + SP500_ref)-1;
Utility_Sum       = (1 + MA(Utility_Perf,Sum_Filter))/(1 + SP500_ref)-1;
ConsumerDSS_Sum   = (1 + MA(ConsumerDSS_Perf,Sum_Filter))/(1 + SP500_ref)-1;
ConsumerStaples_Sum = (1 + MA(ConsumerStaples_Perf,Sum_Filter))/(1 + SP500_ref)-1;
Industry_Sum      = (1 + MA(Industry_Perf,Sum_Filter))/(1 + SP500_ref)-1;
HomeBuilding_Sum  = (1 + MA(HomeBuilding_Perf,Sum_Filter))/(1 + SP500_ref)-1;
Retail_Sum        = (1 + MA(Retail_Perf,Sum_Filter))/(1 + SP500_ref)-1;

/*
Backtest performance by selectig top sector to buy
Buy when rel performance above 0 and slope maximum
Sell when slope decreass relative to another sector
Always be in the market
*/

Filter = Close > 0;
NumColumns = 11;
Column0Name = "Energy";
Column0     = Energy_Sum;
Column1Name = "Tech";
Column1     = Tech_Sum;
Column2Name = "Finance";
Column2     = Finance_Sum;
Column3Name = "Materials";
Column3     = MAterials_Sum;
Column4Name = "Health";
Column4     = Health_Sum;
Column5Name = "Utility";
Column5     = Utility_Sum;
Column6Name = "ConsumerDSS";
Column6     = ConsumerDSS_Sum;
Column7Name = "ConsumerStaples";
Column7     = ConsumerStaples_Sum;
Column8Name = "Industry";
Column8     = Industry_Sum;
Column9Name = "HomeBuilding";
Column9     = HomeBuilding_Sum;
Column10Name = "Retail";
Column10     = Retail_Sum;

Plot(Energy_Sum, "Energy", 10,4);
Plot(Tech_Sum, "Tech", 2,4);
Plot(Finance_Sum, "Finance", 4,4);
Plot(Materials_Sum, "Materials", 5,4);
Plot(Health_Sum, "Health", 7,4);
Plot(Utility_Sum, "Utility", 11,4);
Plot(ConsumerDSS_Sum, "DSS", 9,4);
Plot(ConsumerStaples_Sum, "Staples", 12,4);
Plot(Industry_Sum, "Industry", 15,4);
Plot(HomeBuilding_Sum, "HomeBuilding", 19,4);
Plot(Retail_Sum, "Retail", 39,4);


Plot(0,"",colorWhite,4);
ScreenHunter_01 Jan. 10 09.44.gif
回复 鲜花 鸡蛋

使用道具 举报

 楼主| 发表于 2010-1-10 11:48 AM | 显示全部楼层
14# 大泡泡

又学了一招, 谢谢! 看到版主给钻了,就不能在懒了, 加了些option. 现在可以自己选EMA和MA的period, 以及计算return的方法: "0" - Arithmatic Return; "1" - Expressing geometric relative return.

//------------------------------------------------------------------------------
//
//  Formula Name:    Sector Tracking
//
//  Tracks normalized sector performance
//  Performance is tracked by a 13 day exp moving average
//  and finally the sum of 9 days to smooth out the data.
//
//  CAUTION: You may need to edit the symbol for SP 500 index if different
//  for your data source
//------------------------------------------------------------------------------

// Plot the 13 week EMA of incremental differences
// This is useful for finding strengthening sectors / industries
// Normalize data
/*
Backtest performance by selectig top sector to buy
Buy when rel performance above 0 and slope maximum
Sell when slope decreass relative to another sector
Always be in the market
*/
//Title = "Sectors: Energy(BrightBlue)-Tech(White)-Finance(Red)-Materials(BrightGreen)-Health(Yellow)-Utility(Pink)-Gold(DSS)-Purple(Staples)-Brick(Industry)-DarkGreen(HomeBuilding)-Grey(Retail)";

SetChartOptions(0, chartShowDates);
EMA_Period = Param("EMA Period", 13, 1, 50);
MA_Period = Param("MA Period", 9, 1, 20);
Method = Param("Return Calculation Method", 0, 0, 1);
// "0" - Arithmatic Return; "1" - Expressing geometric relative return;

Energy           = Foreign("XLE","Close",fixup=1);
Tech             = Foreign("XLK","Close",fixup=1);
Finance          = Foreign("XLF","Close",fixup=1);
Materials        = Foreign("XLB","Close",fixup=1);
Health           = Foreign("XLV","Close",fixup=1);
Utility          = Foreign("XLU","Close",fixup=1);
ConsumerDSS      = Foreign("XLY","Close",fixup=1);
Industry         = Foreign("XLI","Close",fixup=1);
ConsumerStaples  = Foreign("XLP","Close",fixup=1);
HomeBuilding     = Foreign("XHB","Close",fixup=1);
Retail           = Foreign("XRT","Close",fixup=1);
SP500            = Foreign("^GSPC","close");

Energy_Perf          = EMA(ROC(Energy,1), EMA_Period);
Tech_Perf            = EMA(ROC(Tech,1), EMA_Period);
Finance_Perf         = EMA(ROC(Finance,1), EMA_Period);
Materials_Perf       = EMA(ROC(Materials,1),EMA_Period);
Health_Perf          = EMA(ROC(Health,1),EMA_Period);
Utility_Perf         = EMA(ROC(Utility,1),EMA_Period);
ConsumerDSS_Perf     = EMA(ROC(ConsumerDSS,1),EMA_Period);
Industry_Perf        = EMA(ROC(Industry,1),EMA_Period);
ConsumerStaples_Perf = EMA(ROC(ConsumerStaples,1),EMA_Period);
HomeBuilding_Perf    = EMA(ROC(HomeBuilding,1),EMA_Period);
Retail_Perf          = EMA(ROC(Retail,1),EMA_Period);
SP500_Perf           = EMA(ROC(SP500,1),EMA_Period);

SP500_ref = MA(SP500_Perf,MA_Period);

if (Method == 0)

{Energy_Sum         = MA(Energy_Perf,MA_Period)- SP500_ref;
Tech_Sum            = MA(Tech_Perf,MA_Period) - SP500_ref;
Finance_Sum         = MA(Finance_Perf,MA_Period) - SP500_ref;
Materials_Sum       = MA(Materials_Perf,MA_Period) - SP500_ref;
Health_Sum          = MA(Health_Perf,MA_Period) - SP500_ref;
Utility_Sum         = MA(Utility_Perf,MA_Period) - SP500_ref;
ConsumerDSS_Sum     = MA(ConsumerDSS_Perf,MA_Period) - SP500_ref;
ConsumerStaples_Sum = MA(ConsumerStaples_Perf,MA_Period) - SP500_ref;
Industry_Sum        = MA(Industry_Perf,MA_Period) - SP500_ref;
HomeBuilding_Sum    = MA(HomeBuilding_Perf,MA_Period) - SP500_ref;
Retail_Sum          = MA(Retail_Perf,MA_Period) - SP500_ref;}

else
{Energy_Sum        = (1 + MA(Energy_Perf,MA_Period))/(1 + SP500_ref)-1;
Tech_Sum          = (1 + MA(Tech_Perf,MA_Period))/(1 + SP500_ref)-1;
Finance_Sum       = (1 + MA(Finance_Perf,MA_Period))/(1 + SP500_ref)-1;
Materials_Sum     = (1 + MA(Materials_Perf,MA_Period))/(1 + SP500_ref)-1;
Health_Sum        = (1 + MA(Health_Perf,MA_Period))/(1 + SP500_ref)-1;
Utility_Sum       = (1 + MA(Utility_Perf,MA_Period))/(1 + SP500_ref)-1;
ConsumerDSS_Sum   = (1 + MA(ConsumerDSS_Perf,MA_Period))/(1 + SP500_ref)-1;
ConsumerStaples_Sum = (1 + MA(ConsumerStaples_Perf,MA_Period))/(1 + SP500_ref)-1;
Industry_Sum      = (1 + MA(Industry_Perf,MA_Period))/(1 + SP500_ref)-1;
HomeBuilding_Sum  = (1 + MA(HomeBuilding_Perf,MA_Period))/(1 + SP500_ref)-1;
Retail_Sum        = (1 + MA(Retail_Perf,MA_Period))/(1 + SP500_ref)-1;}

Plot(Energy_Sum, "Energy", 10,4);
Plot(Tech_Sum, "Tech", 2,4);
Plot(Finance_Sum, "Finance", 4,4);
Plot(Materials_Sum, "Materials", 5,4);
Plot(Health_Sum, "Health", 7,4);
Plot(Utility_Sum, "Utility", 11,4);
Plot(ConsumerDSS_Sum, "DSS", 9,4);
Plot(ConsumerStaples_Sum, "Staples", 12,4);
Plot(Industry_Sum, "Industry", 15,4);
Plot(HomeBuilding_Sum, "HomeBuilding", 19,4);
Plot(Retail_Sum, "Retail", 39,4);


Plot(0,"",colorWhite,4);
回复 鲜花 鸡蛋

使用道具 举报

 楼主| 发表于 2010-1-10 11:50 AM | 显示全部楼层
Good stuff, understand the code now. But I don't have amibrocker
ranchgirl 发表于 2010-1-10 01:37


Do you use NinjaTrader? It's free of use, and can do coding too. I did not look into it, but you can try...

评分

1

查看全部评分

回复 鲜花 鸡蛋

使用道具 举报

发表于 2010-1-10 09:49 PM | 显示全部楼层
Do you use NinjaTrader? It's free of use, and can do coding too. I did not look into it, but you can try...
Ave 发表于 2010-1-10 10:50


Actually, I am a beginner, I did not know either one of them.

I wrote my own baby technical analysis program in ruby, but all in text, no graphical interface. I think I can implement your algorithm into my code.

I will look into NinjaTrader to see what it can do for me.

Thank you very much for sharing your code and algorithm.

    
回复 鲜花 鸡蛋

使用道具 举报

发表于 2010-1-11 01:53 AM | 显示全部楼层
wow
回复 鲜花 鸡蛋

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|www.hutong9.net

GMT-5, 2024-4-28 02:21 PM , Processed in 0.193523 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表