设为首页收藏本站

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

写了如下公式插入应用跟预想不一样是怎么回事 [复制链接]

Rank: 2

精华
0
UID
275910
积分
54
帖子
34
主题
16
阅读权限
30
注册时间
2019-2-22
最后登录
2020-4-7
跳转到指定楼层
1#
发表于 2019-3-28 16:56:42 |显示全部楼层 |倒序浏览



Params
    Numeric n1(10);
    Numeric n2(20);

Vars
    NumericSeries ma1;
    NumericSeries ma2;
        BoolSeries golden;//金叉
        BoolSeries ending;//死叉
       
        numeric myhigh;
    numeric mylow;

Begin
    ma1 = Average(c,n1);
    ma2 = Average(c,n2);
        golden = CrossOver(ma1,ma2);
        //ending = CrossOver(ma2,ma1);
        ending = CrossOver(ma1,ma2);
       
        myhigh = highest(h,10);
        mylow = lowest(l,10);
       
        /* If(golden[1])
        {
        Buy(0,o);
        }
        Else If(ending[1])
        {
        SellShort(0,o);
        } */
       
        If(ma1 != 0)
                PlotNumeric("MA_1",ma1);//连线显示
        If(ma2 != 0)
            PlotNumeric("MA_2",ma2);
               
    /* If(ma1>ma2)
        {   PlotNumeric("MA1",ma1,ma2);}//柱状图显示,从ma1画到ma2
        If(ma1<ma2)
    {   PlotNumeric("MA2",ma2,ma1);} */
       
If(golden == true)
{
    Buy(1,o);
        If(MarketPosition == 1 && low <= mylow)
    {
        sell(1,mylow-minmove*pricescale);
    }
}

If(ending == true)
{
    SellShort(1,o);
        If(MarketPosition == -1 && high >= myhigh)
    {
        BuyToCover(1,myhigh+minmove*pricescale);
    }
}



End
附件: 你需要登录才可以下载或查看附件。没有帐号?注册

Rank: 2

精华
0
UID
275910
积分
54
帖子
34
主题
16
阅读权限
30
注册时间
2019-2-22
最后登录
2020-4-7
2#
发表于 2019-3-28 16:57:58 |显示全部楼层
为什么一个K线上会执行四个操作呢?

使用道具 举报

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

bottom

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

GMT+8, 2024-5-10 06:50

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部