jetxxx 发表于 2015-2-4 18:13:44

IF888 多头策略开源

//------------------------------------------------------------------------
// 简称: MaxWin
// 名称: 追踪止损止盈
// 类别: 公式应用
// 类型: 用户应用
// 输出:
//------------------------------------------------------------------------

Params

        Numeric Length1(5);
        Numeric Length2(30);
        Numeric Lots(1);
        Numeric ATRLength(30);               
        Numeric TrailStop(2);               
       
Vars

        NumericSeries        MA1;
        NumericSeries        MA2;
        NumericSeries        ATRValue;
        NumericSeries        HiAfterEntry;
        NumericSeries        LoAfterEntry;
        Numeric                        StopLine;               
        Numeric                        Change;                       
        BoolSeries                bLongStoped(False);
        BoolSeries                bShortStoped(False);

       
Begin

        Change = Close - Close;
        ATRValue = AvgTrueRange(ATRLength);
        MA1 = AverageFC(Close,Length1);
        MA2 = AverageFC(Close,Length2);
        PlotNumeric("MA1",MA1);
        PlotNumeric("MA2",MA2);
                       
        If(MarketPosition == 1 And BarsSinceEntry == 0)
        {        HiAfterEntry = High;}
        IF(MarketPosition == 1 And BarsSinceEntry >= 1)
        {        HiAfterEntry = Max(HiAfterEntry,High);        }
        If(MarketPosition == -1 And BarsSinceEntry == 0)
        {        LoAfterEntry = Low;}
        IF(MarketPosition == -1 And BarsSinceEntry >= 1)
        {        LoAfterEntry = Min(LoAfterEntry,Low);        }
       
        If(!bLongStoped And MarketPosition<>1 And MA1>MA2 And MA1>(MA2+20))
        {
                Buy(Lots,Open);
                bShortStoped = False;
        }

        If(bLongStoped And MarketPosition<>1 And High>=HiAfterEntry)
        {
                Buy(Lots,Open);//Min(Open,HiAfterEntry));
                bLongStoped = False;
        }
       
        IF(BarsSinceEntry>0 And MarketPosition == 1 )
        {
                StopLine = HiAfterEntry - TrailStop*ATRValue;
                If(Low <= StopLine)
                {
                        Sell(0,Max(Open,StopLine));
                        //Sell(0,Open);
                        bLongStoped = True;
                }
        }

End
       
//------------------------------------------------------------------------
// 编译版本        GS2010.12.08
// 用户版本        2014-12-23 15:51:52
// 版权所有       
// 更改声明        TradeBlazer Software保留对TradeBlazer平台
//                        每一版本的TrabeBlazer公式修改和重写的权利
//------------------------------------------------------------------------

yebenli 发表于 2015-2-5 08:37:04

Sell(0,Max(Open,StopLine));----->>>>Sell(0,Min(Open,StopLine))

jetxxx 发表于 2015-2-5 19:21:01

yebenli 发表于 2015-2-5 08:37 static/image/common/back.gif
Sell(0,Max(Open,StopLine));----->>>>Sell(0,Min(Open,StopLine))

什么道理呢?

yebenli 发表于 2015-2-6 12:42:17

jetxxx 发表于 2015-2-5 19:21 static/image/common/back.gif
什么道理呢?

如果开盘价就跌破出场线,也就是Open<StopLine,这时就应该按开盘价平仓,而不应该用更有利的价格StopLine去平

ppchar 发表于 2015-2-7 21:37:41

这个实盘效果会差很多

89578251 发表于 2015-2-7 21:39:49

同样的时期,一样的模型,为什么我只有一两笔交易,而楼主你却有63笔交易?

jetxxx 发表于 2015-2-9 12:24:02

89578251 发表于 2015-2-7 21:39 static/image/common/back.gif
同样的时期,一样的模型,为什么我只有一两笔交易,而楼主你却有63笔交易? ...

用连续合约

89578251 发表于 2015-2-9 18:32:57

jetxxx 发表于 2015-2-9 12:24 static/image/common/back.gif
用连续合约

用IF888和IF000,也是一样的,几乎没有信号。换了三个电脑上试,也是一样。

jetxxx 发表于 2015-2-10 19:20:35

89578251 发表于 2015-2-9 18:32 static/image/common/back.gif
用IF888和IF000,也是一样的,几乎没有信号。换了三个电脑上试,也是一样。 ...

加q群,帮你看下:288047918

luckybirdt 发表于 2015-2-24 21:27:54

If(bLongStoped And MarketPosition<>1 And High>=HiAfterEntry)
        {
                Buy(Lots,Max(Open,HiAfterEntry));
                bLongStoped = False;
        }
页: [1] 2
查看完整版本: IF888 多头策略开源