logoslogos 发表于 2011-1-12 18:58:25

系统自动化,取钱ATM化。。。。。。。。。。梦的天堂

红永 发表于 2011-1-23 14:30:38

变量未定义

zyloogle 发表于 2011-2-4 17:02:04

可以学学语法!

shhrx 发表于 2011-3-9 17:33:44

谢谢nopain管理员提供的例子。

outonyi 发表于 2011-4-19 06:24:52

拿分走人,

zhoukaitang 发表于 2011-4-25 14:17:30

If(MarketPosition ==0 ) // 当前空仓  这个应该是持平吧

temop3260 发表于 2011-5-22 22:36:27

一个商品,一个周期,多个系统

yelvshu 发表于 2011-7-31 10:41:44

学习了!谢谢!

lvshulinfeng 发表于 2011-8-1 14:05:01

管理员,把做空的那边顺势交易也一起编出来啊?现在只有做多的交易,没有做空的,不够完善。拿去测试还是比较不错的。

lzl563 发表于 2011-8-10 12:51:38

做空是这样吗,但是我运行了,运行不了。。还是这个系统只适合做多啊

//------------------------------------------------------------------------
// 简称: huangji
// 名称: 顺势2
// 类别: 公式应用
// 类型: 用户应用
// 输出:
//------------------------------------------------------------------------

Params

    Numeric TrailingSet(0.382);       // 回撤开仓比例设置,从最高点下跌的比例

    Numeric StopLossSet(0.5);        // 止损比例设置

Vars

    Bool startCondition(False);         // 启动条件

    Bool EntryCondition(False);        // 开仓条件

    Bool ExitCondition(False);          // 平仓条件

    NumericSeries highestValue(0);  // 前2个周期的最高价

    NumericSeries lowestValue(0);   // 前2个周期的最低价

    Numeric myEntryPrice(0);          // 开仓价格

    Numeric myExitPrice(0);            // 平仓价格        

Begin

    highestValue = highestValue;

    lowestValue = lowestValue;

    If(MarketPosition ==0 ) // 当前空仓

{

        If(Close<Open && Close <Open && Close < Close)

        {

            startCondition = True;

            highestValue = max(high,high);

            lowestValue = min(low,low);

        }

        

        If(startCondition)

        {

            EntryCondition = ((open-LowestValue) / (highestValue - lowestValue) > TrailingSet )&& // 开盘价即满足回撤条件,用开盘价进行交易

            (Open < LowestValue +((highestValue - lowestValue)*StopLossSet)) ; //  开盘价不能低于预设的止损价                                                

            If( EntryCondition)

            {

                SellShort(1,Open);

            }Else // 再看其它价格是否满足

            {

                EntryCondition = (High - LowestValue) / (highestValue - lowestValue) > TrailingSet ; // 最低价满足回撤条件,用低于TrailingSet设置的最近价位建仓

                If(EntryCondition)

                {

                    myEntryPrice = lowestValue + (HighestValue - LowestValue ) * TrailingSet;

                    myEntryPrice = IntPart(myEntryPrice / (PriceScale()*MinMove)) *(PriceScale()*MinMove); // 对价格进行处理                                       

                    If(myEntryPrice >= low &&  myEntryPrice <= High)

                    {

                        SellShort(1,MyEntryPrice);

                    }

                }                        

            }

        }

    }
        else If(MarketPosition == -1) // 当前持空仓

    {

        ExitCondition = ( High - lowestValue )/(highestValue - lowestValue) > StopLossSet;        // 止损条件满足

        If(ExitCondition)

        {

            myExitPrice =  lowestValue +(HighestValue - LowestValue ) * StopLossSet;                        

            myExitPrice = IntPart(myExitPrice / (PriceScale()*MinMove)) *(PriceScale()*MinMove); // 对价格进行处理

          BuyToCover(CurrentContracts(),myExitPrice);

        }Else // 获利平仓

        {

            ExitCondition = (AvgEntryPrice() - low) > (highestValue - lowestValue); // 获利平仓条件满足

            If(ExitCondition)

            {

                myExitPrice =  AvgEntryPrice() - (HighestValue - LowestValue );                                

                myExitPrice = IntPart(myExitPrice / (PriceScale()*MinMove)) *(PriceScale()*MinMove); // 对价格进行处理

                If (myExitPrice >= low && myEntryPrice <= high)

                {

                    BuyToCover(CurrentContracts(),myExitPrice);

                }Else

                {

                    BuyToCover(CurrentContracts(),Close);

                }

            }

        }

    }
       
       
        end

//------------------------------------------------------------------------
// 编译版本        GS2010.12.08
// 用户版本        2011/08/10 11:23
// 版权所有        lzl563
// 更改声明        TradeBlazer Software保留对TradeBlazer平台
//                        每一版本的TrabeBlazer公式修改和重写的权利
//------------------------------------------------------------------------
页: 1 2 3 [4] 5 6 7 8 9 10 11 12
查看完整版本: 一个简单顺势交易系统的例子