OPEN-SOURCE SCRIPT

5min MACD scalp by Joel

Telah dikemas kini
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.

Nota Keluaran
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
Nota Keluaran
Added strategy Alerts for Long/Short open, further improvements (eg. minimal value of histogram bars)
Nota Keluaran
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: 3commas.io/trade_signal/trading_view .
  • 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.

Nota Keluaran
Minor update of the default values so that it shows trades on every security
Nota Keluaran
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)
Nota Keluaran
Cleanup of unused variables and RSI min-max values put inline
Nota Keluaran
  • 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.
5minExponential Moving Average (EMA)histogramMoving Average Convergence / Divergence (MACD)scalping

Skrip sumber terbuka

Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai sumber terbuka supaya pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara percuma, tetapi penggunaan semula kod dalam penerbitan ini adalah dikawal oleh Peraturan dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Ingin menggunakan skrip ini pada carta?

Penafian