Hi,
How can I create some code that would simulate exiting my trades on the highest high before the price eventually falls and the trade is inevitably stopped out at entryprice (for example). The point of the exercise is to highlight how much "potential" profit there is within a collection of trades. Is there a way this can be coded so I run this over backtest data?
Regards
Champski
How to simulate maximum potential profit for a number of trades [SOLVED]
- TJ
- Posts: 7744
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: How to simulate maximum potential profit for a number of trades
First, you have to define what is "highest high".
It sounds simple . . . but have you tried to put it down on paper?
It sounds simple . . . but have you tried to put it down on paper?
Re: How to simulate maximum potential profit for a number of trades
Is this possible to code so the backtest report can report on stats? If so, how, considering it is using hindsight to simulate existing a trade at the very highest price prior to an inevitable stop out?
The only way I can see this is possible, at this point (unless the above is possible), is to collect info outside of the backtest report;
- collect the highest high of each bar in a variable (e.g. MyHighestHigh)
- then once the price eventually stops out at x (e.g. entryprice),
- set a variable MaximumPotentialProfit=MyHighestHigh-entryprice
- append the results to a new line to an output file (e.g. csv)
Something like this should work but is pretty clunky.
The only way I can see this is possible, at this point (unless the above is possible), is to collect info outside of the backtest report;
- collect the highest high of each bar in a variable (e.g. MyHighestHigh)
- then once the price eventually stops out at x (e.g. entryprice),
- set a variable MaximumPotentialProfit=MyHighestHigh-entryprice
- append the results to a new line to an output file (e.g. csv)
Something like this should work but is pretty clunky.
Re: How to simulate maximum potential profit for a number of trades
Look at the List of trades in the Performance Report: each trade has a Run-up and a Drawdown.
That's what you are looking for. Export the list to Excel and analyze as you wish.
A Performance report also has separate tabs with visual analysis of these stats.
That's what you are looking for. Export the list to Excel and analyze as you wish.
A Performance report also has separate tabs with visual analysis of these stats.
Re: How to simulate maximum potential profit for a number of trades
Did you try looking in PLEditor?
It has the Dictionary of all keywords and in-built functions catalogued by theme, with explanations and examples..
It has the Dictionary of all keywords and in-built functions catalogued by theme, with explanations and examples..
Re: How to simulate maximum potential profit for a number of trades
yes I didDid you try looking in PLEditor?
It has the Dictionary of all keywords and in-built functions catalogued by theme, with explanations and examples..
thanks Zheka