FFT Strategy Bi-Directional Stop/Profit/Trailing + VMA + Aroon

This strategy uses the Fast Fourier Transform inspired from the source code of @tbiktag for the Fast Fourier Transform & @lazybear for the VMA filter.

If you are not familiar with the Fast Fourier transform it is a variation of the Discrete Fourier Transform. Veritasium on youtube has a great video on it with a follow up recommendation from 3brown1blue. In short it will extract all the frequencies from a set of data. @tbiktag laid the groundwork for creating the indicator which will allow you to isolate only those signals which are the most relevant and remove the noise. I recommend having @tbiktag's FFT Transform indicator side by side with this to understand what my variation is doing by setting similar settings.

Using this idea, you can then optimize a strategy to the frequencies that are best. The main entry signal is when the FFT Signal crosses above or below the 0 line.

Included with this strategy is the ability to optionally bi-directionally set:

  • Stop Loss
  • Trailing Stop Loss
  • Take Profit
  • Trailing Take Profit

Entries are optionally further filtered by use of the VMA using the algorithm from LazyBear which allows you to adjust a variable moving average with 3 market trend detections. Green represents upwards momentum; Blue sideways trading and Red downwards momentum. The idea being to filter out buy or sell entries unless the market is moving in that direction, and this makes a big difference as you can see for yourself when you turn it off or on. Turning it off will change the color of the FFT signal to orange instead of the green, blue, red colors.

I have added 2 custom stop loss types as well for experimentation:

1. VMA Filter stop loss to exit the trade if the VMA detects a market trend direction change matching the rules you have set. I have set this to off by default, but it is there so you can see what affect it may have on other tickers. It can increase the profit factor but usually at a cost of net profit.

2. The Aroon Filter stop loss with different lengths for the short or long direction. For the Aroon strategy (which is a trend change detector) it is considered bullish if the upper line (green in my code) is above 70 and the lower line (red in my code) is below 30 and the opposite for the bearish case. With this in mind, I have set it to filter by default only the extreme ends (99 and 1) to increase profit factor and net profit but I encourage you to try different settings and see how it affects things. Turning this off yields much higher net profit but at the cost of the profit factor and drawdown. To disable this just uncheck the 'Use Aroon Filter Long' (or short) and it will also hide the aroon graphics and crosses on the plot.

I will be adding more features in an attempt to lower the drawdown on this strategy but I hope you enjoy what I have so far!

-=Gentleman Goat=- Download the TradingView Input Optimizer at

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