全部 智大领峰 TBQuant功能 TBL语言 TB开户 问答专区 高手圈 其他
各位看一下我这个模型,能不能重新设一下如何止损和止盈
2022-04-24 15:23

Params
    Numeric AfStep( 0.02);
    Numeric AfLimit( 0.2 ) ;
    Numeric Length(50);    //均线周期
    Numeric Tiao(0);    //跳数
    Numeric Lots(1);    //仓量 
    
    Numeric lostPoint(100); // 50个点,止损
    
Vars
    Numeric oParCl( 0 ); 
    Numeric oParOp( 0 );
    Numeric oPosition( 0 ); 
    Numeric oTransition( 0 );
    NumericSeries sar; 
    Numeric ma;
    NumericSeries isDo;
    NumericSeries lastOpen; 
//    NumericSeries sar;
    Numeric minpoint;
    NumericSeries myenterPrice;
    Numeric zhisunPrice;
    
Begin
                if(currentdate>=20220401) return; //指定日期后
    ma = AverageFC(Close[1],Length);
    ParabolicSAR( AfStep, AfLimit, oParCl, oParOp, oPosition, oTransition ) ;


    COMMENTARY("oParCl="+ Text(oParCl));
    // COMMENTARY("oParOp"+ Text(oParOp));
    // COMMENTARY("oPosition"+ Text(oPosition));
    // COMMENTARY("oTransition"+ Text(oTransition));
    // COMMENTARY("MarketPosition"+ Text(MarketPosition));
    
    // COMMENTARY("isDo[0]"+ Text(isDo));
    // COMMENTARY("isDo[1]"+ Text(isDo[1]));
    COMMENTARY("ma="+ Text(ma));
    PlotNumeric("oParCl" , oParCl);
    
    
    minpoint = MinMove*PriceScale;
    zhisunPrice = MinMove * PriceScale * lostPoint;
    
    isDo = oParCl - ma - 10 * Tiao;

    If(MarketPosition==1 ) 
    {
        // If(isDo[0] > 0 && isDo[1] <= 0){
        If(oParCl > H){
            Sell(Lots, (h+l)/2);
            SellShort(Lots, (h+l)/2);
            lastOpen = O;
        }
        // zhisunPrice
        else if(close[1] < lastOpen - zhisunPrice)    {
                sell(LOTS, open);
            }
    }Else If(MarketPosition==-1){
        If(oParCl < L){
            BuyToCover(Lots, (h+l)/2);
            Buy(Lots, (h+l)/2);
            lastOpen = O;
        // zhisunPrice
        }else if (close[1] > lastOpen + zhisunPrice)
             {
                BuyToCover(LOTS,o);
             

        }
    }Else If(MarketPosition==0){
        If(oParCl < L){
            Buy(Lots, O);
            lastOpen = O;
        }Else If(oParCl > H){
            SellShort(Lots, O);
            lastOpen = O;
        }
    }
    
    End

 

希望优化一下,就是可以开仓后动态止盈和固定止损

请问如何优化

kyover

帮助中心的进阶案例里有移动止盈 固定止损的教学

2022-04-25 09:25
您未登录,请先 登录注册 后发表评论
顶部