PureBytes Links
Trading Reference Links
|
Go to the Yahoo Groups web page for the AmiBroker group, then enter
the message number in the search area.
Mike
--- In amibroker@xxxxxxxxxxxxxxx, "Louis Préfontaine"
<rockprog80@xxx> wrote:
>
> Already finished the book two weeks ago.
>
> I don't see message number... in what thread was that?
>
> Louis
>
>
> 2008/5/10 Mike <sfclimbers@xxx>:
>
> > Finish Howard's book, then go through the slides that he offers
in
> > message #123602, then write your objective function.
> >
> > It's perfectly fine to have different objective functions for
> > different systems. It all depends on what your goal is (i.e. the
> > objective) for each of those systems.
> >
> >
> > Mike
> >
> > --- In amibroker@xxxxxxxxxxxxxxx <amibroker%
40yahoogroups.com>, "Louis
> > Préfontaine"
> > <rockprog80@> wrote:
> > >
> > > Building a good objective function is more difficult than I
though.
> > >
> > > Is it ok to have different objective functions depending on the
> > system or
> > > part of the system? I mean: sometimes you prefer to have a high
> > ratio of
> > > win no matter how much you win while other time %profit is more
> > important...
> > >
> > > Louis
> > >
> > >
> > > 2008/5/9 Louis Préfontaine <rockprog80@>:
> > >
> > > > Thanks Mike! ;-)
> > > >
> > > > Louis
> > > >
> > > > 2008/5/9 Mike <sfclimbers@>:
> > > >
> > > > 1. Uncomment the Buy/Sell signals. You need to generate
> > statistics in
> > > >> order to calculate the objective function.
> > > >>
> > > >> 2. Type in the name of your custom variable for the
optimization
> > > >> target of the walk forward settings tab (yours is named
> > > >> ObjectiveFunction in the code below)
> > > >>
> > > >> See http://www.amibroker.com/kb/2008/02/12/getting-started-
with-
> > > >> automatic-walk-forward-optimization/
> > > >>
> > > >> Mike
> > > >>
> > > >> --- In amibroker@xxxxxxxxxxxxxxx <amibroker%
40yahoogroups.com><amibroker%
> > 40yahoogroups.com>, "Louis
> >
> > > >> Préfontaine"
> > > >> <rockprog80@> wrote:
> > > >> >
> > > >> > Hi Howard,
> > > >> >
> > > >> > I am using the following code
> > > >> >
> > > >> > // CustomMetricWithPenalty.afl
> > > >> > //
> > > >> > // Add a custom metric to the backtest report.
> > > >> > // The metric is the KRatio, multiplied by a
> > > >> > // penalty function based on:
> > > >> > // the average percentage profit or loss per trade.
> > > >> > // the percentage the system is exposed to the market.
> > > >> > // the holding period per trade.
> > > >> > // the percent of trades that are winners.
> > > >> > // the RAR value.
> > > >> >
> > > >> > KRatioVal = 0;
> > > >> >
> > > >> > SetCustomBacktestProc("");
> > > >> >
> > > >> > if (Status("action") == actionPortfolio)
> > > >> > {
> > > >> > bo = GetBacktesterObject();
> > > >> >
> > > >> > bo.backtest();
> > > >> >
> > > >> > st = bo.getperformancestats(0);
> > > >> >
> > > >> > KRatioVal = 100.0 * st.getvalue("KRatio");
> > > >> > RRR = st.getvalue("RRR");
> > > >> >
> > > >> > AvgPctGainVal = 0.01
> > > >> > * st.getvalue("AllAvgProfitLossPercent");
> > > >> > ExposureVal = 0.01 * st.getvalue("ExposurePercent");
> > > >> > HoldingPeriodVal = st.getvalue("AllAvgBarsHeld");
> > > >> > PctWinnersVal = 0.01 * st.getvalue("WinnersPercent");
> > > >> > RarVal = 0.01 * st.getvalue("RAR");
> > > >> >
> > > >> > AvgPctGainMult = IIf(AvgPctGainVal<0.01,
> > > >> > 0.0,
> > > >> > 1.00);
> > > >> >
> > > >> > ExposureMult = IIf(ExposureVal<0.10,
> > > >> > 1.00-(0.50/0.10)*(0.10-ExposureVal),
> > > >> > IIf((ExposureVal>=0.10 AND ExposureVal<=0.20),
> > > >> > 1.00,
> > > >> > IIf((ExposureVal>0.20 AND ExposureVal<0.40),
> > > >> > 1.00-(0.50/0.20)*(ExposureVal-0.20),
> > > >> > 0.50 )));
> > > >> >
> > > >> > HoldingPeriodMult = IIf(HoldingPeriodVal<3,
> > > >> > 1.00-(0.50/3)*(3-HoldingPeriodVal),
> > > >> > IIf((HoldingPeriodVal>=3 AND HoldingPeriodVal<=7),
> > > >> > 1.00,
> > > >> > IIf((HoldingPeriodVal>7 AND HoldingPeriodVal<14),
> > > >> > 1.00-(0.50/7)*(HoldingPeriodVal-7),
> > > >> > 0.50 )));
> > > >> >
> > > >> > PctWinnersMult = IIf(PctWinnersVal<0.50,
> > > >> > 0.50,
> > > >> > IIf((PctWinnersVal>=0.50 AND PctWinnersVal<=0.65),
> > > >> > 1.00-(0.50/0.15)*(0.65-PctWinnersVal),
> > > >> > 1.00 ));
> > > >> >
> > > >> > RarMult = IIf(RarVal<0.10,
> > > >> > 0.50,
> > > >> > IIf((RarVal>=0.10 AND RarVal<=0.20),
> > > >> > 1.00-(0.50/0.10)*(0.20-RarVal),
> > > >> > 1.00 ));
> > > >> >
> > > >> > ObFn = KRatioVal * AvgPctGainMult * ExposureMult
> > > >> > * HoldingPeriodMult * PctWinnersMult * RarMult;
> > > >> >
> > > >> > bo.addcustommetric("ObjectiveFunction", ObFn);
> > > >> > }
> > > >> >
> > > >> > // The trading system starts here
> > > >> > /*
> > > >> > fast = Optimize("fast",16,1,20,1);
> > > >> > slow = Optimize("slow",8,1,20,1);
> > > >> > MAF = DEMA(C,fast);
> > > >> > MAS = DEMA(C,slow);
> > > >> >
> > > >> > HoldDays = Optimize("HoldDays",1,1,20,1);
> > > >> > Buy = Cross(MAF,MAS);
> > > >> > Sell = Cross(MAS,MAF) OR BarsSince(Buy)>=HoldDays;
> > > >> > Sell = ExRem(Sell,Buy);
> > > >> > */
> > > >> > e = Equity();
> > > >> >
> > > >> > //Plot(C,"C",colorBlack,styleCandle);
> > > >> > //shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
> > > >> > //PlotShapes( shape, IIf( Buy, colorGreen, colorRed ),
> > > >> > // 0, IIf( Buy, Low, High ) );
> > > >> > Plot(e,"Equity",colorGreen,styleLine|styleOwnScale);
> > > >> > //GraphXSpace = 5;
> > > >> > //Figure A.7 Custom Metric with Penalty
> > > >> >
> > > >> > I didn't post it at first because I was not sure if you
wanted
> > the
> > > >> code to
> > > >> > be made public.
> > > >> >
> > > >> > I worked on another objective function, and I wonder... how
> > can you
> > > >> put the
> > > >> > objective function in the walk-forward tab?
> > > >> >
> > > >> > Thanks!
> > > >> >
> > > >> > Louis
> > > >> >
> > > >> > 2008/5/9 Howard B <howardbandy@>:
> > > >> >
> > > >> > > Hi Louis --
> > > >> > >
> > > >> > > Please post the code you are trying to use.
> > > >> > >
> > > >> > > Yes, you can use your custom objective function when
running
> > > >> backtests and
> > > >> > > automatic walk forward runs.
> > > >> > >
> > > >> > > Thanks,
> > > >> > > Howard
> > > >> > >
> > > >> > >
> > > >> > > On Fri, May 9, 2008 at 3:33 PM, Louis Préfontaine
> > <rockprog80@>
> > > >> > > wrote:
> > > >> > >
> > > >> > >> Hi,
> > > >> > >>
> > > >> > >> I've been trying to build a custom objective function
and
> > tried
> > > >> to see
> > > >> > >> what it would be like to use Howard's one in the
Appendix A.
> > > >> However, after
> > > >> > >> running it with different symbols/markets/systems, the
> > results
> > > >> is ALWAYS
> > > >> > >> 0.00 Anyone know why this can happen?
> > > >> > >>
> > > >> > >> BTW, is it possible to add the custom OB to the walk-
> > forward?
> > > >> > >>
> > > >> > >> Thanks,
> > > >> > >>
> > > >> > >> Louis
> > > >> > >>
> > > >> > >>
> > > >> > >>
> > > >> > >
> > > >> > >
> > > >> >
> > > >>
> > > >>
> > > >>
> > > >
> > > >
> > >
> >
> >
> >
>
------------------------------------
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|