咨询策略

data-href=

没有信号执行,条件都满足了啊,问题出在哪?老师

咨询策略编写
TB策略咨询
咨询关于导出策略的问题
策略咨询
咨询函数
简语言策略函数咨询
咨询编写问题
咨询minmove的用法
咨询水平线
咨询

Params

   Numeric FastLength(12); // 快速移动平均线周期

   Numeric SlowLength(26); // 慢速移动平均线周期

   Numeric MACDSignalLength(9); // MACD 信号线周期

Vars

   Numeric LAST;

   Numeric MACDValue;

   Numeric SignalLine;

   Numeric MACDDiff;

   Bool EnterLongCondition(False);

   Bool EnterShortCondition(False);

   Numeric MyEntryPrice;

   Numeric MyStopLoss;

   Numeric MyTakeProfit;

Events

   OnReady()

   {

       Range[0:DataSourceSize() - 1]

       {

         MACDValue = XAverage(Close,FastLength)-XAverage(Close,SlowLength);

         SignalLine = XAverage(MACDValue,MACDSignalLength);

         MACDDiff = MACDValue - SignalLine;

               

       }

       {

           // 判断开仓条件

   If (MACDValue > REF(MACDValue,1) And REF(MACDValue,1)  < REF(MACDValue,2) )

   {

       EnterLongCondition = True;

   }

   IF (MACDValue < REF(MACDValue,1) And REF(MACDValue,1) > REF(MACDValue,2) )

   {

       EnterShortCondition = True;

   }


   // 开仓操作

   If (MarketPosition == 0 And EnterLongCondition)

   {

       Buy(1,LAST);

       MyEntryPrice =LAST;

       MyStopLoss = MyEntryPrice - 10*MinMove;

       MyTakeProfit = 0;

   }

   Else If (MarketPosition == 0 And EnterShortCondition)

   {

       SellShort(1,LAST);

       MyEntryPrice = LAST;

       MyStopLoss = MyEntryPrice + 10*MinMove;

       MyTakeProfit = 0;

   }


   // 持仓不为零时的止损和止盈调整

   If (MarketPosition!= 0)

   {

       If (MarketPosition == 1)

       {

           // 多头持仓

           If (LAST>= MyEntryPrice + 30*MinMove)

           {

               MyStopLoss = MyEntryPrice + 20*MinMove;

           }

           Else If (LAST>= MyEntryPrice + 40*MinMove)

           {

               MyStopLoss = MyEntryPrice + 25*MinMove;

           }

           Else If (LAST>= MyEntryPrice + 50*MinMove)

           {

               MyStopLoss = MyEntryPrice + 30*MinMove;

           }

           Else If ((LAST- MyEntryPrice) >= ((IntPart((C- MyEntryPrice)/20)+1)*20*MinMove))

           {

               MyStopLoss = MyEntryPrice + ((IntPart((C - MyEntryPrice)/20)+1)*20*MinMove);

           }

           If (LAST<= MyStopLoss)

           {

               Sell(1,MyStopLoss);

           }

       }

       Else If (MarketPosition == -1)

       {

           // 空头持仓

           If (LAST<= MyEntryPrice - 30*MinMove)

           {

               MyStopLoss = MyEntryPrice - 20*MinMove;

           }

           Else If (LAST<= MyEntryPrice - 40*MinMove)

           {

               MyStopLoss = MyEntryPrice - 25*MinMove;

           }

           Else If (LAST<= MyEntryPrice - 50*MinMove)

           {

               MyStopLoss = MyEntryPrice - 30*MinMove;

           }

           Else If ((MyEntryPrice - LAST) >= ((IntPart((MyEntryPrice - LAST)/20)+1)*20*MinMove))

           {

               MyStopLoss = MyEntryPrice - ((IntPart((MyEntryPrice - LAST)/20)+1)*20*MinMove);

           }

           If (LAST>= MyStopLoss)

           {

               BuyToCover(1,MyStopLoss);

           }

       }

   }  

           

           

           

           

           

           

           

       }

   }

是没有信号还是有信号不执行?

另外你要么就发全文

我实在是没有这个时间一句一句把代码敲到编辑器里复现运行一遍

况且你这个图片里,还不说变量是什么数据结构

这怎么看呢