: | : | :期货程序化 | :期货程序化研究 | :期货量化学习 | :期货量化 |
返回列表 发帖

[MC源码] 金肯特纳交易策略&改 (已编辑)

感谢版主分享!

TOP

感谢版主分享

TOP

感谢

TOP

Input:price1(close of data1),price2(close of data2);

var:mp(0),timecondition(False),timecondition1(False),timecondition2(False),filtercondition1(False),filtercondition2(False),buycondition(False),sellcondition(False),hltime1(False),hltime2(False),hltime(False);{global var}
var:ma1(0),ma2(0);{filter var}
var:VAR1(0),VAR2(0),beginbar(0),std(0),ma(0);{strategy var}

mp = marketposition;

//trading session model

timecondition1 = time>0930 and time< 1455;
timecondition2 = time>2130 and Time< 2255;
timecondition = timecondition1 or timecondition2;
hltime1 = time > 0905 and Time < 0915;{2high2sell or 2low2buy time}
hltime2 = time > 2105 and time < 2115;
hltime = hltime1 or hltime2;

//filter net model

ma1 = Average(close,5) of data2;
ma2 = Average(close,10)of data2;

filtercondition1 = ma1 > ma2 and Close > minlist(ma1,ma2); //bulltrend
filtercondition2 = ma1 < ma2 and Close < maxlist(ma1,ma2); //beartrend


//strategy model-{Aberration}
{first enter}
ma = Average(price1,35);
std = StandardDev(price1,35,1);
var1 = ma + 2*std;
var2 = ma - 2*std;

buycondition = price1 > var1;
sellcondition = price1 < var2;
{second entry}
condition1 = close[1] < var2[1] and Close > var2;
condition2 = Close[1] > var1[1] and Close < var1;

{buy/sell model}
if mp=0 then begin

if filtercondition1 and buycondition and timecondition then begin
buy("breakout-buy") 1 shares next bar at market;
end;
if filtercondition1 and condition1 and hltime then begin
buy("2low-buy") 1 shares next bar at market;
end;

if filtercondition2 and sellcondition and timecondition then begin
sellshort("breakdown-sell") 1 shares next bar at market;
end;

if filtercondition2 and condition2 and hltime then begin
sellshort("2high-sell") 1 shares next bar at market;
end;

end;

//strategy-exit

if mp=1 and Close < ma and Close-entryprice >= 5 then sell("long-exit") 1 shares next bar at market;
if mp=-1 and Close > ma and entryprice - Close>= 5 then buytocover("short-exit") 1 shares next bar at market;

//time-exit model

if mp<>0 then begin

if Time>1455 and time <1500 then begin
if mp=-1 then buytocover("short-exit at 14:55")1 shares next bar at market;
if mp= 1 then sell("long-exit at 14:55")1 shares next bar at market;
end;

if Time>2255 and time <2300  then begin
if mp=-1 then buytocover("short-exit at 22:55") 1 shares next bar at market;
if mp= 1 then sell("long-exit at 22:55") 1 shares next bar at market;
end;
end;

//set-stop model

if mp<>0 then begin

SetStopContract;

SetProfitTarget(150);

SetPercentTrailing(140,50);
end;
//check model {if strategy has problem,use print check}
{print(ma1);}

TOP

谢谢分享!

TOP

谢谢!

TOP

感謝分享

TOP

谢谢分享

TOP

学习学习

TOP

返回列表