打印本文打印本文 关闭窗口关闭窗口

关于平仓后再次开仓问题

作者:开拓者 TB 来源:cxh99.com 发布时间:2023年05月06日
  • 咨询内容: 双均线交易系统带有固定点位止损止盈
    有以下几个问题:
    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

     

     来源:CXH99.COM

  • TB技术人员: 最好只在金叉、死叉出现时开仓,过了就不做了。对第二点,如果出现止损,要再等到新出现交叉再开仓。
    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();

     

  • TB客服:
    Yuen_Lee 发表于 2021-8-3 11:44
    最好只在金叉、死叉出现时开仓,过了就不做了。对第二点,如果出现止损,要再等到新出现交叉再开仓。
    If(Ma ...

    谢谢!

     

  • 网友回复: http://www.wjs7878.com/
打印本文打印本文 关闭窗口关闭窗口