请教开仓问题

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

请提供可以供分析的代码

回复://------------------------------------------------------------------------// 简称: 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