OPEN-SOURCE SCRIPT

Best EMA Finder

549
This script, Best EMA Finder, is based on the same original logic as the Best SMA Finder I published previously. Although it was not the initial goal of the project, several users asked for an EMA version, so here it is.

The script scans a wide range of Exponential Moving Average (EMA) lengths, from 10 to 500, and identifies the one that historically delivered the most robust performance on the current chart. The choice to stop at 500 is deliberate: beyond that point, EMA curves tend to flatten and converge, adding processing time without meaningful differences in signals or outcomes.

Each EMA is evaluated using a custom robustness score:
Profit Factor × log(Number of Trades) × sqrt(Win Rate)

Only EMA lengths that exceed a user-defined minimum number of trades are considered valid. Among these, the one with the highest robustness score is selected and displayed on the chart.

A table summarizes the results:
- Best EMA length
- Total number of trades
- Profit Factor
- Win Rate
- Robustness Score

You can adjust:
- Strategy type: Long Only or Buy & Sell
- Minimum number of trades required
- Table visibility

This script is designed for analysis and optimization only. It does not execute trades or handle position sizing. Only one open trade per direction is considered at a time.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.