PureBytes Links
Trading Reference Links
|
Alex,
I have used Cum() extensively in a similar manner to your example
without any problems whatsoever.
I used it for *manually* calculating ProfitFactor outside of the
Backtester, so I will discuss it in that context.
I calculate PF using the Wins/Losses * Ave%Won/Ave%Loss compared to
the AA metrics which uses gross profit/gross loss method (large
sample tests show they are near enough the same for my purposes -
allowing for IEEEEEEEEEEEEEEEE standard float roundoff stuff :-)
For my approach I calculate PF on a bar by bar basis for any chosen
symbol/index.
It could be used as a benchmark metric (a trading system PF would
have to beat the index *bar by bar* PF?)
I have posted a very temporary file in the root of the group files
section with screenshots:
ProfitFactor.doc
The first shot uses a small database for ease of counting etc.
The second shot shows that cum() holds up over larger datasets (the
database contains 614 bars and the example shot shows that cum
correctly totalled 330/284 = = 1.16197.
I haven't given a screenshot of the last code in use but I am
confident it is correct.
Cum is a progressive total - it is normal to increase left to right.
If you are only interested in the final number for your range then my
guess is you could use explore>with a lastvalue() column or select n
= = 1 in AA window before runnning an exploration.
I don't understand how backtest got into your example except that,
making another guess, your buyprice-sellprice must be resetting each
push of the backtest button.
I would say that you are just not fully understanding what is going
on there yet.
The topguns would do that type of thing in the custom backtester.
I have done it in explorer by coding and cumulating raw descriptions
of the buy signal etc (no backtester involved).
There are quite a few hours in that *from the ground up* approach.
BrianB2.
--- In amibroker@xxxxxxxxxxxxxxx, "dralexchambers"
<dralexchambers@xxx> wrote:
>
> I am using the Cum() function - in the code below - to calculate
the
> number of trades that make a profit and a loss in a backtest.
>
> I am finding that the values outputted for total trades won and
lost
> are being affected by the position of the chart being displayed
that
> contains the backtest AFL.
>
> To get the correct profit and loss values, I have to scroll the
price
> chart to the end of the data and hit "Backtest". If I move the data
> back in time (ie. scroll the chart to the left), the values below
> change.
>
> It appears to be the Cum() function that is affected. I thought
that
> the "SetBarsRequired" code should eliminate this problem, but it
> doesn't.
>
> Can anyone advise,
> Most grateful
>
> ====================================
> SetBarsRequired(10000,10000);
>
> rwdaL = IIf(Sell,(SellPrice-ValueWhen(Buy,BuyPrice)),0);
>
> profitL = IIf(rwdaL>0,rwdaL,0);
> LossesL = IIf(rwdaL<0,rwdaL,0);
>
> fh = fopen("D:\AdvancedTradeOutput.html", "w");
>
> f = Cum(ProfitL);
> g = Cum(LossesL);
>
> fputs("Profit / Loss = "+(f/g), fh);
> fclose(fh);
> ====================================
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Transfer from your equities account.
Receive up to $1,000 from GFT. Click here to learn more.
http://us.click.yahoo.com/aZttyC/X_xQAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~->
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/
|