OPEN-SOURCE SCRIPT

Customizable Non-Repainting HTF MACD MFI Scalper Bot Strategy

Updated
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 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.
Release Notes
Updated code comments
Release Notes
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.
Release Notes
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.
algorithmictradingAverage True Range (ATR)botMoving Average Convergence / Divergence (MACD)Money Flow Index (MFI)scalperscalpingscalptradingwunderbitwunderbit_trading

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 publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


Also on:

Disclaimer