The Fast, Slow and Signal Moving Averages can be set to:
Exponentially (RMA) ( )
Symmetrically ( SWMA )
Moving Average ( )
Double RMA ( DRMA )
Triple RMA (TRMA)
curve Moving Average ( )
If you have a strategy that can buy based on External Indicators use 'Backtest Signal' which returns a 1 for a Buy and a 2 for a sell.
'Backtest Signal' is plotted to display.none, so change the Style Settings for the chart if you need to see it for testing.
Re-wrote calcMA as a switch, much more pleasing on the eye.
Removed all the security fluff which I'd never even read, "terms of the Mozilla Public License 2.0" is more comprehensive anyway.
Added check boxes to quickly disable some of the default plots.
• Added options to generate open and close for both long and short positions. So if you are in a long position and your criteria for a negative signal is met it will close your long, if another negative signal is generated it will open a short. If you're just trading the crossover this will keep you permanently trading short or long, as it's only when there are two or more consecutive signals are generated that will move you from longs to shorts.
• Plots a Green Triangle for Open Long, a Green Square for Close Long, a Red Triangle for Open Short and a Red Square for Close Short.
• To do this I needed to track the sate of open deals. Could have done this with variables but thought plotting it may help, so "Deal State" plots a 1 if it's in a long, 0 if no deals are open and -1 if it's in a short, to display.none. Enable it in Stlye Settings if you need it for testing.
• If you'd prefer that it just worked as it did before with simple Buy / Sell signals, which makes sense if you're just trading the crossover, disable the 'Generate Close Signals for Long / Short Positions' setting.
• Now that it can generate Open Long, Close Long, Open Short and Close Short signals I added a 'Long / Short Signals' section in settings, where you can specify what signals your backtester is expecting for each state.
• Moving averages are now plotted to display.none as well in case you want to see the price and the moving averages for testing. You're much better off running my other script 'Any Ribbon' on the top pane to show the moving averages ribbon, but these options enable you to show them here if you want to.
• Added the option to buy / sell based on the moving average crossing zero, thanks Bu Bader!
• Added filters for MACD above and below zero.
• Added the option to buy / sell based on divergences between the price and the MACD. Thanks to Trading View for the 'Divergence Indicator' and @DaviddTech for his idea to use that as the basis for a MACD Divergence script.
• REMEMBER you can't trigger a divergence before a local top or bottom is CONFIRMED by closing some bars after that local top or bottom. Replay some bars to see how far after the divergence the signal will actually fire.
• Added a bunch of tool tips, I bet there are spelling mistakes in some, tell me if so.
• I've had requests to filter based on a few different indicators, I think that the script is getting too complicated as it is and I don't want to add a bunch of filters that only one person may use. So I added the option to filter based on the output of an external indicator. You can enable or disable trading based any indicator hitting the levels that you set. I've tested a few indicators but you need to to confirm that your indicator is filtering as you expect it to. Enable the plot of 'Trades Enabled' in Style Settings to see if trades are enabled (1) or disabled (0). I expect that this was requested to only open longs in an uptrend etc. so it may not be helpful if you want to open longs and shorts. Thanks Jason5480 for hack_utils that made this easier.
• The external filter will stop new trades starting but it won't stop any existing trades closing.
• The MACD > 0 filter may not have stopped existing deals closing, changed that so that they can close.
• Added check to do nothing when buy and sell fire in the same bar.
• Corrected signal for consecutive short orders.
Dalam semangat TradingView yang sebenar, penulis skrip ini telah menerbitkannya dengan menggunakan sumber terbuka supaya pedagang-pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda dapat menggunakannya secara percuma tetapi penggunaan semula kod ini dalam penerbitan adalah dikawalselia oleh Peraturan Rumah. Anda boleh menyukainya untuk menggunakannya pada carta.
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.