止损,和止盈不执行


Params

Numeric length1(1);// 短期指数平均线参数

Numeric length2(5);// 长期指数平均线参数

Numeric length3(1.002);// 小上涨涨幅

Numeric length4(1.006);// 大上涨涨幅

Numeric length5(1.0025);// 破位涨幅

Numeric length7(2500);// 区间高位

Numeric length6(2000);// 区间低位

Numeric length8(35);// 止损点位

Numeric length9(100);// 止盈点位

Numeric length10(1);// 手数

Numeric length11(10);// 加仓间隔点数

Numeric length12(3);// 多头建仓次数

Numeric length13(3);// 多头挂单点数

Numeric length15(16);// 多头挂单点数

Vars

series<Numeric> ma1;

series<Numeric> ma2;

series<Numeric> my_entryprice1;

series<Numeric> my_entryprice2;

series<Numeric> my_entryprice3;

series<Bool> bool_crossover;

series<Bool> bool_crossunder;

Events

OnBar(ArrayRef<Integer> indexs)

{

   ma1 = Average(close, length1);

   ma2 = Average(close,length2);

   //PlotNumeric(\"ma1\",ma1);

   PlotNumeric(\"ma2\",ma2);

//金叉

   // bool_crossover = ma1[1] <= ma2[1] and ma1 > ma2;

   // bool_crossunder = ma1[1] >= ma2[1] and ma1 < ma2;

   

      bool_crossover = close[1] > ma2[1]  and ma2[1] >Low[1] and close[2] < ma2[2] and  (close[1]/close[2]) >= length3 and   (close[1]/close[2]) <= length4 and length7 > low[2] and low[2] >length6 ;//and (low[2] >length6 and length7 > low[2])

     

     bool_crossunder = close[1] < ma2[1] and close[2] > ma2[2]  and (close[2]/close[1]) > length5;

     

     //and MarketPosition <> 1

           If(bool_crossover and MarketPosition <> 1)

            {

             Buy(length10,open-length13);

            my_entryprice1=open-length13;

              if(MarketPosition>0 and low< my_entryprice1-length8)//止损条件满足亏1oa0,EntryPrice,my_entryprice-low>1g

                {

                sell(0,min(o,my_entryprice1 -length8));

                 }

            else if(MarketPosition>0 and high>my_entryprice1+length9)//止盈条件满足亏loa8,EntryPrice,my_entryprice-low>

               {

               sell(0,max(o,my_entryprice1 +length9));

                }          

         

        If(bool_crossover and MarketPosition <> 1)

            {

            Buy(length10,open-length15);

              my_entryprice2=open-length15;

         

              if(MarketPosition>0 and low< my_entryprice2-length8)//止损条件满足亏1oa0,EntryPrice,my_entryprice-low>1g

                {

              sell(0,min(o,my_entryprice2 -length8));

                 }

               else if(MarketPosition>0 and high>my_entryprice2+length9)//止盈条件满足亏loa8,EntryPrice,my_entryprice-low>

                   {

                 sell(0,max(o,my_entryprice2 +length9));

                    }    

         

               }

         

      }Else If(MarketPosition == 1 AND  CurrentEntries < length12 AND bool_crossover and High[1]-my_entryprice1 > length11)    // 有仓的情况

   {

     

       Buy(length10,open-length13);

       my_entryprice3=open-length13;

       

if(MarketPosition>0 and low< my_entryprice3-length8)//止损条件满足亏1oa0,EntryPrice,my_entryprice-low>1g

       {

       sell(0,min(o,my_entryprice3 -length8));

       }

else if(MarketPosition>0 and high>my_entryprice3+length9)//止盈条件满足亏loa8,EntryPrice,my_entryprice-low>

      {

sell(0,max(o,my_entryprice3 +length9));

      }          

       

       

       

       

       

       

       

       

       

       

    }  


       

       

       


               

         

 

                 

//If(bool_crossunder)

//{

  // Sell(length10,open[1]);

//}




}


止盈止损代码编写
关于止损止盈的写法
代码写了固定止损和固定止盈,当盘中出现大K线时,此K线的最高价和最低价同时满足止损和止盈,得怎么办?
根据账户权益止盈止损
代码中止盈止损不起作用
多空移动止盈止损线源码
开仓可以 为什么后续的止盈、止损、和补仓 就不会执行了呢 是不是开关设置问题 请教老师指点
账户手工开仓后,怎样利用开拓者平台对该手工仓单进行止盈止损(对于止盈最好能实现浮动止盈)
增加止盈止损后,原位置不开仓了
收盘平仓不执行

另外,如果平行,他怎么识别我的第一次开仓,哪个是第二次开仓,需要标记吗

好的,谢谢,如果平行下,能否实现呢

先理清逻辑

平仓跟开仓你可以认为是一种平行关系,把平仓包含在开仓条件下,意思就是同时满足开仓和平仓条件才会平仓

能实现吗,对应的开仓一个价格,对应一个止损,另外开仓,对应另外止损

我想对应开仓,对应止损

你这些平仓内容写在开仓的条件下?而且还是类似金叉的时候,那怎么平仓呢

data-href=