NexusFi: Find Your Edge


Home Menu

 





Calculating 'Perfect Profit'


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Jura with 3 posts (0 thanks)
    2. looks_two Big Mike with 2 posts (1 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 Fat Tails with 1 posts (0 thanks)
    1. trending_up 8,268 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

Calculating 'Perfect Profit'

  #1 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690

Hi there,

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:

Quoting 
Perfect profit is a theoretical measure of market potential. It is the total profit produced by buying at every valley and selling at every top that occurs during a historical period of market history. This is obviously impossible in practice, therefore the name perfect profit. Because of the method of calculation, perfect profit will constantly grow from the beginning of the historical test period to its end. (p. 204)

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:
 
Code
#include "Prices.h"
using namespace PPBOOK;
namespace PPBOOK {
inline double
pardo_potential_profit (const Prices& prices)
{
 double ppp = 0.0
 for(size_t j = 1 ; j < prices.size(); j++)
  ppp += fabs(prices[j] - prices[j-1]);
 return ppp * prices.tickValue() / prices.tick();
}
} // PPBOOK
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,

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
NexusFi Journal Challenge - May 2024
Feedback and Announcements
How to apply profiles
Traders Hideout
Trade idea based off three indicators.
Traders Hideout
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
45 thanks
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
21 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


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.

Reply With Quote
  #4 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,446 since Jun 2009
Thanks Given: 33,217
Thanks Received: 101,608

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.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690


Fat Tails View Post
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.

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.


Big Mike View Post
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.

Mike

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.

Regards,

Started this thread Reply With Quote
  #6 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,446 since Jun 2009
Thanks Given: 33,217
Thanks Received: 101,608

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.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #7 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690


Big Mike View Post
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.

Mike

That's okay Mike, thanks nonetheless.

Started this thread Reply With Quote




Last Updated on July 15, 2010


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts