Amibroker + EquityMonaco 做蒙地卡羅模擬

Discussion in 'AmiBroker' started by rendercat, Jan 25, 2009.

  1. 看了蓝色投机客兄台的文章之后,试了试Equity Monaco, 的确觉得是个很方便的monte carlo simulation 软体。 多谢了,蓝色兄!

    蓝色兄在blog上提到了TS+Equity Monaco测试的简易方法,于是就想到用Amibroker的backtesting result 来试试,顺手写了一段AFL 来export backtesting每笔交易的Profit,每次run backtest就会在 C:\Program Files\AmiBroker\MyPositions 产生一个新的position data文件,然后可直接让Equity Monaco读取。



    SetCustomBacktestProc("");
    if (Status("action") == actionPortfolio)
    {


    //Create Folder
    posFolder = "C:\\Program Files\\AmiBroker\\MyPositions";
    fmkdir(posFolder);

    bo = GetBacktesterObject();

    bo.Backtest(); // Run backtests

    filename = posFolder+"\\PosData_"+StrFormat("%6.0f_%6.0f",Now(3)+1900*10000,Now(4));


    fh = fopen( filename, "w");

    for (trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade())
    {
    profit = trade.GetProfit();
    fputs(StrFormat("%.0f\n",profit),fh);
    }

    fclose( fh );

    }




    想试试的朋友可将上面的afl存档放在C:\Program Files\AmiBroker\Formulas\Custom\EquityMonacol.afl, 然后再在你要测试的系统afl内加入以下代码便可使用
    SetOption("UseCustomBacktestProc", True);
    SetCustomBacktestProc("C:\\Program Files\\AmiBroker\\Formulas\\Custom\\EquityMonaco.afl");


    或是直接将代码嵌入你的afl也可以

    注意这不包括backtesting最后的open position.
     
  2. 很好,谢谢你的分享。 :)
     
  3. AmiBroker Custom Backtester Interface ---

    one of the best and powerful features of Amibroker. :D
     
  4. espresso昨晚喝的Long Black,兴奋呀:)
     
  5. 哈哈,Long Black还真没喝过,查了一下原来是double shot of espresso over hot water,顺序也很重要,要不就变成Americano了,改天做一杯试试 :p

    多谢Stanwell :)

    严重跑题中...

    祝各位海粉们龙年大吉大利,身体健康,合家欢乐!
     
  6. 对,把题正回来。同祝龙年快乐!
     
  7. delete my post ...