聚沙成塔ING : 使用CCI 做成當沖程式(程式碼)

 

這是我多年前使用的程式 ! 其實還蠻穩定的 .雖然並無非常可觀的績效,不過這也是一種參考點 !

Parameter: n(10) ,Price(close), Length(20), UpMultiplier(2.0), DnMultiplier(-2.0),Length_1(30),L停損金額(2400),停損金額(1200)
var : up100(0) , low100(0) ,center(0),StopLossAmount(0), OrderPrice(0),DT(0)
if date[0] <> date[1] then DT=0 end if
up100 =100
low100=-100
center=0
/////////時間////////////
Condition1= time > 133000
Condition2= time > 90000
Condition3= time < 130000
/////////////////////////
//////買進//////////////
Condition4= cci(Length) cross over low100
//////買平倉////////////
Condition5= cci(Length) cross over low100
Condition8= cci(Length) cross over center
Condition9= cci(Length) cross over up100
//////濾網條件//////////
Condition6= vhf(n,length)>0.333
Condition7= vhf(n,length)<0.333
Condition10= cci(Length) cross under low100
Condition11= cci(Length) cross under center
Condition12= cci(Length) cross under up100

if (Condition2 and Condition3 ) and ( Condition6 and (Condition5)and( cci(Length)>-90)  ) or ( Condition6 and (Condition9)and( cci(Length)>110)  ) and dt =0 then
buy("買") next bar on market
DT=DT+1
end if

if (marketposition=1) and (Condition1 )or (Condition12 and Condition10) then
exitlong("買出") next bar on market
end if
if (Condition2 and Condition3 ) and ( Condition6 and (Condition12)and( cci(Length)>-90)  ) or ( Condition6 and (Condition10)and( cci(Length)>110)  ) and dt =0 then

sell("賣") next bar on market
DT=DT+1
end if
if (marketposition=-1) and (Condition1 )or ( Condition5 and Condition9 )then
exitshort("賣出") next bar on market
end if
If MarketPosition = 1 Then
 StopLossAmount = 停損金額 + Commission_B
    OrderPrice = Entryprice(0) - (StopLossAmount / PointValue)
 ExitLong ("多單停損") NEXT Bar at OrderPrice Stop
End if

If MarketPosition = -1 Then
 StopLossAmount = 停損金額 + Commission_S
 OrderPrice = EntryPrice(0) + (StopLossAmount/ PointValue)
 ExitShort ("空單停損") NEXT Bar at OrderPrice Stop
End if

If MarketPosition = 1 Then
CNDL_LongBody(Length)
 StopLossAmount = L停損金額 + Commission_B
    OrderPrice = Entryprice(0) - (StopLossAmount / PointValue)
 ExitLong ("長陰多單停損") THIS Bar at OrderPrice Stop
End if

If MarketPosition = -1 Then
CNDL_LongBody(Length)
 StopLossAmount = L停損金額 + Commission_S
 OrderPrice = EntryPrice(0) + (StopLossAmount/ PointValue)
 ExitShort ("長陽空單停損") THIS Bar at OrderPrice Stop
End if

if time>=131500  then
exitlong("b_out")NEXT BAR ON MARKET                                          
end if
if time>=131500 then
exitshort("s_out")NEXT BAR ON MARKET
end if
if  time>131500 then
EXITLONG ("T_BOUT") THIS BAR ON CLOSE
EXITSHORT ("T_SOUT") THIS BAR ON CLOSE
END IF

Posted by Picasa
arrow
arrow
    全站熱搜

    阿唐 發表在 痞客邦 留言(0) 人氣()