加入 |登录

策略交易高峰会论坛EasyLanguage/PowerLanguage 策略语言研究 › 查看主题

233

查看

1

回复
返回列表

Rank: 2Rank: 2

go

[编程求助] 请教获利加仓的问题

楼主
发表于 2012-1-16 17:54 | 只看该作者 | 倒序看帖 | 打印
本帖最后由 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%时加仓,但是系统指示却在下一次多转空的时候加仓并且平仓了。


求助.jpg


请问代码中问题出现在哪里?谢谢!

TOP

好文分享,是超英赶美的关键! QQ书签=>QQ书签 百度搜藏=>百度搜藏

Google书签=> Google书签 新浪Vivi=> 新浪ViVi

Rank: 2Rank: 2

沙发
发表于 2012-1-16 18:10 | 只看该作者
刚刚自己在信号属性里调了一下,解决了。

TOP

策略交易高峰会 |联系我们

GMT+8, 2012-2-23 15:50, Processed in 0.034172 second(s), 13 queries.

Powered by Discuz! X1

© 2001-2010 Comsenz Inc.