Board logo

标题: 【_SystemHistory function】 [打印本页]

作者: 龙听    时间: 2024-2-5 15:47     标题: 【_SystemHistory function】

{
_SystemHistory 函数

作者:Alex Matulich 2003 年 11 月 8 日修订 独角兽研究公司版权所有 (c) 2003 年,保留所有权利。

在优化过程中,请将文件名参数设置为空字符串""。否则,每次重新计算策略时,该函数都会重新创建一个文件,这将大大降低优化速度。

该函数会输出每个平仓头寸的利润、初始风险、初始波动率、最大不利偏移 (MAE) 和最大有利偏移 (MFE)。输出单位是美元,而不是市场单位,尽管输入*是市场单位。

该函数的输入是文件名、止损价和波动率测量值,您可以在每条线上将其传递给该函数。

下面是一个如何使用 _SystemHistory 的示例,使用的是一个粗糙的 "海龟式 "交易系统:
-----------------------------------------------------------------------
  1. Inputs: filename(""), EntryLen(24), StopLength(12);
  2. Vars: StopPrice(0), signl(0);

  3. {Generate buy or sell signal}

  4. signl = 0;
  5. if Close > Highest(High, EntryLen)[1] then signl = 1; {buy signal}
  6. if Close < Lowest(Low, EntryLen)[1] then signl = -1;  {sell signal}

  7. {Execute buy or sell signal and set initial stop}

  8. if signl > 0 then begin
  9.      Buy("L") next bar open;
  10.      if MarketPosition <= 0 then StopPrice = Highest(Low, StopLength);
  11.      ExitLong("xl1") next bar at StopPrice stop;
  12. end;

  13. if signl < 0 then begin
  14.      Sell("S") next bar open;
  15.      if MarketPosition >= 0 then StopPrice = Lowest(High, StopLength);
  16.      ExitShort("xs1") next bar at StopPrice stop;
  17. end;

  18. {Update stop for open position}

  19. if MarketPosition > 0 then begin
  20.      StopPrice = MinList(StopPrice, Highest(Low, StopLength));
  21.      ExitLong("xl") next bar at StopPrice stop;
  22. end;

  23. if MarketPosition < 0 then begin
  24.      StopPrice = MaxList(StopPrice, Lowest(High, StopLength));
  25.      ExitShort("xs") next bar at StopPrice stop;
  26. end;

  27. {Output the history}
  28. value1 = _SystemHistory(filename, StopPrice, AvgTrueRange(15));
复制代码
-----------------------------------------------------------------------
}

本帖隐藏的内容需要回复才可以浏览

作者: 龙听    时间: 2024-2-5 15:50

本帖隐藏的内容需要回复才可以浏览





欢迎光临 龙听期货论坛 (http://qhlt.club/) Powered by Discuz! 7.2