|
本帖最後由 allen0925 於 10-10-7 11:53 AM 編輯
回復 31# trading144
程式碼很簡單
/*aa=2
bb=34
多單 con1=cross(ma((h+l)/2,bb)[2],ma(h,aa)[2])
平多 con1=cross(ma(l,aa)[1],ma((h+l)/2,bb)[1])
空單 con1=cross(ma(l,aa)[2],ma((h+l)/2,bb)[2])
平空 con1=cross(ma((h+l)/2,bb)[1],ma(h,aa)[1])
*/
nMidP = (h + l)/2 ;
nMa34 = AverageFC( nMidP, 34 ) ;
nH = AverageFC( H, 2 ) ;
nL = AverageFC( L, 2 ) ;
condition1 = nMa34[1] cross above nH[1] ;
condition2 = nL cross above nMa34 ;
condition3 = nL[1] cross above nMa34[1] ;
condition4 = nMa34 cross above nH ;
if condition1 then
Buy ( "B" ) next bar at market ;
if condition2 then
sell ( "S" ) next bar at market ;
if condition3 then
sellshort ( "1" ) next bar at market ;
if condition4 then
buytocover ( "2" ) next bar at market ; |
|