[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Reconciling MAE/MFE backtest results


  • Date: Thu, 04 Mar 2010 20:01:55 -0000
  • From: "q03237241" <adsligtd@xxxxxxxxxx>
  • Subject: [amibroker] Re: Reconciling MAE/MFE backtest results

PureBytes Links

Trading Reference Links

yes, that seems to be the case. I worked around it by setting trade delays to 1 and prices to open. It is not perfect in the case of opening gaps, but pretty close.

Thanks for your suggestion of using intraday data, I hadn't thought of that :)

cheers
Chris



--- In amibroker@xxxxxxxxxxxxxxx, "sebastiandanconia" <sebastiandanconia@xxx> wrote:
>
> Well, for starters, using your code exactly as you posted it I can reproduce the condition in AB 5.2, so I "get" what you're talking about.
> 
> In looking through some of the trades it appears as though the problem crops-up when the day of the MAE is the same day as the long exit.
> 
> If you change your code so that there's a 2-day delay on your long exit (so that the exit date in your example goes to Feb. 10 instead of Feb. 8) the MAE is as it should be, reflecting the intraday lows of Feb. 8 and Feb. 9.
> 
> This condition (if I'm understanding it correctly) is related to how AB processes EOD data.  There's an intraday low made on the exit day, BUT with EOD data AB doesn't "know" what the intraday low was until after the market closes and you update your data.
> 
> And since your system exits on the close with no delays BEFORE AB has all the data (including the intraday low), as far as it's concerned there was no further MAE beyond the closing price where the system exited. 
> 
> So that's the problem, and it seems to be a legitimate one, but I don't have a solution, except to get intraday data.:)  It's not a "bug", but related to the way AB processes EOD data.  Maybe Tomasz or one of the other more-advanced users can suggest a different solution.
> 
> 
> Sebastian 
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "q03237241" <adsligtd@> wrote:
> >
> > Thanks Sebastian but going long only didn't help either.
> > 
> > Looking at the individual trades, in the case of longs the backtest MAE seems to show an error when a trade low happens to coincide with on the closing bar. 
> > 
> > This system sells at the close of the bar but the MAE calculation appears to ignore if a trade low occurred during the closing bar.
> > 
> > I've tried it with other trade systems as well. It would be interesting to see if anybody else experiences the same problem?..
> > 
> > Regards
> > Chris
> > 
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "sebastiandanconia" <sebastiandanconia@> wrote:
> > >
> > > Your system reverses to short on long exits, is that right? (Sell = Short = Cross(StoD,StoK);)  Have you checked to see what happens if you just set it to "Buy" and "Sell" so you're just getting the long trades?  Maybe the fact that the system is reversing from long to short within the same bar is "confusing" AB?
> > > 
> > > I don't know for sure that this is it, but it's something to try.  (JMO, but I think the best practice is to test long and short systems separately, anyway, just because long and short trades behave differently from each other.)
> > > 
> > > 
> > > Sebastian
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "q03237241" <adsligtd@> wrote:
> > > >
> > > > Hi,
> > > > 
> > > > I have been going cross-eyed with this for days, so I am hoping someone can point me in the right direction.
> > > > 
> > > > I am trying a system that buys/sells on a stochastic cross. However when I examine the backtest output, I cannot reconcile the MAE% figure with the simulated trade data.
> > > > 
> > > > 
> > > > Here is the code:
> > > > 
> > > > //enter at close of bar
> > > > SetTradeDelays(0,0,0,0); 
> > > > BuyPrice = C;
> > > > SellPrice = C;
> > > > ShortPrice = C;
> > > > CoverPrice = C;
> > > > 
> > > > 
> > > > //Stochastic indicator
> > > > 
> > > > Userfriendly = Param("User Friendly Variable",1,1,50,1);
> > > > periods = Param( "Periods", 15, 1, 200, 1 );
> > > > Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
> > > > Dsmooth = Param( "%D avg", 3, 1, 200, 1 );
> > > > StoD = StochD( Userfriendly*periods , Userfriendly*Ksmooth, Userfriendly*DSmooth);
> > > > StoK = StochK( Userfriendly*periods , Userfriendly*Ksmooth);
> > > > 
> > > > //-----------------------------------------------
> > > > 
> > > > // buy & Sell conditions
> > > > 
> > > > Buy = Cover = Cross(StoK,StoD);
> > > > Sell = Short = Cross(StoD,StoK);
> > > > Buy = ExRem(Buy,Sell);
> > > > Sell = ExRem(Sell,Buy);
> > > > 
> > > > 
> > > > Plot(C,"C",colorBlack,styleCandle);
> > > > Plot( StoD, "StoD", colorBlue, styleLine|styleLeftAxisScale);
> > > > Plot( StoK,"StoK", colorRed,styleLine|styleLeftAxisScale);
> > > > 
> > > > ////////////END/////////////////////////////////////
> > > > 
> > > > 
> > > > As an example, when I run the backtest on ticker SKI.AX I get a long entry @ $1.33 on Jan29 ? 2010 with an exit @ $1.31 Feb8. Reported MAE of 1.5%.
> > > > 
> > > > When I check the chart I get trade open $1.33 and trade low of $1.30 (Feb8) giving a MAE of $0.03c or 2.25%. 
> > > > 
> > > > Checking other trades gives similar results. All the MFEs I have checked seem ok.
> > > > 
> > > > Does anyone have any pointers for me?
> > > > 
> > > > 
> > > > Thanks
> > > > Chris
> > > >
> > >
> >
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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:
    amibroker-digest@xxxxxxxxxxxxxxx 
    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/