TradingView
MauricioZuniga
6 Jun 2022 pukul 19.02

Customizable Non-Repainting HTF MACD MFI Scalper Bot Strategy 

ETH 3x Long / TetherKuCoin

Huraian

This script was originally shared by Wunderbit as a free open source script for the community to work with.

WHAT THIS SCRIPT DOES:
It is intended for use on an algorithmic bot trading platform but can be used for scalping and manual trading.
This strategy is based on the trend-following momentum indicator . It includes the Money Flow index as an additional point for entry.

HOW IT DOES IT:
It uses a combination of MACD and MFI indicators to create entry signals. Parameters for each indicator have been surfaced for user configurability.
Take profits are fixed, but stop loss uses ATR configuration to minimize losses and close profitably.

HOW IS MY VERSION ORIGINAL:
I started trying to deploy this script myself in my algorithmic trading but ran into some issues which I have tried to address in this version.
  • Delayed Signals : The script has been refactored to use a time frame drop down. The higher time frame can be run on a faster chart (recommended on one minute chart for fastest signal confirmation and relay to algotrading platform.)
  • Repainting Issues : All indicators have been recoded to use the security function that checks to see if the current calculation is in realtime, if it is, then it uses the previous bar for calculation. If you are still experiencing repainting issues based on intended (or non intended use), please provide a report with screenshot and explanation so I can try to address.
  • Filtering : I have added to additional filters an ABOVE EMA Filter and a BELOW RSI Filter (both can be turned on and off)
  • Customizable Long and Close Messages : This allows someone to use the script for algorithmic trading without having to alter code. It also means you can use one indicator for all of your different alterts required for your bots.


HOW TO USE IT:
It is intended to be used in the 5-30 minute time frames, but you might be able to get a good configuration for higher time frames. I welcome feedback from other users on what they have found.

Find a pair with high volatility (example KUCOIN:ETH3LUSDT ) - I have found it works particularly well with 3L and 3S tokens for crypto. although it the limitation is that confrigurations I have found to work typically have low R/R ratio, but very high win rate and profit factor.

Ideally set one minute chart for bots, but you can use other charts for manual trading. The signal will be delayed by one bar but I have found configurations that still test well.
Select a time frame in configuration for your indicator calculations.

Select the strategy config for time frame. I like to use 5 and 15 minutes for scalping scenarios, but I am interested in hearing back from other community memebers.

Optimize your indicator without filters (trendFilter and RSI Filter)

Use the TrendFilter and RSI Filter to further refine your signals for entry. You will get less entries but you can increase your win ratio.

I will add screenshots and possibly a video provided that it passes community standards.

Limitations: this works rather well for short term, and does some good forward testing but back testing large data sets is a problem when switching from very small time frame to large time frame. For instance, finding a configuration that works on a one minute chart but then changing to a 1 hour chart means you lose some of your intra bar calclulations. There are some new features in pine script which might be able to address, this, but I have not had a chance to work on that issue.

Nota Keluaran

Updated code comments

Nota Keluaran

Added a comment filed for closing trailing stop so that strategy can be automated on both opens and closes. Previously the strategy was dependent on having subsystem closing order based on parameters set there. This can yield much better returns on backtest.

Nota Keluaran

Add option to add or remove Take Profit 1 as the trailing stop can perform better without it.

Reformatted the config interface for easier input and changed the default parameters to ones that are working for certain pairs to see if they work on others.

I found that using an RSI filter for below 60 period @ 38 through 40 length worked well on 5 minute chart to filter out some losing trades and increase profitability.
Komen
blckst10
There is unfortunately a repaint in backtest. After the signal came, the transaction seemed to be closed, but when you refresh the page, the transaction still seemed to be in progress. this is a big problem.. i hope this bug is fixed. I can send a photo of it
MauricioZuniga
@blckst10, please send photos and i will take a look.
diLiviu
@MauricioZuniga thanks for the script .
Whatever I did, I could not reproduce your pic posted above.
Can you please help?
Thanks
MauricioZuniga
@diLiviu, if you right click on the chart, you should be able to see all of the parameters for how this was configured. It wouls be difficult to complety replicate given different market conditions, but should give you some ideas on how to create your own config.
dogekao
Hii boss , can be used for scalp 15 min btc
MauricioZuniga
@dogekao, can be used on any chart any time frame. But if you use 15 min, you can run into a 15 min delay after confirmation, since it will wait for bar to close after confirmation.
Winivecait
does this script buy and sell automatically? or do i still need to place the orders?? ty
MauricioZuniga
@Winivecait, you can use the open and close message to integrate with a platform and automate your trading. I personally use wundeebit. The most success i usually have is by using this and combining an element of dca in case the market moves against the trade a bit.
gadgetsfan
@MauricioZuniga, Hey, thanks for the great script. I am a little confused regarding what should be set to what timeframe settings.

I get the best backtest when I put the TradingView chart to 30m and the strategy resolution to 1 hour.

But I see you say set the charts to 1 min for the bots. Do you mean set the Wunderbit timeframe for the bot to 1 minute or does TradingView need to be set to the 1 minute chart to create the alert?

Also I take it you are just using {{strategy.order.action}} for your alert message?

Thanks
MauricioZuniga
@gadgetsfan, as for the alert message you are correct. Some things ro keep in mind, however, security funcrion (to help with repainting) is supposed to work witb higher time frames so your chart time frame should be lower than strategy time frame. If you are inverting the idea and using a lower time frame on strategy it could possibly work but its not intended to work like that. I would forward test it a bit before deployment. Please do let us know if that somehow works better. Some other things to keep in mind: if you are using anything other than 1 minute chart your signal can be delayed by a factor of 2xTimeframe. This is because the script will look for confirmation and that might not happen until bar after it happened then pinescript can wait until the end of the bar to send the signal since strategies are supposed to be recalculated at end of bar. This can lead to trading that is not congruent with the backtest. Back test can only give you a good idea with most ideal imaginary deployment. This is why i recommend trying a 1 min chart. You might not get as good backtest reaults but keep in mind that it only uses about 1 week of data for this time frame... whereas other timeframes give you much longer periods. I am still not rich and trying to figure it out for myself ;) but perhaps if we all collaborate and report findings we can help each other succeed. I typically use this in conjunction with a dca 3 orders of 8%,2xVol multiplier,2x price deviation.. trailing profit of about 3% and get most of my trades to close profitably but you are taking risk if market moves against you because now you invested more. Lastly theres a few settings via code we could tinker with or bring into configuration we could try (calc on every tick, make orders on bsr close, etc) which could speed up the actual signal a little bit but could also introduce some false signals if we don't think sbout it carefully. I am experimenting with another algorithm where i am very careful in code to only open on confirmation but close if tick moves against you in trailing profit. I will try to update this algorithm once i have it dialed in. Also... one last thing. Don't let pinescript close your orders. It doesn't know the actual price it was filled via webhook, wunderbit should close the order based on trailing profit or stop loss to ensure your order is profitable based on the actual entry. To do this just leave close order comment blank or set to wwc (wunderbit will close). Lastly i personally always set my time frame to 1m on wunderbit so it is recalculating as quickly as possible to close a trade profitably. This however could work against you if you are looking for much larger moves. Hope that helps.
Lebih