- 最后登录
- 2012-2-15
- 注册时间
- 2012-1-13
- 阅读权限
- 20
- 帖子
- 4
- 精华
- 0
- 积分
- 107
 
|
本帖最后由 cjyjgz 于 2012-1-16 17:57 编辑
inputs: InitialBalance(500000),P1(20),BaoZhengJinLv(0.15),YiShouDanWeiShu(5);
vars: AccountBalance(0),
LTT(0);
/// T//////////////////////////////////////
AccountBalance = InitialBalance + netprofit;
LTT = IntPortion(AccountBalance*0.5/(C*YiShouDanWeiShu*BaoZhengJinLv)); /// IntPortion(DollarRisk*10/DV); //////////////////////////////////////
condition1 = Average(CLOSE,P1) > Average(CLOSE,P1)[1] ;
condition2 = Average(CLOSE,P1) < Average(CLOSE,P1)[1] ;
condition3 = c>entryprice(1)*1.15;
condition4 = c<entryprice(1)*0.85;
if marketposition = 0 then begin
IF condition1 then begin //LTT shares//
buy LTT shares this bar close;
end;
if condition2 then begin
sellshort LTT shares this bar close;
end;
end;
if marketposition = -1 then begin
IF condition1 then begin
buytocover LTT shares this bar close;
buy LTT shares this bar close;
if condition4 then begin
sellshort 1 share this bar close;
end;
end;
if condition4 then begin
sellshort 1 share this bar close;
end;
end;
if marketposition = 1 then begin
if condition2 then begin
sell LTT shares this bar close;
sellshort LTT shares this bar close;
if condition3 then begin
buy 1 share this bar close;
end;
end;
end;
请前辈看一下上面的代码,我的想法是买入后价格上涨15%时加仓,但是系统指示却在下一次多转空的时候加仓并且平仓了。
请问代码中问题出现在哪里?谢谢!
|
|