设为首页收藏本站

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

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

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线上会执行四个操作呢?

使用道具 举报

Rank: 10Rank: 10Rank: 10

精华
3
UID
5
积分
26584
帖子
12686
主题
49
阅读权限
200
注册时间
2007-7-20
最后登录
2021-11-3
3#
发表于 2019-3-28 17:02:06 |只看该作者
visions111 发表于 2019-3-28 16:57
为什么一个K线上会执行四个操作呢?
  1.   golden = CrossOver(ma1,ma2);
  2.         //ending = CrossOver(ma2,ma1);
  3.         ending = CrossOver(ma1,ma2);
复制代码
golden 和ending的赋值是一样的。。

使用道具 举报

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

bottom

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

GMT+8, 2024-4-27 22:52

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部