--

2509% Profit Unlocked: A Case Study on Algorithmic Trading with Freqtrade

Here is the 2nd edition of the famous article on building PROFITABLE TRADING STRATEGY. (New Strategy)

“Unlock 4450% Profit with Algorithm Trading on Cryptocurrency: A Freqtrade Case Study” — Link

We have covered lot of introductory topics in the above article which covers all key basic concepts which I mentioned below, if you are new to “trading”, “algorithm trading”, “freqtrade” platform or “futures trading” concepts, I suggest you to open my previous article and go through the same.

I’m here to talk about my new strategy which I was working for past few months

Topics covered in previous article: (Link)

Introduction to algorithmic trading and its benefits

What algorithmic trading is and how it can be used in the context of crypto futures trading

Some of the benefits of using algorithmic trading for crypto futures include:

Introduction to the freqtrade platform

Here are some key features of the freqtrade platform:

What is Short Trading and Long Trading in Futures Market

How Leverage works and Factors to consider while using Leverage during Trades

There are a few factors that traders should consider when deciding whether and how to use leverage:

  1. Risk appetite: Traders with a higher risk appetite may be more comfortable using larger amounts of leverage, while those who are more risk-averse may prefer to use less leverage or none at all.
  2. Trading strategy: Different trading strategies may be more or less suitable for leveraging, depending on the level of risk involved and the trader’s goals.
  3. Market conditions: The level of leverage that is appropriate for a trade may also depend on the current market conditions, such as the level of volatility or the overall trend of the market.
  4. Trading capital: Traders should also consider their available capital when deciding how much leverage to use, as they will need to have sufficient margin to cover any potential losses.

In general, it’s important for traders to carefully evaluate the potential risks and rewards of using leverage and to use it responsibly, as it can significantly impact the outcome of a trade.

Setting up freqtrade for crypto futures trading

  1. There are lot of tutorials about how to connect Freqtrade using docker in a containerized environment. You can refer to any of the many Youtube tutorials on the same.
  2. Here, Our main agenda is to show case the backtest and forward test results of the algorithm trading on freqtrade, so, I will focus on that more.
  3. If there is a lot of demand and requests in comments for a tutorial on how to setup freqtrade and run your own strategies if requested, I will add that in forth coming article. Thank you

Resources:

https://youtu.be/ASq2aeUHen8

or

https://youtu.be/PrPGKHCx5qY

or

https://youtu.be/H2OkrvSojOI

I’m giving reference only.

Backtesting a trading strategy with freqtrade

Backtesting is the process of simulating trades using historical market data to evaluate the performance of a trading strategy. Freqtrade includes a backtesting feature that allows users to backtest their trading strategies by specifying a range of dates and a set of market data to use in the simulation.

To backtest a trading strategy with freqtrade, you will need to follow these steps:

  1. Create a configuration file: Freqtrade requires a configuration file to specify the details of your crypto futures exchange account and your desired trading parameters. To create a configuration file, copy the sample configuration file provided in the freqtrade repository to a new file called “config.json”. Then, edit the file to specify your exchange credentials and desired trading parameters.
  2. Prepare your market data: Freqtrade requires a set of market data to use in the backtest. This data should be in the form of a CSV file with columns for the date, open price, high price, low price, close price, and volume of the asset being traded. You can obtain this data from a variety of sources, such as a cryptocurrency exchange or a market data provider.
  3. Run the backtest: Once you have your configuration file and market data ready, you can run the backtest by executing the following command:
freqtrade backtesting --config config.json --strategy MyStrategy --datadir data/

Replace “MyStrategy” with the name of your strategy function and “data/” with the directory where your market data is stored. This will run the backtest using the settings specified in your configuration file and the market data provided.

  1. Review the results: Once the backtest is complete, freqtrade will generate a report with information on the performance of your strategy. This report will include metrics such as the profit/loss, the number of trades executed, and the win/loss ratio of the strategy. You can use this information to evaluate the performance of your strategy and make any necessary adjustments.

By investing 1000 USDT, (1 USD approximately equal to 1 USDT with 1–2% variance)

for a period of 762 days (from 2021–01–02 06:00:00 up to 2023–02–04 02:00:00)

with maximum open trades at any given point of time being 5

maximum stake in each trade entry being around 190 USDT,

has given a Profit of 2509.75% Profit return on investment (ROI).

The Absolute Draw-down mentioned from results is at — 3.16%

Daily Win to Lose Ratio is at 458 days of WIN, 300 Days loss and 3 Days of Draw

Average Daily profit is at3.29% per day

Daily Average Trades is 25 approximate

Market Returns Have been (if you buy and hold Bitcoin (BTCUSDT) for the above mentioned period the returns are mentioned here, instead of trading) — 113.56%

Forward testing a trading strategy with freqtrade

Forward testing is the process of executing a trading strategy on live market data to evaluate its performance in real-time market conditions. Freqtrade includes a live trading feature that allows users to forward test their trading strategies by executing trades on a real exchange.

freqtrade forward testing live results for 1 month period from 20th jan 2023 to 20th Feb 2023
Individual trades profit and loss, overall performance of each asset, daily profit/loss returns and Bot performance overall are given here
Individual trades profit and loss, overall performance of each asset, daily profit/loss returns and Bot performance overall are given here

We can pause, resume, stop bot from running and the dashboard provides individual login credentials to secure.

People who invest in bots can hold the assets in their personal wallet without sending them to the 2nd party. You provide us a API key which will have rights to trade but won’t have any rights to withdraw the holding money. (This creates security, safety of assets and avoid any cyber attacks as a whole)

People who like to create their own bot and start running trades for gaining profits can also initiate the process through their personal account from any exchange, as freqtrade is connected with CCXT which has access to over 70+ crypto trading platform, it becomes easy for anyone across the world/globe to run the strategy and get amazing results.

Can Check Live Trades and Results on Telegram 24/7:

telegram integration with freqtrade for live trade results, analysis of stats, profit, daily performance, live enter exit trades and lot more
telegram integration with freqtrade for live trade results, analysis of stats, profit, daily performance, live enter exit trades and lot more
telegram integration with freqtrade for live trade results, analysis of stats, profit, daily performance, live enter exit trades and lot more

telegram integration with freqtrade for live trade results, analysis of stats, profit, daily performance, live enter exit trades and lot more

We can setup telegram bot with our freqtrade startegy easily by providing “chat_id” and “bot token” from telegram to our “config.json” file. The setup can help us in monitoring, controlling all our trades without need to open web portal.

To forward test a trading strategy with freqtrade, you will need to follow these steps:

  1. Create a configuration file: Freqtrade requires a configuration file to specify the details of your crypto futures exchange account and your desired trading parameters. To create a configuration file, copy the sample configuration file provided in the freqtrade repository to a new file called “config.json”. Then, edit the file to specify your exchange credentials and desired trading parameters.
  2. Enable live trading: In order to execute trades on a real exchange, you will need to set the “dry_run” option in your configuration file to “False”. This will enable live trading and allow freqtrade to place orders on the exchange.
  3. Run freqtrade: Once you have your configuration file set up, you can start the live trading feature by executing the following command:
freqtrade live --config config.json

This will start freqtrade using the settings specified in your configuration file and begin executing trades on the exchange.

  1. Monitor the trades: As freqtrade executes trades, it will log the details of each trade to the console. You can use this information to monitor the performance of your strategy in real-time and make any necessary adjustments.
  2. Review the results: Once you have finished forward testing your strategy, you can review the overall performance by looking at the profit/loss and other metrics generated by freqtrade. This will allow you to evaluate the performance of your strategy and make any necessary adjustments.

If you set the “dry_run” option in your configuration file to “True” and run freqtrade with this configuration, the platform will simulate trades without actually executing them on the exchange. This is known as “dry run” mode.

There are a few advantages to using dry run mode when testing a trading strategy:

  1. It allows you to test your strategy without risking real funds: Because the trades are not executed on the exchange, you will not be at risk of losing any money if your strategy performs poorly. This can be useful for testing and fine-tuning your strategy without incurring any real losses.
  2. It can save time: Dry run mode allows you to quickly test your strategy and see how it would have performed under different market conditions. This can be more efficient than waiting for trades to execute on the exchange and can allow you to iterate more quickly on your strategy development.
  3. It can help you debug your strategy: If you encounter any errors or issues when testing your strategy, dry run mode can make it easier to identify and troubleshoot them. Because the trades are not being executed on the exchange, you can more easily see what is happening behind the scenes and debug any issues that arise.

Overall, dry run mode can be a useful tool for testing and developing trading strategies without incurring real losses or spending a lot of time waiting for trades to execute.

Strategy I used Here:

I have used total of 3 key indicators, namely

The slope is dope (combination of slow and fast EMA), RSI, ADX

Combined with volume indicator.

Slope Is Dope:

  • “Slope is Dope” is a technical analysis strategy that uses moving averages to identify market trends and momentum.
  • The strategy involves plotting two exponential moving averages (EMA) with different periods on a price chart.
  • The shorter EMA is typically set to 8 periods, while the longer EMA is set to 21 periods.
  • The strategy is based on the concept that when the shorter EMA is above the longer EMA, it indicates a bullish trend, and when the shorter EMA is below the longer EMA, it indicates a bearish trend.
  • The slope of the EMA lines is used to confirm the trend. If the slope of both EMAs is positive, it indicates a strong bullish trend, and if the slope of both EMAs is negative, it indicates a strong bearish trend.
  • Traders using this strategy look for buy signals when the shorter EMA crosses above the longer EMA and the slope of both EMAs is positive. Conversely, they look for sell signals when the shorter EMA crosses below the longer EMA and the slope of both EMAs is negative.
  • Traders can use this strategy to identify potential entry and exit points for trades, as well as to set stop-loss orders to manage risk.

How to use RSI and ADX in combination for entering and exiting trades in general for both long and short positions:

  • RSI (Relative Strength Index) is a technical analysis indicator that measures the strength of a market trend by comparing the average gains and losses of an asset over a period of time.
  • ADX (Average Directional Index) is another technical analysis indicator that measures the strength of a trend and helps identify whether a market is trending or not.
  • To use RSI and ADX in combination, traders typically look for opportunities to enter or exit trades when the two indicators are showing similar signals.
  • For long positions, traders may look for oversold conditions on the RSI (typically below 30) combined with a rising ADX line above 20, which suggests a strong uptrend.
  • Traders may also look for bullish crossovers on the ADX indicator (where the positive directional indicator line crosses above the negative directional indicator line) combined with RSI readings above 50, which suggest a strong uptrend is in place.
  • For short positions, traders may look for overbought conditions on the RSI (typically above 70) combined with a falling ADX line below 20, which suggests a weak downtrend.
  • Traders may also look for bearish crossovers on the ADX indicator (where the negative directional indicator line crosses above the positive directional indicator line) combined with RSI readings below 50, which suggest a strong downtrend is in place.
  • In both long and short positions, traders may also use the ADX indicator to confirm the strength of the trend and stay in a trade as long as the trend remains strong.

Tips for improving the performance of a trading strategy with freqtrade

Here are a few tips for improving the performance of a trading strategy with freqtrade:

  1. Use historical data to evaluate your strategy: Before using your strategy in live trading, it’s important to test it using a range of historical market data to see how it performs under different market conditions. Freqtrade includes a backtesting feature that allows you to do this by simulating trades using historical data. By testing your strategy on a variety of data, you can get a better sense of its strengths and weaknesses and make any necessary adjustments.
  2. Optimize your strategy’s parameters: Many trading strategies have a set of parameters that can be adjusted to optimize their performance. Freqtrade includes a feature called “Hyperopt” that allows you to optimize your strategy’s parameters by searching for the combination that produces the best results. By optimizing your strategy’s parameters, you can improve its performance and increase the chances of success in live trading.
  3. Test your strategy in different market conditions: Different market conditions can have a big impact on the performance of a trading strategy. To get a better understanding of how your strategy will perform in different conditions, it’s a good idea to test it in a variety of markets, including both bull and bear markets. This will give you a sense of how your strategy behaves under different circumstances and allow you to make any necessary adjustments.
  4. Monitor your trades and adjust your strategy as needed: As you use your strategy in live trading, it’s important to monitor the performance of your trades and adjust your strategy as needed. This can help you identify any problems or weaknesses in your strategy and make adjustments to improve its performance. Some things you might want to consider when monitoring your trades include:

. The win/loss ratio: This is the percentage of trades that are profitable versus those that are unprofitable. A high win/loss ratio is generally a good sign, but it’s important to keep in mind that past performance is no guarantee of future results.

· The profit/loss: This is the overall gain or loss from your trades. It’s important to pay attention to this metric to see how your strategy is performing over time.

· The drawdown: This is the maximum loss from a series of trades. A high drawdown can indicate that your strategy is taking on too much risk, so it’s important to keep an eye on this metric and adjust your risk management techniques as needed.

By monitoring your trades and adjusting your strategy as needed, you can improve the performance of your strategy and increase your chances of success in the market.

5. Usage of different time period candle sticks and advantages: Candlestick charts are a type of chart that is commonly used in technical analysis to visualize the price action of an asset over time. Each candlestick on the chart represents a specific time period, and the chart is composed of a series of these candlesticks. The time period for each candlestick can vary, with common periods being 1 minute, 5 minutes, 15 minutes, 30 minutes, 1 hour, 4 hours, and 1 day.

The choice of time period for the candlesticks can have a big impact on the appearance and interpretation of the chart. For example, a chart with 1-minute candlesticks will show a lot of detail and may be more suited for short-term trading, while a chart with 4-hour candlesticks will show less detail and may be more suited for longer-term trading.

There are a few advantages to using different time periods for candlesticks:

  1. It allows you to see different time frames: By using different time periods, you can view the same asset at different time frames and get a sense of how it is performing over different time horizons. This can be useful for traders who are looking to trade at different scales, such as scalping, day trading, or swing trading.
  2. It can help you identify trends: Different time periods can reveal different trends in the market. For example, a chart with 1-minute candlesticks may show a lot of short-term fluctuations, while a chart with 4-hour candlesticks may show longer-term trends. By looking at different time periods, you can get a better sense of the overall direction of the market and identify trends that may not be apparent on other time frames.
  3. It can help you manage risk: By using different time periods, you can tailor your risk management to the time frame you are trading. For example, if you are trading at a short-term time frame, you may want to use a tighter stop loss to protect against rapid price movements, while if you are trading at a longer-term time frame, you may be able to use a wider stop loss without increasing your risk.

While doing forward testing, it is crucial to monitor results for every 100 trades. How many profit to loss trades happened, what is winning %, what is the maximum draw down that happened. While creating a strategy, total Maximum Number of trades and Maximum amount to enter a trade has to be clear. Also, test your strategy on multiple timeframes from 1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d time frames. This will give you overall idea of how your strategy works at different time intervals. Keep optimzing your strategy till you get profits for 500+ trades, also run dry run tests for 2 months before comfirming if your strategy is profitable or not.

Overall, using different time periods for candlesticks can be a useful tool for traders who want to analyze and trade the market at different scales. It’s important to experiment with different time periods and find the one that works best for your trading style and goals.

Conclusion

  1. Freqtrade is an amazing platform to do cryptocurrency algorithm trading which can run for 24/7, 365 days with multiple assets or chosen limited assets as configured by the user.
  2. We can setup number of trades limit, amount to enter a trade, stop-loss, take profit, trailing stop-loss, strategy to enter trades and exit them, can do both spot trading and futures trading, can use leverage and lot more features.
  3. People who are interested to build own bot or who would like to invest in our pre-built cryptocurrency bots can contact me on patreon or other given social networks given by me below.
  4. Algorithm trading can be profitable and less stress free if proper setup and trading strategies are built. There is no 1 gurantee trading strategy that will work wonderful during all market conditions, so we have to create minimum of 2–3 trading bots that can sustain any market condition. (up trend market or down trend market or side way trend market).
  5. In conclusion, algorithmic trading on cryptocurrency using the freqtrade platform can be an effective way to generate profit in the market. By setting up freqtrade with the right configuration and strategy, traders can automate their trades and take advantage of market movements to generate consistent returns. As we have seen in this case study, it is possible to achieve a profit of 4450% using algorithmic trading with freqtrade. However, it’s important to keep in mind that past performance is no guarantee of future results and that trading carries inherent risks. By carefully testing and monitoring their strategies, traders can increase their chances of success and make informed decisions about their trading activities.

Thank you, Readers.

I hope you have found this article on crypto strategy to be informative and helpful. As a creator, I am dedicated to providing valuable insights and analysis on cryptocurrency, stock market and other assets management.

If you have enjoyed this article and would like to support my ongoing efforts, I would be honored to have you as a member of my Patreon community. As a member, you will have access to exclusive content, early access to new analysis, and the opportunity to be a part of shaping the direction of my research.

Membership starts at just $10, and you can choose to contribute on a monthly basis. Your support will help me to continue to produce high-quality content and bring you the latest insights on financial analytics.

Patreon https://patreon.com/pppicasso

Regards,

Puranam Pradeep Picasso

Linkedin — https://www.linkedin.com/in/puranampradeeppicasso/

Patreon — https://patreon.com/pppicasso

Facebook — https://www.facebook.com/puranam.p.picasso/

Twitter — https://twitter.com/picasso_999

--

--

Puranam Pradeep Picasso - ImbueDesk Profile

Algorithmic Trader, AI/ML & Crypto Enthusiast, Certified Blockchain Architect, Certified Lean Six SIgma Green Belt, Certified SCRUM Master and Entrepreneur