西沙浪人 發表於 17-8-10 15:09

请问 MC 想第二个交易讯号出现, 才进场交易, 怎么编写


以下假设 以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 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;



頁: [1]
查看完整版本: 请问 MC 想第二个交易讯号出现, 才进场交易, 怎么编写