请教开仓问题

老师,你好,我有一个实盘运行的策略,软件有开仓信号,但是实际上没有开仓,是怎么回事啊?

老师好,请教一个问题,如何写当跟BAR上不能交易两次,比如开仓后不能平仓和平仓后不能再开仓?谢谢!
最大开仓市值问题
请教写法问题
满足条件不开仓是什么问题
请教如何分别计算两次开仓的分别止损
信号闪烁造成重复开仓的问题反馈
关于异常开仓问题
请教MarketPosition的问题
请教:如何实现在一根K线上多次开仓
请教一个问题,自动交易开仓后手工加仓,最后平仓的时候为什么不是一起平掉,程序那里平仓数量是(0)的

请提供可以供分析的代码

//------------------------------------------------------------------------

// 简称: MALossLong_SanGe

// 名称: 均线止损策略-多头(三哥)

// 类别: 公式应用

// 类型: 用户应用

// 输出: Void

//------------------------------------------------------------------------

Params

   Numeric Length(20);                     // 均线周期

   Numeric Lots(1);                        // 开仓手数

   Numeric Loss(20);                       // 止损跳数

   Numeric advancesec(5);                  // 提前多少秒


Vars

   Series<Numeric> minPoint;            // 一跳

   Series<Numeric> lossPrice;           // 止损价格

   Series<Numeric> winPrice;            // 止盈价格

   Plot plt_losswin;

   

   Series<Numeric> MA;


Defs

   //此处添加公式函数

   

Events

   //此处实现事件函数

   

   //初始化事件函数,策略运行期间,首先运行且只有一次

   OnInit()

   {

       //止盈止损线划线无数据间断设置

       plt_losswin.setOption("止损线","line-display","interval");

       plt_losswin.setOption("止盈线","line-display","interval");

       //plt_losswin.setOption("止盈线","color",Red);

       //plt_losswin.setOption("止损线","color",Green);

   }

   

   //每根BAR开始的时候设置触发时间点

   OnReady()

   {

       //Numeric advancesec(5); //提前多少秒

       Array<Numeric> timePoint;

       Numeric ret = DateTimeAdd(RealEndDateTime, -1*advancesec);

       ret = StringToTime(TimeToString(ret));

       Print("endtime="+text(RealEndDateTime)+" SetTriggerBarClose:" + Text(ret));

       ArrayPushBack(timePoint, ret);

       SetTriggerBarClose(timePoint);

   }

   

   OnBarClose(ArrayRef<Integer> indexes)

   {

       Bool condL=Close>=MA And Close[1]<MA[1];

       Bool condS=Close<=MA And Close[1]>MA[1];

       

       If (MarketPosition==0 And condL)

       {

           Commentary("价格上破"+Text(Length)+"均线开多");

           Buy(Lots,Close);

           If (Loss>0) lossPrice=EntryPrice-Loss*minPoint;

           //If (Win>0) winPrice =EntryPrice+Win*minPoint;

       }

       If (MarketPosition==1 And condS)

       {

           Commentary("价格下破"+Text(Length)+"均线平多");

           Sell(Lots,Close);

       }

   }



   //Bar更新事件函数,参数indexs表示变化的数据源图层ID数组

   OnBar(ArrayRef<Integer> indexs)

   {

       MA=AverageFC(Close,Length);

       PlotNumeric("MA",MA);

       

       minPoint=MinMove()*PriceScale();

       Commentary("该品种1跳等于"+Text(minPoint)+"点");

       

       /*Bool condL=Close[1]>=MA[1] And Close[2]<MA[2];

       Bool condS=Close[1]<=MA[1] And Close[2]>MA[2];

       

       If (MarketPosition==0 And condL)

       {

           Commentary("价格上破"+Text(Length)+"均线开多");

           Buy(Lots,Open);

           If (Loss>0) lossPrice=EntryPrice-Loss*minPoint;

           //If (Win>0) winPrice =EntryPrice+Win*minPoint;

       }*/

       //多头止损(开仓当根)

       /*If (MarketPosition==1 And Vol>0 And BarsSinceEntry==0 And Low<=lossPrice And lossPrice>0 And Loss>0)

       {

           Commentary("多头固定止损");

           Sell(0,lossPrice);

           lossPrice=0;

           //winPrice=0;

       }*/

       //多头止损

       If (MarketPosition==1 And Vol>0 And BarsSinceEntry>0 And Low<=lossPrice And lossPrice>0 And Loss>0)

       {

           Commentary("多头固定止损");

           Sell(0,Min(Open,lossPrice));

           lossPrice=0;

           //winPrice=0;

           //PlotBool("dd",False);

       }

       /*If (MarketPosition==1 And condS)

       {

           Commentary("价格下破"+Text(Length)+"均线平多");

           Sell(Lots,Open);

       }*/

       

   }



//------------------------------------------------------------------------

// 编译版本    2025/10/26 155955

// 版权所有    jltxquant

// 更改声明    TradeBlazer Software保留对TradeBlazer平台

//            每一版本的TradeBlazer公式修改和重写的权利

//------------------------------------------------------------------------

老师,这是我的策略代码


昨天沪铜满足我的开单条件,应该开多单的,但是并没有开单

https://bbs.tbquant.net/thread/post96