Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Recently I came across the term 'perfect profit' in Robert Pardo's book The Evaluation and Optimization of Trading Strategies. (Great book btw ). In it, he states:
This sounds to me like a good way to provide a benchmark to which a trading strategy can be compared. However, the author doesn't provide the code for such a calculation.
I tried to create a NinjaTrader indicator with this, but I had great problems with 'every valley and every top'. I've used the Swing indicator, Zigzag, and the standard functions as MAX and Highs.
Could someone suggest me a way to create such an indicator? I think it will be quite valuable to give another perspective on the results of a backtest.
I think a strategy with 'perfect profit' isn't possible because the entry and exit prices can't be edited in NinjaTrader. (i.e. you can't sell with hindsight after the top, which offcourse is a nice 'protection' to coding errors).
In the same book the author discusses the use of the 'perfect profit' in correlation with the result of a backtest to get an idea how good the strategy is. Do you guys think such a think can be custom added to NinjaTrader? (such as the Optimizer on this forum)
In my research to create such a indicator I found the following (C++) code in Modeling Maximum Trading Profits with C++ from Valerie Salov:
Perhaps this gives some better insight in how such an 'perfect profit' can be calculated.
On internet I found an old newletter ("Better optimization in TradeStation, part 2: Breakout Bulletin - June 2005 ) which creates a sort of perfect profit indicator (see the code in that article).
Any thoughts are very highly appreciated,
Regards,
Can you help answer these questions from other members on NexusFi?
I have not read the book, so I only can suggest how to proceed:
The perfect profit would assume a minimum target (to overcome transaction costs), which I would translate into a minimum deviation for the zigzag indicator. First step would be to apply that indicator to a chart. The system would then sell every top (deducting spread and slippage) and buy every bottom (adding spread and slippage).
The problem is, that this can only be done with hindsight, so I would not know how to define a strategy, as the information required to sell the top or buy the bottom will only be available later.
What you could do is just store the swing highs and lows in a dataseries and calculate the potential profits and display them abóve or below each swing (it is basically the vertical dimension of the swing). THan add those profits up and display them somewhere.
You could also try to export the hypothetical profits to an excel file.
I wrote an indicator that showed the MFE and MAE of each trade using another indicator as a base line. It was last year, but the basic principle was take something like SuperTrend and look for the above/below crossovers. Start counting the MAE and MFE from bar 1, and each new bar adjust it accordingly. When a new crossover occurs, draw a trendline from bar 1 to the last bar, and then drawtext to show the MAE and MFE.
The MAE and the MFE would be calculated by just recording the entry price from bar 1 and then look at the low of each bar (for MAE, on longs) and the high of each bar (for MFE, for longs). If the low or high (in ticks, away from entry price) for the new bar is higher than the previously stored value, store the new value.
It's not perfect but it was simple, a dozen or two lines of code, and it helped with a spreadsheet that I was doing at the time which was for me to record the MAE and MFE for each move based on a mechanical entry set of conditions, then I would compare what I actually got on the trade to the theoretical best.
Thanks for your reply Fat Tails. I'll look into the ZigZag indicator again, it looks to be the best indicator for such an idea.
Your DataSeries idea is an interesting one, thanks! (sound also complex ). Will look into it when the idea that I'm now using (with MAX and MIN values over an period) doesn't work out.
Great idea Mike, perhaps that can be quite a good substitute for 'perfect profit'. Such an indicator can even be used in realtime to watch the performance of a strategy (how great would that be!). However, my programming skills are not even close to your skills. Can you give some suggestions or tips?
Thanks for your posts Fat Tails and Mike, it gave me some fresh insight into this problem.
Sorry, but I am no longer doing any NT programming. I'm sure you can hire it done or if you make a case you might get another person to do it free, specifically posting in the want your indicator created for free thread.