#### nonameblitz1

##### New member

Good Evening!

Have been browsing these forums for a while now. I've tried this several times and this community seems tip-top and extremely helpful with answering thinkscript questions. I am having a bit of trouble, however. I am ultimately trying to code MAE and MFE of a strategy (most recent trade) or even a lower study that tells me the number. I can figure out the rest once I figure out the following:

Basically, what I need help with is how to find the highest high that happens between my entry and exit criteria. Am I missing something D:

My goal here is to get the MAE and MFE of several strategies so that I can do a little data science. If one can find those metrics out for each hypothetical trade then in theory we can see how far our trades go in our favor or against us on any lookback (trader preference). This can be helpful in optimizing stop losses and take profit levels, therefore, optimizing our trading!

Really just trying to figure out how to find the highest high that occurs between the entry and exit conditions, each time. From there we can find the average MFE (of a buy signal here) at a certain lookback (traders choice), plot 1st 2nd 3rd, and 4th quartile, and maybe have makeshift confidence intervals.

Have been browsing these forums for a while now. I've tried this several times and this community seems tip-top and extremely helpful with answering thinkscript questions. I am having a bit of trouble, however. I am ultimately trying to code MAE and MFE of a strategy (most recent trade) or even a lower study that tells me the number. I can figure out the rest once I figure out the following:

Code:

```
def entry = close crosses below md1;
def exit = close[50];
def EntryPrice = EntryPrice();
def HH =if entry then high else if high > HH[1] then high else HH[1];
Plot hh1 = hh;
###def MFE = HH - EntryPrice; (only during condition will i want to do this, now that i think about it)
###def MFE1 = MFE;
```

My goal here is to get the MAE and MFE of several strategies so that I can do a little data science. If one can find those metrics out for each hypothetical trade then in theory we can see how far our trades go in our favor or against us on any lookback (trader preference). This can be helpful in optimizing stop losses and take profit levels, therefore, optimizing our trading!

Really just trying to figure out how to find the highest high that occurs between the entry and exit conditions, each time. From there we can find the average MFE (of a buy signal here) at a certain lookback (traders choice), plot 1st 2nd 3rd, and 4th quartile, and maybe have makeshift confidence intervals.

Last edited by a moderator: