Hi all,
Is there a readymade code for MAE and MFE.
I would like to be able to answer the question:
“what is the maximum amount ever gained since this trade started” – for MFE and the opposite for MAE for both sell and buy orders
I started writing the code for this but am hoping it already exists
Also, it would be good to have “what is the MFE on the last X bars”
Thanks
P.S – I really appreciate your help and support, it is amazing!
This might be of use:
MAE and MFE calculator.
It comes up as the top item if you type MAE MFE in the search box!
Thanks,
Naturally, I checked it before posting, but it is not exactly what I am looking for, the question is does a pre built indicator exist in the language, like ATR for example or HIGH, LOW etc.
Otherwise I can code it myself, it just takes longer…
Thanks again!
There is no pre-built indicator or code that provides what you want but coding it wouldn’t be very difficult and a lot of the basic calculations are in what I wrote. You just need to start recording MFE and MAE highest highs and lowest lows distance from TRADEPRICE from the moment a position is opened and then reset it when it is closed.
What does MAE and MFE stand for please?
i see them when i am looking at back testing history but havent been able to find out what they mean.
thanks
DJ
The MAE term stands for “Maximum Adverse Excursion” and refers to the biggest movement against you while you are at market.
While the MFE (Maxime Favorable Excursion) is the inverse: maximum gain achieved while you are at market.
I have been using Probacktest to backtest my trading strategies for over two months now on a daily basis.
I have recently noticed that the MAE figure on the detailed report does not take into account the max movement against you on the entry bar itself; but then also noticed yesterday night by reviewing a small sample of the winning trades from the detailed report’s closed positions list that the MAE is not really the max price it went against your trade at all. This makes me wonder whether the absolute performance figures and MFE have any bearing….
Should I trust that the return figure on the overview tab information on the probacktest results is correct?
I normally use the MAE as an indicator of the size of stop loss required for the strategy, but how accurate is it? can I trust it? please help
a small sample of the winning trades from the detailed report’s closed positions list that the MAE is not really the max price it went against your trade at all.
I (and I’m sure others?) would love to see examples of what you found??
I’m not doubting what you say btw.
PaulParticipant
Master
inside a strategy, it shows mae / mfe
if longonmarket then
lowestprice=min(tradeprice(1),low)
mae=lowestprice-tradeprice(1)
if mae>mae[1] then
mae=mae[1]
endif
highestprice=max(tradeprice(1),high)
mfe=highestprice-tradeprice(1)
if mfe<mfe[1] then
mfe=mfe[1]
endif
endif
if shortonmarket then
highestprice=max(tradeprice(1),high)
mae=tradeprice(1)-highestprice
if mae>mae[1] then
mae=mae[1]
endif
lowestprice=min(tradeprice(1),low)
mfe=tradeprice(1)-lowestprice
if mfe<mfe[1] then
mfe=mfe[1]
endif
endif
if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
highestprice=0
lowestprice=close
mfe=0
mae=0
endif
graph round(mfe) coloured(0,0,255,255) as "Maximum Favorable Excursion"
graph round(mae) coloured(255,0,0,255) as "Maximum Adverse Excursion"
Above added as Log 212 here …
@Vonasi MAE / MFE Indicator added also as Log 213
Snippet Link Library