设为首页收藏本站

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

关于平仓后再次开仓问题 [复制链接]

Rank: 1

精华
0
UID
287475
积分
17
帖子
10
主题
7
阅读权限
10
注册时间
2020-1-2
最后登录
2022-8-9
跳转到指定楼层
1#
发表于 2021-8-3 11:16:31 |只看该作者 |倒序浏览
双均线交易系统带有固定点位止损止盈
有以下几个问题:
1.比方均线金叉进多,达到止盈目标止盈后形态上仍然是多头趋势,如何限制继续开仓?
2.如果前一次止损,后面再次开仓加一个突破过滤条件?
现在代码如下:
Params
        Numeric length(10);
                Numeric length1(20);
                Numeric TakeProfitSet(50);
        Numeric StopLossSet(30);
        Numeric Lots(3);
Vars
                NumericSeries AvgValue;
        NumericSeries AvgValue1;
                Numeric MyEntryPrice;
            Numeric myexitprice;
                Numeric Minpoint;
Begin
         AvgValue = AverageFC(C,Length);
         AvgValue1= AverageFC(C,Length1);
        If(MarketPosition <>1 and   AvgValue[1]> AvgValue1[1])
        {
         myentryprice=open;
         Buy(LOTS,myentryprice);
         }
         
        If(MarketPosition <>-1    and  AvgValue[1]< AvgValue1[1] )
        {
         myentryprice=open;
         SellShort(LOTS,open);
         }       
        /////
        If(MarketPosition==1) // 有多仓的情况
    {
         if(high>=(myentryprice+TakeProfitSet*MinPoint))
           {
            myexitprice=(myentryprice+TakeProfitSet*MinPoint);
           if(open>myexitprice)myexitprice=open;
           Sell(0,myexitprice);
           }Else if(low<=(myentryprice-StopLossSet*MinPoint))
           {
            myexitprice=(myentryprice-StopLossSet*MinPoint);
                if(open<myexitprice)myexitprice=open;
                Sell(0,myexitprice);
                }
          
         }
          if(MarketPosition==-1) // 有空仓的情况
    {
        if(low<=(myentryprice-TakeProfitSet*MinPoint))
           {
            myexitprice=(myentryprice-TakeProfitSet*MinPoint);
           if(open<myexitprice)myexitprice=open;
           BuyToCover(0,myexitprice);
           }Else if(High>=(myentryprice+StopLossSet*MinPoint))
           {
            myexitprice=(myentryprice+StopLossSet*MinPoint);
                if(open>myexitprice)myexitprice=open;
                BuyToCover(0,myexitprice);
                }
    }
       

         End

Rank: 4

精华
0
UID
110114
积分
380
帖子
314
主题
16
阅读权限
50
注册时间
2012-4-20
最后登录
2021-12-29
2#
发表于 2021-8-3 11:44:57 |只看该作者
最好只在金叉、死叉出现时开仓,过了就不做了。对第二点,如果出现止损,要再等到新出现交叉再开仓。
If(MarketPosition <>1 and  AvgValue[2] <= AvgValue1[2] and  AvgValue[1]> AvgValue1[1])
    Buy();
If(MarketPosition <>-1 and  AvgValue[2] >= AvgValue1[2] and AvgValue[1]< AvgValue1[1])
    SellShort();

使用道具 举报

Rank: 1

精华
0
UID
287475
积分
17
帖子
10
主题
7
阅读权限
10
注册时间
2020-1-2
最后登录
2022-8-9
3#
发表于 2021-8-3 14:03:06 |只看该作者
Yuen_Lee 发表于 2021-8-3 11:44
最好只在金叉、死叉出现时开仓,过了就不做了。对第二点,如果出现止损,要再等到新出现交叉再开仓。
If(Ma ...

谢谢!

使用道具 举报

Rank: 1

精华
0
UID
281421
积分
1
帖子
1
主题
0
阅读权限
10
注册时间
2019-7-14
最后登录
2021-8-23
4#
发表于 2021-8-23 14:19:27 |只看该作者

使用道具 举报

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

bottom

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

GMT+8, 2024-4-28 15:14

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部