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

[amibroker] Re: Perfect Profit and DOF



PureBytes Links

Trading Reference Links

See reply below

--- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@xxx> wrote:
>
> Paul,
> 
> I believe that your degrees of freedom math is not in agreement 
with 
> that of Pardo. 

Thats is correct.
> 
> In "The Evaluation and Optimization of Trading Strategies", pages 
> 292 - 295, Pardo states that data containing O/H/L/C will represent 
4 
> available degrees of freedom per bar, whether you use them or not.

OHLCVOI could be available, but if a system doesnt use anything else 
other than the Close, OHLVOI isnt going to be improving its degree of 
freedom.

> 
> Further, Pardo writes that each data point used in the calculation 
of 
> a rule counts as 1 degree of freedom, but is not double counted. 
The 
> rule itself counts as an additional degree of freedom.
> 
> So, using your example below;
> 
> pds = optimize("pds", 30, 10, 100, 1);
> c > ema(c, pds);
> 


> If I understand Pardo correctly, then:
> 
> - You will have used up 100 degrees of freedom as a result of using 
> 100 Close values when the optimize statement caused pds to be set 
to 
> its maximum value of 100.
> 
> - You would not count the Close values used for the lesser pds 
(i.e. 
> for 10, 11, ... 99) since the max of 100 already accounted for all 
> those Close values. 
> 
> - It is not clear to me whether Pardo considers each of the 
> variations of the C > EMA(C, pds) rule as being a degree of freedom 
> (i.e. 91 variations = 91 degrees of freedom) or just the variation 
> ultimately selected (i.e. 1 degree of freedom). I suspect that he 
> means all 91. David Aronson in "Evidence Based Technical Analysis" 
is 
> clear that he believes that each variation must be counted as a 
rule.

I agree that for MA, that is correct. The equation C >= MA(C, 30)uses 
all 30 datapoints to confirm this rules hold, and since I would have 
to test it upto 100 to know the best to use. So I would have used up 
100 datapoints. But EMA is constructed differently, EMA(c, 30), at 
least the proper version, doesnt always need 30 data points. In fact, 
the first EMA in the series uses only 1 datapoints. However, for 
simplicity, we can make EMA uses up the same degree of freedom as MA.
So I would agree that it uses up 100 degree of freedom
> 
> So, continuing with your example, and taking the conservative 
> approach of assuming all 91 rule variations each count for 1 degree 
> of freedom, Pardo would say that we have used 100 closes + 91 rules 
= 
> 191 used degrees of freedom out of 2000 bars x 4 data points = 8000 
> available degrees of freedom.

I think you are double counting here. If we put 100 datapoints in 
this in-equation, we will be able to tell exactly this in-equation is 
correct. The way to tell if degree of freedom is used up is look at 
how many different answers one can get ie C >= EMA(C, 100). There 
will be only one answer with 100 datapoints. In addition, there will 
still be one answer no matter what the H, L, or open are. Showing 
that HLO is not irrelevant to the degree of freedom calcuation is 
this in-equation.

> 
> In other words, you will have used up 191/8000 = 2.4% of the 
> available degrees of freedom, leaving 97.6% remaining. As a rule of 
> thumb, Pardo advises having not less than 90% degrees of freedom 
> remaining.
> 
> I believe that it is irrelevant how many symbols the strategy is 
run 
> on, the math is constant per symbol.
> 

If we have 2 thousand symbols of a 100 points each, we will have two 
thousand of theoretical different answer to this inequation C >= EMA
(C, 100). Therefore in the case of C >= EMA(c, 100). The degree of 
freedom is multiplied by 2000. 



> I have not yet got around to trying to automate this calculation, 
> since it is relatively easy to count by hand.
> 
> I do plan to eventually have a look at automating the calculation 
of 
> perfect profit though. So if and when I do it, I'll try to remember 
> to update this thread with my conclusions. Unless of course someone 
> beats me to it ;)
> 
> Mike
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Paul Ho" <paultsho@> wrote:
> >
> > I didnt see the Degree of freedom question
> > Suppose we have one rule set buy = c > ema(c, pds);
> > we put this through our dataset of 200 symbols each with 2000 bars
> > So there is 200 * 2000 = 400000 Dof in terms of the Closing 
price. 
> > Note that Dof in h, l, o and volume is irrelevant because we dont 
> use 
> > them.
> > if pds is a single no. then we have used up only 1 dof, but if 
> > pds = optimize("pds", 30, 10, 100, 1);
> > then we effectively have 91 rules, just that we only choose one 
of 
> > them after looking at the results of 91 rules. 
> > So I believe the Used dof is the no of possible permutations 
> > expressed in your optimization statement + other fixed rules, 
> implied 
> > or otherwise.
> > Hope that helps
> > /Paul.
> > --- In amibroker@xxxxxxxxxxxxxxx, Thomas Ludwig <Thomas.Ludwig@> 
> > wrote:
> > >
> > > Hi all,
> > > 
> > > Rober Pardo suggests in his book "The Evaluation and 
Optimization 
> > of 
> > > Trading Strategies" the calculation of "Perfect Profit" (PP) 
> > which "is 
> > > the sum total of all of the potential profit that could be 
> realized 
> > by 
> > > buying every bottom and selling every top". By comparing Net 
> Profit 
> > of 
> > > your trading system with PP you can calculate the "Model 
> > Efficiency" 
> > > (ME). 
> > > 
> > > I think PP can be easily calculated as a stand-alone code by 
> > applying a, 
> > > say, 1% Zigzag. But how can it be done if I want to add ME as 
an 
> > > additional metric in the Custom Backtester? The Equity() 
function 
> > is 
> > > used for your trading system and cannot be used for the Zigzag 
> > system 
> > > at the same time in order to compare both, IMHO. So the only 
> > solution I 
> > > can think of is to loop through all Zigzag signals and 
calculate 
> > the 
> > > profit programmatically. Or am I overlooking something?
> > > 
> > > Pardo also suggests to calculate the Remaining Percentage of 
> > Degrees of 
> > > Freedom (through Used Dgrees of Freedom and Original Degrees of 
> > > Freedom). Any idea if and how they can be counted in AFL?
> > > 
> > > Regards,
> > > 
> > > Thomas
> > >
> >
>



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

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/