TradingView
Zippy111
18 Kas 2021 18:46

5min MACD scalp by Joel 

Bitcoin / TetherUSBinance

Açıklama

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.

Sürüm Notları

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

Sürüm Notları

Added strategy Alerts for Long/Short open, further improvements (eg. minimal value of histogram bars)

Sürüm Notları

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.

Sürüm Notları

Minor update of the default values so that it shows trades on every security

Sürüm Notları

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)

Sürüm Notları

Cleanup of unused variables and RSI min-max values put inline

Sürüm Notları

  • 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.
Yorumlar
official_Luqui
Guys, i have a
-60.36% WinRate on the Strategy Tester with
-111 Trades on the
-[BTCUSDT ByBit] 1-Minute Chart and a
-1:1.5 Risk/Reward Ratio.

My Settings are these:
TP: 0.6
SL: 0.4

pause trades: 0
only loosing trades: no

Ema cross
fast Ema: 4
slow ema: 579
Valid cross: 115

Macd res: Chart
Fast length: 13
Slow length: 23
Signal Smoothing: 9

Min histogram value: 11
Lookback period: 20

compare with histogram avg: no

Rsi Filter: no

Pullback: no

____________________________________________________________________
Remember: 1 minute chart on the ByBit BTCUSDT. Have fun and play with it! =)
LOVE AND PEACE <3

Luqui
Zippy111
@official_Luqui, wonderfull, someone shares their settings so that we can all learn from them and possibly give suggestions that will make us more successful together. Thank you @official_Luqui! I will put your settings on my 3commas paper bot to see how it goes for me.
NeverLONG
great script, for me it works very well on 15min chart. I am trying to combine it with another indicator, just to remove some of the bad trades. If I find something I'll let you know
NowarCrypto
@NeverLONG, Which indicator do you use to remove bad trades? Thank you.
NeverLONG
@NowarCrypto, it didn't work very well for me this one
Kveie
Hey, can't get the signal to work on 3 commas. What exactly should i type in the message field? I think thats where i mess up
Zippy111
@Kveie, erase everything from the message field and type in this placeholder: {{strategy.order.comment}}
Don't forget that the 3commas comments have to be turned on, so you'll see them on the chart while you create the alert
Thrian
I noticed that the strategy often takes multiple bad trades when the trend is changing.
Your latest option to pause trades after a loss for X bars tries to combat that but isn't working too well for me.
I thought of an option to pause trades in the same direction after X losses in a row. So for example after 2 lost long trades in a row the bot would wait for the EMA-Cross downwards and only then start trading again with shorts. I hope you understand what I mean. Sadly my programming skills are limited. Maybe you could try to implement that if you like my idea.
Zippy111
@Thrian, thank you for the suggestion, I liked it, so I have implemented it into the new upgrade. Testing didn't give me much better results, but anyway it's good to have this option and maybe you'll find better settings for it
Daha Fazla