- UID
- 2
- 积分
- 2874604
- 威望
- 1387331 布
- 龙e币
- 1487273 刀
- 在线时间
- 13155 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2024-11-24
|
【OptimalF】
- input: theData(Numeric), watchDays(Numeric), isOnStrategy(TrueFalse);
- array: DATAs[](0), DATAsCopy[](0), HPRs[](1), Geo_Mean[101](1);
- var: maxLoss(0), maxMeans(0), j(0), k(0), temp(1);
- var: MP(0), passDays(0), isHasTraded(false);
- once begin
- array_setmaxindex( DATAs, watchDays+1 );
- array_setmaxindex( DATAsCopy, watchDays+1 );
- array_setmaxindex( HPRs, watchDays+1 );
- end;
- MP= i_MarketPosition;
- if MP<>MP[1] then isHasTraded= true;
- if isOnStrategy= true then
- begin
- if isHasTraded and sessionlastbar then
- begin
- _arrayShift( DATAs );
- DATAs[1]= theData;
- passDays= passDays + 1;
- end;
- end
- else
- begin
- _arrayShift( DATAs );
- DATAs[1]= theData;
- passDays= passDays + 1;
- end;
- if watchDays > 0 and passDays > watchDays then begin
-
- array_copy( DATAs, 1, DATAsCopy, 1, watchDays );
- maxLoss= minlist( Lowest_a( DATAsCopy, watchDays ), -1 );
- for k= 0 to 99 begin
- temp= 1;
- for j=1 to watchDays begin
- HPRs[j]= 1 + k/100 * ( -DATAsCopy[j] / maxLoss );
- temp= temp * HPRs[j];
- end;
-
- Geo_Mean[k]= power( temp, 1/watchDays );
- end;
- maxMeans= 0;
- _OptimalF=0;
- for k=0 to 99 begin
- if Geo_Mean[k] > maxMeans then begin
- maxMeans= Geo_Mean[k];
- _OptimalF= k;
- end;
- end;
-
- end;
复制代码 |
论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
|