作者:Chen Peter
Adaptive price zone
使用的是平滑化的移動平均和基本的ADX指標。
當ADX value<2 且跌破70的平滑化的移動平均下線就買進。
Example:
買進 賣出
2012/5/15 上午 10:29:00 |
2012/5/15 下午 01:29:00 |
賺 7400-7349 = 51點。
回測使用的是小時為區間。這策略的優點是結合兩種指標來判斷可能的超跌點。
上面的圖灰線就是上下平滑化的移動平均線。
使用amibroker code為:
SetTradeDelays(0, 0, 0, 0);
SetOption("InitialEquity", 100000);
SetOption("MaxOpenPositions",1);
SetOption("CommissionMode", 3); //count hand cost by how much future
SetOption("CommissionAmount", 100); //one future hand cost 50 dollars
SetOption("FuturesMode", 1); //
SetPositionSize(1, spsShares);
function DblSmoothEMA(price,Length)
{
period =IIf(Length < 0,1,sqrt(Length));
smooth = 2/(period+1);
returnAMA(AMA(price,smooth),smooth);
}
SetTradeDelays(0,0,0,0);
BuyPrice = C;
SellPrice = C;
price = C;
period =70;//Optimize("period",10,10,100,10);
BandPct = 2.2;//Optimize("width[%]",0.4,0.4,4,0.3);
DsEMA =DblSmoothEMA(price,period);
RangeDsEMA= DblSmoothEMA(H-L,period);
UpBand = BandPct*RangeDsEMA + DsEMA;
DnBand = DsEMA - BandPct * RangeDsEMA;
ADXThshold = 46;//Optimize("ADXThshould",2,2,50,4);
ADXLength = 2;//Optimize("ADXLength",2,2,40,4);
ADXValue = ADX(ADXLength);
Buy = ADXValue <= ADXThshold ANDLow <= DnBand;
Sell = ADXValue > ADXThshold;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Plot(C,"Price",colorBlack,styleCandle);
Plot(UpBand,"UpBand",colorLightGrey);
Plot(DnBand,"DnBand",colorLightGrey);
//Plot(Buy*shapeUpArrow,colorGreen,0,DnBand,-24);
//Plot(Sell*shapeDownArrow,colorRed,0,UpBand,-24);
留言列表