How to simulate maximum potential profit for a number of trades  [SOLVED]

Questions about MultiCharts and user contributed studies.
champski
Posts: 71
Joined: 28 Jun 2011
Has thanked: 20 times
Been thanked: 1 time

How to simulate maximum potential profit for a number of trades

Postby champski » 30 Oct 2019

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

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: How to simulate maximum potential profit for a number of trades

Postby TJ » 30 Oct 2019

First, you have to define what is "highest high".

It sounds simple . . . but have you tried to put it down on paper?

champski
Posts: 71
Joined: 28 Jun 2011
Has thanked: 20 times
Been thanked: 1 time

Re: How to simulate maximum potential profit for a number of trades

Postby champski » 31 Oct 2019

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.

Zheka
Posts: 223
Joined: 13 Jan 2016
Has thanked: 8 times
Been thanked: 53 times

Re: How to simulate maximum potential profit for a number of trades

Postby Zheka » 31 Oct 2019

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.

Zheka
Posts: 223
Joined: 13 Jan 2016
Has thanked: 8 times
Been thanked: 53 times

Re: How to simulate maximum potential profit for a number of trades

Postby Zheka » 02 Nov 2019

These are also available programmatically via MaxPosProfit() , MacContractProfit(), OpenEntryProfit() and OpenEntryProfitPerContract ().

champski
Posts: 71
Joined: 28 Jun 2011
Has thanked: 20 times
Been thanked: 1 time

Re: How to simulate maximum potential profit for a number of trades  [SOLVED]

Postby champski » 04 Nov 2019

thanks Zheka, that's exactly what I was looking for

Zheka
Posts: 223
Joined: 13 Jan 2016
Has thanked: 8 times
Been thanked: 53 times

Re: How to simulate maximum potential profit for a number of trades

Postby Zheka » 04 Nov 2019

Did you try looking in PLEditor?
It has the Dictionary of all keywords and in-built functions catalogued by theme, with explanations and examples..

champski
Posts: 71
Joined: 28 Jun 2011
Has thanked: 20 times
Been thanked: 1 time

Re: How to simulate maximum potential profit for a number of trades

Postby champski » 12 Nov 2019

Did you try looking in PLEditor?
It has the Dictionary of all keywords and in-built functions catalogued by theme, with explanations and examples..
yes I did

thanks Zheka


Return to “MultiCharts”