文章 "基于通用 MLP 逼近器的EA" - 页 2

 
Eric Ruvalcaba #:

非常感谢你分享这篇文章和你的见解。好主意。我实施了一些独立的头寸处理,并在对冲账户(我的经纪商)上运行起来了

你是最棒的。

超级棒

 

亲爱的作者,我重读了 TargetFunction() 代码好几遍,你似乎犯了一些错误。

1.在计算仓位利润时,您对利润进行了双重求和。

        if (!truTradeTime [h]) {
            if (posType != 0) { // 如果有空位
                posClPrice = rates [h].open; // 以栏位开盘价收盘
                profit = (posClPrice - posOpPrice) * signal - 0.00003; // 委员会

                if (profit > 0.0) allProfit += profit;
                else              allLoss   += -profit;

                if (posType == 1) buys++;
                else              sells++;

                allProfit += profit;
                posType = 0; // 重置位置
            }
            continue; // 跳过非交易时间
        }

        if ((posType == 1 && signal == -1) || (posType == -1 && signal == 1)) {
            posClPrice = rates [h].open; // 以当前条形图的开盘价收盘
            profit = (posClPrice - posOpPrice) * signal - 0.00003; // 利润计算

            // 损益核算
            if (profit > 0.0) allProfit += profit;
            else              allLoss   += -profit;

            // 交易统计
            if (posType == 1) buys++;
            else              sells++;

            allProfit += profit;
            posType = 0; // 关闭位置
        }


2.计算适应性指数时不使用 Ko 系数。
double ko = 1.0;
  if (sells == 0 || buys == 0) return -DBL_MAX;
  if (sells / buys > 1.5 || buys / sells > 1.5) ko = 0.001;

  return (allProfit / (allLoss + DBL_EPSILON)) * dealsNumb;
 
John_Freeman #:

亲爱的作者,我重读了 TargetFunction() 代码好几遍,你似乎犯了一些错误。

1.在计算仓位利润时,您对利润进行了双重求和。


2.计算适应性指数时不使用 Ko 系数。

1.是的,您说得对,删除两个代码块末尾的行
allProfit += profit;

使其看起来像这样:

f (!truTradeTime [h]) {
            if (posType != 0) { // 如果有空位
                posClPrice = rates [h].open; // 以栏位开盘价收盘
                profit = (posClPrice - posOpPrice) * signal - 0.00003; // 委员会

                if (profit > 0.0) allProfit += profit;
                else              allLoss   += -profit;

                if (posType == 1) buys++;
                else              sells++;

                //allProfit += profit;
                posType = 0; // 重置位置
            }
            continue; // 跳过非交易时间
        }

        if ((posType == 1 && signal == -1) || (posType == -1 && signal == 1)) {
            posClPrice = rates [h].open; // 以当前条形图的开盘价收盘
            profit = (posClPrice - posOpPrice) * signal - 0.00003; // 利润计算

            // 损益核算
            if (profit > 0.0) allProfit += profit;
            else              allLoss   += -profit;

            // 交易统计
            if (posType == 1) buys++;
            else              sells++;

            //allProfit += profit;
            posType = 0; // 关闭位置
        }


2.是的,没有使用 ko。