设为首页收藏本站

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

无法编译,请老师帮忙看看,哪儿出问题了哦 [复制链接]

Rank: 1

精华
0
UID
190699
积分
12
帖子
11
主题
1
阅读权限
10
注册时间
2014-7-16
最后登录
2023-5-13
跳转到指定楼层
1#
发表于 2017-10-17 13:09:56 |只看该作者 |倒序浏览
//------------------------------------------------------------------------
// 简称: tb5
// 名称: 加减仓策略怎么实验2
// 类别: 公式应用
// 类型: 用户应用
// 输出:
//------------------------------------------------------------------------

//------------------------------------------------------------------------
// 简称: tb3
// 名称: 加减仓策略
// 类别: 公式应用
// 类型: 用户应用
// 输出:
//------------------------------------------------------------------------
Params
        Numeric LEFast(5);         //多头入场短均线周期参数
        Numeric LESlow(20);        //多头入场长均线周期参数
        Numeric LXFast(3);         //多头出场短均线周期参数
        Numeric LXSlow(10);        //多头出场长均线周期参数
        Numeric SEFast(5);         //空头入场短均线周期参数
        Numeric SESlow(20);        //空头入场长均线周期参数
        Numeric SXFast(3);         //空头出场短均线周期参数
        Numeric SXSlow(10);        //空头出场长均线周期参数

Vars
    Numeric MinPoint;// 一个最小变动单位,也就是一跳
    NumericSeries FirstPrice;// 第一次开仓价格
    NumericSeries LastPrice;// 最后一次开仓价格
        Numeric AddSet(30);// 加仓设置
    Numeric SubSet(30);// 减仓设置
    Bool FirstEntryCon;// 首次开仓条件

        NumericSeries MALEFast;//多头入场短均线
    NumericSeries MALESlow;//多头入场长均线
        NumericSeries MALXFast;//多头出场短均线
        NumericSeries MALXSlow;//多头出场长均线
        NumericSeries MASEFast;//空头入场短均线
        NumericSeries MASESlow;//空头入场长均线
        NumericSeries MASXFast;//空头出场短均线
        NumericSeries MASXSlow;//空头出场长均线


Begin

    MALEFast=Average(Close,LEFast);//多头入场短均线
        MALESlow=Average(Close,LESlow);//多头入场长均线
        MALXFast=Average(Close,LXFast);//多头出场短均线
        MALXSlow=Average(Close,LXSlow);//多头出场长均线
        MASEFast=Average(Close,SEFast);//空头入场短均线
        MASESlow=Average(Close,SESlow);//空头入场长均线
        MASXFast=Average(Close,SXFast);//空头出场短均线
        MASXSlow=Average(Close,SXSlow);//空头出场长均线


    FirstEntryConD = ( MALEFast[1] > MALESlow[1] and MALXFast[1] > MALXSlow[1] and High >= High[1] And Vol > 0 );
    FirstEntryConK = ( MASEFast[1] < MASESlow[1] and MASXFast[1] < MASXSlow[1] and Low <= Low[1] And Vol > 0 );
    MinPoint = MinMove*PriceScale;

If(MarketPosition==0)
{
    If(FirstEntryConD)
    {
    FirstPrice = Open;
    LastPrice = firstPrice;
    Buy(2,firstPrice);
    }
}else If(MarketPosition==1) // 有多仓的情况
{
        While(CurrentEntries < 4 && High >= LastPrice + AddSet*MinPoint) // 加仓
    {
    LastPrice = LastPrice + AddSet*MinPoint;
    if(Open > LastPrice) LastPrice = Open;
    Buy(1,LastPrice);
    }

    While(CurrentEntries > 0 && Low <= firstPrice - SubSet*MinPoint) // 减仓
    {
    firstPrice = firstPrice - SubSet*MinPoint;
    if(Open < firstPrice) firstPrice = Open;
    Sell(1,firstPrice);
    }
}


   


If(MarketPosition==0)
{
    If(FirstEntryConK)
    {
    FirstPrice = Open;
    LastPrice = firstPrice;
    SellShort(2,firstPrice);
    }
}else If(MarketPosition==1) // 有多仓的情况
{
    While(CurrentEntries < 4 && High <= LastPrice - AddSet*MinPoint) // 加仓
    {
    LastPrice = LastPrice - AddSet*MinPoint;
    if(Open < LastPrice) LastPrice = Open;
    SellShort(1,LastPrice);
    }

    While(CurrentEntries > 0 && Low >= firstPrice + SubSet*MinPoint) // 减仓
    {
    firstPrice = firstPrice + SubSet*MinPoint;
    if(Open > firstPrice) firstPrice = Open;
    BuyToCover(1,firstPrice);
    }
}
End
//------------------------------------------------------------------------
// 编译版本        GS2015.12.25
// 用户版本        2017/10/17 12:22:00
// 版权所有        ranjianlin
// 更改声明        TradeBlazer Software保留对TradeBlazer平台
//                        每一版本的TradeBlazer公式修改和重写的权利
//------------------------------------------------------------------------

//------------------------------------------------------------------------
// 编译版本        GS2015.12.25
// 用户版本        2017/10/17 12:56:52
// 版权所有        ranjianlin
// 更改声明        TradeBlazer Software保留对TradeBlazer平台
//                        每一版本的TradeBlazer公式修改和重写的权利
//------------------------------------------------------------------------

Rank: 10Rank: 10Rank: 10

精华
0
UID
209716
积分
2226
帖子
2131
主题
0
阅读权限
200
注册时间
2015-5-25
最后登录
2020-5-29
2#
发表于 2017-10-17 13:23:51 |只看该作者
FirstEntryConD跟FirstEntryConK没有声明,您在vars里面声明bool型试试。

使用道具 举报

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

bottom

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

GMT+8, 2024-4-20 06:44

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部