MFE & MAE Tool

This is a simple implementation of the MFE/MAE Tool for TradingView.
It's a quite powerful tool and pretty useful in systematic trading, but I don't see many trader using it these days.
It's created for EMA cross, but you can easily change it to use your own signals.

What is MAE/MFE Tool
  • MAE stands for Maximum Adverse Excursion - Worst P&L during the trade
  • MFE stands for Maximum Favorable Excursion - Best P&L during the trade

The idea is pretty simple. We take only signals without any position management or exits and measure the best/worst P&L for the next X bars after the signal was.

The primary use case for it is to understand how good your signals are .
If you'll add complicated money management tools, exits, and SL/PT to your strategy, it brings quite a lot of noise. After that, it's pretty tricky to understand if your signals bring much information about future price movements. In other words, bad money management can ruin good signals, and you might discard the entire strategy without knowing that. So this is why I think it's important to check the quality of your signals separately.

Another simple way to use it is to estimate where to put SL/PT
In this example, we're computing MAE/MFE in percent. We're plotting it both on the chart and computing some statistics based on it. This is why it's pretty easy to get a quick understanding of what is your SL/PT should be.

MAE/MFE tool consists of a:
  • Chart - it displays a point for every signal. Long/Short trades can have different colors. On hover you'll see details for this signal.
  • Table with stats - we're computing basic metrics for these Signals like average/min/median/max MAE/MFE, number of trades, and how many trades hit selected SL and PT. Stats are also separated by the side so you can see performance separately for longs and shorts.

The indicator is highly customizable, you can configure:
  • Bars you want to use to compute MAE/MFE
  • Side selection
  • SL and R:R
  • Styling of the chart
  • Position and style of the table
  • Parameters for the EMA

EMA cross and its parameter were selected randomly, so don't estimate to see a great performance here.

MFE/MAE tool is a pretty powerful concept. At some point, I'll create an entire article in my blog with more examples and descriptions.

Thanks to @MUQWISHI for helping code it.

Please remember that past performance may not indicate future results.
Due to various factors, including changing market conditions, the strategy may no longer perform as well as in historical backtesting.
This post and the script don’t provide any financial advice.

My First Live Course: qntly.com/101
Pine Programming v5: qntly.com/pineprog
Adv.Pine Use-Cases: qntly.com/advpine

Hire Me: qntly.com/hirepine
Telegram: qntly.com/tel

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。