Zippy111

5min MACD scalp by Joel

This strategy is inspired by a youtuber called Joel on Crypto. He trades this using Ema , MACD indicators and his own experience. For more information, check out his Best Crypto Scalping Strategy for the 5 Min Time Frame video. I have tried to automate this a little.

Long or Short trades are determined with a crossing of the fast Ema over the slow Ema for Long and the opposite for Short. Trades should only happen close to the crossovers. Then for Long we use the MACD indicator with a 1min TF (I had better results using the 5min) where we look for high peaks in negative values for Long and vice versa for Shorts. These should be significantly higher than other peaks (or if you will lower peaks for a Long).

Hence, the key is to detect high peaks on the histogram, which I try to achieve by checking if the last 2 values were higher than X bars back. If you want to make it even more specific, then you can turn on the additional checkbox which compares the current value to the average value of X bars back, and if it is greater than, say, 50% the value of the average (= 1.5x the average), then it's ok for the trade.

I also noticed that the strategy often bought at the top or bottom, so I added a check that compares whether the last evaluated bar is the first rising bar (for Long) or falling bar (for Short). This can be turned on or off.

Target profit 0,5% and stop loss 0,4% are based on his recommendation. The strategy is set to take only 1 trade at a time, and you can have a back tester table on.

I'm still a pine script beginner, so the strategy is certainly not perfect and could be improved. If you have any tips on how to improve it further, please let me know. I will try to update it when I have time.

I would also like to thank Joel on Crypto for sharing the strategy and @ZenAndTheArtOfTrading for his great library and code (thanks to him we have a back tester table in here), but especially his educational videos on youtube, which taught me a lot about pine script.

Release Notes: I have made some significant changes and corrections, so I would recommend everyone to use the current version. I've also changed the defualt values for ones that give a better start.

New features and improvements:
- RSI filter, which sets the maximum RSI threshold for a long position and the minimum for a short,
- Ema trend picker, which gives more options for determining the trend. You can select individual Emas now,
- Back tester table will turn green if the strategy is profitable;

I hope that you'll find the strategy better to trade now. Feel free to test different values that go well outside the standard.

I will be glad if you let me know in the comments how you're doing and which values are the most profitable for you. I can also add inputs for 3commas robots if there is more interest.

Take care folks
Release Notes: Added strategy Alerts for Long/Short open, further improvements (eg. minimal value of histogram bars)
Release Notes: The update took me a little longer than I expected, but I tested it all the more. The update includes:
- Order fill alerts fix
- RSI filter extended with:
- Confirmation of the trade direction with RSI, i.e. for Long the RSI must rise a specified number of bars back, vice versa for Short
- Minimum RSI value for Long and maximum for Short
- Now EMAs can be plotted to the chart, but this is disabled by default (Style tab)
- 3commas connector – even with a free subscription you should be able to use it, as they start and stop the bots along with the orders

Tip: If you want the order fill alerts to show what type of order has just been triggered, then use placeholder {{strategy.order.id}} in the alert message.

Warning: By taking the MACD histogram values from the lower TF (which is not the default setting anymore), it can get stuck although it may work you for several trades in a row. Unfortunately, I haven't found a way to prevent this, so use lower TF with caution and check it more often. Those who want to make sure it doesn't get stuck need to use the same or higher TFs. The same goes for the RSI values.


Instructions for the 3commas connector:
  • 1. First, you need to prepare 3commas Long/Short bots that will only listen to custom TV signals.
  • 2. Inputs for the 3commas bot can be found at the end of the user inputs.
  • 3. Once you have entered the required details into the inputs, turn on 3commas comments. They should appear on the chart (looks messy).
  • 4. Now you can add the alert where you should paste the 3commas Webhook URL: https://3commas.io/trade_signal/trading_... .
  • 5. For the alert message text insert the placeholder {{strategy.order.comment}} and delete the rest. 6. Once the alert is saved, you can turn off those 3commas comments to have a clearer chart.
  • 7. With a new alert, the bot and trade should launch.
Release Notes: Minor update of the default values so that it shows trades on every security
Release Notes: The script made trades sometimes too often, even when conditions weren't ideal, so I have added a pause for trades. (also applied on the screenshot with a pause for three bars)
Release Notes: Cleanup of unused variables and RSI min-max values put inline
Release Notes:
  • Ability to pause trades after a certain number of loosing trades in a row (in one direction)
  • Simplified (and thus accelerated) way of calculating the average histogram
  • Pullback filter is fixed as its logic was flawed

TODO: The script should start using arrays to store histogram values. This will be a major change because today when we want to go short, ta.highest looks back for example 10 bars and if 9 out of 10 bars have negative histogram values, even a very low positive value on the 10th bar will be evaluated as exceptionaly high for a short (turn on a separate MACD histogram like I have in the picture to see this). With the use of arrays it will only compare values in its positive spectrum and will ignore values from the negative spectrum.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?