limanc 發表於 14-6-9 03:40

MACD(9,26,9)的入市策略分享

簡單的MACD入市策略分享:

造好:
MACD(9,26,9)慢線由零線之下升至零線之上後,繼而再發出買入訊號便入市造好,收市價升穿20SMA止賺或RSI(7)跌至20止蝕。

造淡:
MACD(9,26,9)慢線由零線之上跌至零線之下後,繼而再發出沽出訊號便入市造淡,收市價跌穿20SMA止賺或RSI(7)升至80止蝕。


SetPositionSize(1,spsShares);


red=Ref(Signal(9,26,9),-1)<0 AND Signal(9,26,9)>0;
dark=Ref(Signal(9,26,9),-1)>0 AND Signal(9,26,9)<0;
Buy=0;
Sell=0;
Short=0;
Cover=0;
MACDarray=MACD(9,26);
Signalarray=Signal(9,26,9);
GoldCross = Cross(MACDarray, Signalarray);
DeadCross = Cross(Signalarray, MACDarray);
rsiARRAY=RSI(7);
MAarray=MA(Close,20);
Higharray=High;
Lowarray=Low;
Closearray=Close;
Buysignal=False;
Shortsignal=False;
positionhold=0;

for (i=0; i <BarCount; i++)

{

   if (red==True AND positionhold==0)
   {
    Buysignal=True;
    }

   else if (Buysignal==True AND GoldCross AND positionhold==0)

   {

    Buy=1;
   positionhold++;

   }

   else if (positionhold>0 AND Closearray>MAarray OR RSIARRAY<20)
   {
    Sell=1;
    positionhold=0;
    }

   else if (dark==True AND positionhold==0)

    {
   Shortsignal=True;
    }
   
    else if (Shortsignal==True AND DeadCrossAND positionhold==0)
    {

   Short=1;
   positionhold--;
    }

    else if (positionhold<0 AND Closearray<MAarrayOR RSIARRAY>80)

    {
   Cover=1;
    positionhold=0;
    }

}
   
PlotShapes( Buy*shapeUpArrow, colorBlue, 0, Low -2);
PlotShapes (Sell*shapeDownArrow, colorPink, 0, High + 2);

PlotShapes( Short*shapeDownArrow, colorRed, 0, High +2);
PlotShapes (Cover*shapeUpArrow,colorGreen, 0, Low -2);

資料來源: 量化交易研究中心(QUANTS)

annie0612 發表於 14-6-9 12:23

謝謝分享~~~~~~~~~~~~~~~~~~~~~~~

a25575703 發表於 14-6-9 20:39

感謝版大的分享。

HaoShu 發表於 14-6-10 12:16

感謝分享                              
頁: [1]
查看完整版本: MACD(9,26,9)的入市策略分享