開拓者 TB 10倍20倍均線交易策略模型 簡單可參考
作者:開拓者 TB 來源:cxh99.com 發布時間:2012年12月05日
- 思路內容:
若10倍均線大于20倍均線,且20倍均線大于30倍均線,則在5倍均線上穿10倍均線時買入。上漲30個點止盈,或者股價下穿10倍均線止損。
若10倍均線小于20倍均線,且20倍均線小于30倍均線,則在5倍均線下穿10倍均線時賣出。下跌30個點止盈,或者股價上穿10倍均線止損。
僅供參考
- 源碼:
- Params
- Numeric N5(5);
- Numeric N10(10);
- Numeric N20(20);
- Numeric N30(30);
- Numeric stopline(30);
- Vars
- NumericSeries MA5;
- NumericSeries MA10;
- NumericSeries MA20;
- NumericSeries MA30;
- NumericSeries MyPrice;
- //程序化交易
- Begin
- ma5=AverageFC(close,N5);
- ma10=AverageFC(close,n10);
- ma20=AverageFC(close,n20);
- ma30=AverageFC(close,n30);
- PlotNumeric("MA5",MA5);
- PlotNumeric("MA10",MA10);
- PlotNumeric("MA20",MA20);
- PlotNumeric("MA30",MA30);
- If(ma10[1]>ma20[1] And ma20[1]>ma30[1] And MA5[2]<ma10[2] And MA5[1]>ma10[1])
- {
- MyPrice=Open;
- Buy(1,MyPrice);
- }
- If(MarketPosition==1 And BarsSinceEntry>0)
- {
- If(High>=MyPrice+stopline)
- {
- Sell(1,MyPrice+stopline);
- Return;
- }
- else If(Low<=ma10)
- {
- MyPrice=MA10;
- If(MyPrice>Open)MyPrice=Open;
- Sell(1,MyPrice);
- }
- }
- If(ma10[1]<ma20[1] And ma20[1]<ma30[1] And MA5[2]>ma10[2] And MA5[1]<ma10[1])
- {
- MyPrice=Open;
- SellShort(1,MyPrice);
- }
- If(MarketPosition==-1 And BarsSinceEntry>0)
- {
- If(Low<=MyPrice-stopline)
- {
- BuyToCover(1,MyPrice-stopline);
- Return;
- }
- else If(High>=MA10)
- {
- MyPrice=MA10;
- If(MyPrice<Open)MyPrice=Open;
- BuyToCover(1,MyPrice);
- }
- }
- End