数组___应该思路

OnBar(ArrayRef<Integer> indexs)

{

  arraySize = DataSourceSize();

 

  // 方法1:使用标准数组初始化语法

  If (BarStatus () == 0 Or GetArraySize(tmpZD) == 0)

  {

     // 初始化或重新初始化数组

     tmpZD = tmpZD[arraySize];

     tmpZDind = tmpZDind[arraySize];

     tmpH = tmpH[arraySize];

     tmpL = tmpL[arraySize];

     

     For i = 0 To arraySize - 1

     {

        If (i < GetArraySize(tmpZDind))

        {

           tmpZDind[i] = i;

           tmpZD[i] = 0;

           tmpH[i] = 0;

           tmpL[i] = 0;

        }

     }

  }

  // 方法2:如果数组大小发生变化,重新创建数组

  Else If (GetArraySize(tmpZD) != arraySize)

  {

     // 重新初始化数组

     tmpZD = tmpZD[arraySize];

     tmpZDind = tmpZDind[arraySize];

     tmpH = tmpH[arraySize];

     tmpL = tmpL[arraySize];

     

     For i = 0 To arraySize - 1

     {

        If (i < GetArraySize(tmpZDind))

        {

           tmpZDind[i] = i;

           tmpZD[i] = 0;

           tmpH[i] = 0;

           tmpL[i] = 0;

        }

     }

  }

 

  // 在指定时间段计算涨幅并排序

  If (Time >= 0.0905 And Time < 0.0910 And Not HasSorted)

  {

     // 计算所有品种的涨幅

     For i = 0 To arraySize - 1

     {

        If (i < GetArraySize(tmpZD))

        {

           If (Data[i].C[2] != 0)

           {

              // 计算前一根K线的涨幅

              tmpZD[i] = 100 * ((Data[i].C[1] - Data[i].C[2]) / Data[i].C[2]);

           }

           Else

           {

              tmpZD[i] = 0;

           }

           tmpZDind[i] = i;

           tmpH[i] = Data[i].H;

           tmpL[i] = Data[i].L;

        }

     }

     

     // 使用冒泡排序按涨幅降序排列

     For i = 0 To arraySize - 2

     {

        For j = i + 1 To arraySize - 1

        {

           If (j < GetArraySize(tmpZD) And i < GetArraySize(tmpZD))

           {

              If (tmpZD[i] < tmpZD[j])

              {

                 // 交换值

                 tempVal = tmpZD[i];

                 tmpZD[i] = tmpZD[j];

                 tmpZD[j] = tempVal;

                 

                 // 交换索引

                 tempIdx = tmpZDind[i];

                 tmpZDind[i] = tmpZDind[j];

                 tmpZDind[j] = tempIdx;

              }

           }

        }

     }

     

     HasSorted = True; // 标记已排序

     

     // 输出排序结果用于调试

     Commentary("Top " + Text(TOP) + " 品种:");

     For i = 0 To Min(TOP-1, arraySize-1)

     {

        If (i < GetArraySize(tmpZDind))

        {

           j = tmpZDind[i];

           Commentary("第" + Text(i+1) + "名: 代码=" + Data[j].Symbol +

                     ", 涨幅=" + Text(tmpZD[i], 2) + "%");

        }

     }

  }


  // 其余的交易逻辑保持不变

求一个调仓的思路
数组使用
开仓仓位应该怎么写?
数组
数组
请教信号闪烁后继处理逻辑或思路
数组问题
关于信号闪烁问题的解决思路,请老师指导!
数组权重 或 因子权重问题
关于数组的语句问题