设为首页收藏本站

 找回密码
 注册
查看: 2088|回复: 0
打印 上一主题 下一主题

找了一个龟汤交易程序,能通过编译,不产生交易信号,请哪位老师指导一下. [复制链接]

Rank: 1

精华
0
UID
219116
积分
6
帖子
3
主题
3
阅读权限
10
注册时间
2015-9-8
最后登录
2016-4-17
跳转到指定楼层
1#
发表于 2015-12-31 05:36:40 |只看该作者 |倒序浏览
规则:
   *今天市场创20天以来的新低;
   *前一个20天新低必须出现在至少4个交易日以前;(需要考虑barnumber)
    *在市场创20天以来新低以后,在前期低点以上5-10点放置停损买入单(当天有效);
    博主按:这里必明确创新低多少距离才放停损买入单,否则创新低距离很小(比如一个最小波动点)就放置停损单的话,很容易被触发。
    这里用atr来计算突破距离,做为突破的确认。
    *如果买入停损成交,马上放置在当天日低以下放置GTC止损卖单;
    *当头寸开始获利,使用追踪停损Trail保护利润,其中一些交易可能持续2-3小时,一些可能持续几天;



Params
    Numeric BreakedDays(4);
    Numeric FactorAtr(0.2);
        Numeric lenth(20);
        Numeric offset(5);
        Numeric LenAtr(20);
Vars
        Bool Condition1;
        Bool Condition2;
        
        NumericSeries var1(0);
        NumericSeries var2(0);
        NumericSeries var3(0);
        NumericSeries var4(0);
        Bool Bcon1(false);
        Bool Scon1(false);
        
        NumericSeries mp(0);
        Numeric MinPoint;
        
        Numeric Value1;
        Numeric value2;
        Numeric value3;
        NumericSeries value4;
        NumericSeries value5;

        
Begin
        
minpoint=MinMove*PriceScale;
mp=marketposition;

//*****************entrycondition*****************//
var3=lowest(L,lenth);
var4=Highest(h,lenth);

if(date<>date[1])
{
  if(L<var3[1])
  {
   var1=1;
  }
  else
  {
   var1=var1[1]+1;
  }
  if(H>var4[1])
  {
   var2=1;
  }
  else
  {
   var2=var2[1]+1;
  }
  Bcon1=var1>=BreakedDays;
  Scon1=var2>=BreakedDays;
}

value1=AvgTrueRange(LenAtr)*FactorAtr;
condition1= Bcon1==true and L<var3 and (var3-L)>=value1 and marketposition==0;
condition2= Scon1==true and H>var4 and (H-var4)>=value1 and marketposition==0;

//*****************entry*****************//

if(condition1)
{
buy(1,var3+offset*MinPoint);
}
if(condition2)
{
sellshort(1,var4-offset*MinPoint);
}

//*****************trail stop*****************//


//----trail stop value----
if(marketposition==1 and mp[1]==0)
{
value2=(entryprice-LowD(0)-minpoint);
}
if(marketposition==-1 and mp[1]==0)
{
value3=(HighD(0)-entryprice+minpoint);
}

//L trail stop
if(marketposition==1)
{
  if(mp[1]==0)
{
  value4=high;
}
else
{
  value4=max(high,value4[1]);
}
sell(1,value4-value2);
}

//S trail stop
if(marketposition==-1)
{
  if(mp[1]==0)
  {
   value5=low;
  }
  else
  {
   value5=min(low,value5[1]);
  }
  buytocover(1,value5+value3);
}

End
您需要登录后才可以回帖 登录 | 注册

bottom

静态版|手机版|联系我们|交易开拓者 ( 粤ICP备07044698   

GMT+8, 2024-5-22 18:23

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部