| 以下假设 以MACD 2次金叉为例,好像有点问题,求指点。
 
 inputs:  FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ;
 variables:  var0( 0 ), var1( 0 ), var2( 0 ), buyflag(false), sellflag(false),marketposition(0),value1(false);
 
 var0 = MACD( Close, FastLength, SlowLength ) ;
 var1 = XAverage( var0, MACDLength ) ;
 var2 = var0 - var1 ;
 
 condition1 = CurrentBar > 2 and var2 crosses over 0 ;
 value1=false;
 
 if date>date[1] then begin
 buyflag=false;
 end;
 
 if buyflag=false then begin
 if condition1 and marketposition=0 then buyflag=true;
 
 if buyflag and var2<0 then value1=true;
 if value1 and condition1 and marketposition=0 then
 Buy ( "LE" ) next bar at market ;
 
 if marketposition=1 and var2 cross under 0 then sell next bar at market;
 end;
 
 if time=1600 and marketposition<>0 then sell all contracts next bar at market;
 
 
 
 
 |