MAE and MFE calculator.
Forums › ProRealTime English forum › ProOrder support › MAE and MFE calculator.
- This topic has 4 replies, 3 voices, and was last updated 4 years ago by Vonasi.
-
-
08/01/2018 at 3:02 PM #77327
Although this is an indicator I am posting it in this forum as I wrote it really to assist in deciding on stop loss and take profit levels within a strategy (not that I ever use them!)
It is based on long positions only but just reverse the results if you want MAE and MFE for short positions. The MAE and MFE is calculated from the bar open price.
This indicator will calculate the following:
- The all time average MAE and MFE from open price per bar.
- The biggest all time 1 bar MAE and the biggest all time 1 bar MFE.
- The MAE and MFE since the open n bars back.
- The average 1 bar MAE and average 1 bar MFE since the open n bars back.
With this it is easy to check recent market volatility compared to the average and also to decide on stop loss and take profit levels. You could even use the calculations within a strategy to set dynamic levels.
Not sure if it is worthy of the indicator library but I will submit it if Nicolas thinks it is.
Note: just in case anyone does not know – MAE = Maximum Adverse Equity and MFE = Maximum Favourable Equity. Basically how far price moves for or against your position.
12345678910111213141516171819202122232425n = 12if barindex <> 0 thenmae = mae + (open - low)total = total + 1mfe = mfe + (high - open)biggestmae = max((open - low),biggestmae)biggestmfe = max((high - open),biggestmfe)recentmae = (open[n] - lowest[n](low))recentmfe = (highest[n](high) - open[n])maerec = 0mferec = 0for i = 1 to nmaerec = maerec + (open[i] - low[i])mferec = mferec + (high[i] - open[i])nextendifaverecentmae = maerec / naverecentmfe = mferec / navemae = mae / totalavemfe = mfe / totalreturn -avemae coloured(128,0,0) as "All Time Average MAE", avemfe coloured(0,128,0) as "All Time Average MFE", -biggestmae coloured(128,0,0) as "Biggest Ever 1 Bar MAE", biggestmfe coloured(0,128,0) as "Biggest Ever 1 Bar MFE", -recentmae coloured(128,0,0) as "MAE Since n Bar Open", recentmfe coloured(0,128,0) as "MFE Since n Bar Open", -averecentmae coloured(128,0,0) as "Average Recent MAE", averecentmfe coloured(0,128,0) as "Average Recent MFE"08/03/2018 at 3:35 PM #77481An interesting way to use these MAE and MFE values is with bands based on the average of them over a look back period of n.
The above is a weekly chart. The bands have been shifted so that the values for the current forming bar are those at the close of the previous bar. It can then be easily seen if price is near to the average MAE or MFE which can be areas to enter a trade or get out of a trade. I have added a multiple so that you can move the bands to for example 1.5 times MAE and MFE if you want to.
12345678910111213141516defparam calculateonlastbars = 200n = 6multiple = 1.0maerec = 0mferec = 0for i = 1 to nmaerec = maerec + (open[i] - low[i])mferec = mferec + (high[i] - open[i])nextaverecentmae = close - ((maerec / n) * multiple)averecentmfe = close + ((mferec / n) * multiple)return averecentmae[1] coloured(128,0,0) as "Average Recent MAE", averecentmfe[1] coloured(0,128,0) as "Average Recent MFE"…and here is an image of a daily strategy that buys when price drops to an average of MAE (done with MTF). It seems like there is some potential there.
5 users thanked author for this post.
10/02/2020 at 3:06 PM #14620310/02/2020 at 3:35 PM #14620410/02/2020 at 10:36 PM #146255That was a very old strategy from over two and a half years go so I don’t recall exactly which one it was. Looking at the equity curve and the positioning sizing in a constantly trending up market I can only imagine that it involved some averaging down which is not something that I would recommend as a long term strategy unless you have very deep pockets.
Despite that disappointment MAE and MFE are very important in any strategy when deciding on exit positions for either take profit or stop loss and should most certainly not be ignored.
-
AuthorPosts
Find exclusive trading pro-tools on