This ProBuilder code snippet demonstrates how to calculate the Maximum Adverse Excursion (MAE) and Maximum Favorable Excursion (MFE) for trading strategies. MAE measures the largest loss observed in a trade before it is closed, while MFE assesses the largest profit.
// Define the entry price
entryPrice = close
// Calculate MAE and MFE
MAE = max(entryPrice - low, 0)
MFE = max(high - entryPrice, 0)
// Plot MAE and MFE on the chart
GRAPH MAE as "MAE" coloured("red")
GRAPH MFE as "MFE" coloured("green")
Explanation of the Code:
This snippet is useful for traders and analysts to visually assess the risk and potential of trades over their duration directly on the chart.
Check out this related content for more information:
https://www.prorealcode.com/topic/mae-and-mfe-calculator/
Visit Link