Scalping Strategy Insights: Achieving Profitable Results
Written on
Chapter 1: Introduction to Scalping Strategies
In the world of trading, achieving a return of 220% in just 3.5 months on EUR/USD seems almost too good to be true. Let's scrutinize this claim and see if a similar approach can be applied to cryptocurrency!
This paragraph will result in an indented block of text, typically used for quoting other text.
Section 1.1: The Initial Claim
Hello again! Today, we’re diving into the fascinating realm of trading. The details of the code and parameters I utilized will be shared at the end. I recently watched a new video from the YouTube channel CodeTrading, showcasing a straightforward scalping strategy that allegedly generated 220% returns on EUR/USD. However, two aspects raise concerns: the excessive leverage of 30:1 and the absence of transaction fees.
This raises questions about the realism of such a backtest. While I possess strategies that yield impressive returns without accounting for fees, real-world trading operates differently. Let’s examine the strategy in detail!
Section 1.2: Strategy Breakdown
The strategy presented in the video focuses on a 5-minute timeframe for EUR/USD:
- Uptrend Condition: EMA(30) > EMA(50) for the last 7 candles
- Downtrend Condition: EMA(30) < EMA(50) for the last 7 candles
- Buy Signal: Uptrend & Close < lower Bollinger Band (15, std=1.5)
- Sell Signal: Downtrend & Close > upper Bollinger Band (15, std=1.5)
- Position Closure: Utilize stop loss and take profit based on 1.1*ATR(7) with a risk-reward ratio (RRR) of 1.5
If the details seem complex, don't worry; the code will clarify everything!
Now, instead of EUR/USD, we will apply this strategy to cryptocurrencies, eliminating leverage and incorporating a transaction cost of 0.1% per trade.
Chapter 2: Testing the Strategy on ETH/USD
The first video titled "7 Profitable Scalping Lessons After 7 Years of Trading Forex" provides valuable insights into trading strategies.
Continuing with our analysis, here are the results for ETH/USD based on the parameters shared in the video:
params = {
'fast_ema_period': 30,
'slow_ema_period': 50,
'bb_period': 14,
'bb_std': 1.5,
'atr_period': 7,
'atr_factor': 1.1,
'rrr': 1.5,
'trend_ma_period': 7,
'trend_threshold': 1
}
When backtesting on the ETH/USD 5-minute timeframe without fees or leverage, we observe a steady upward trend post a low of 50k, suggesting that the strategy has potential.
However, when we factor in the 0.1% fees:
Backtest on ETH/USD 5min timeframe, 0.1% fees and no leverage. Grey: ETH, Purple: Portfolio. Plot by author.
The results are not encouraging, as we start to incur losses—a common occurrence in algorithmic trading.
Section 2.1: Adjusting Parameters for Better Performance
To minimize the number of trades, let's tweak the parameters:
params = {
'fast_ema_period': 40,
'slow_ema_period': 100,
'bb_period': 50,
'bb_std': 4,
'atr_period': 5,
'atr_factor': 4,
'rrr': 1,
'trend_ma_period': 1,
'trend_threshold': 1
}
This adjustment leads to a more favorable backtest outcome:
A better backtest on ETH/USD 5min timeframe, 0.1% fees and no leverage. Grey: ETH, Purple: Portfolio. Plot by author.
Here are the updated statistics:
- Win Rate: 62%
- Maximum Drawdown: 18%
- Total Trades: 175 over 1112 Days
- Sortino Ratio: 2.28
- Total Return: 166.5%
Section 2.2: Refining Strategy for Optimization
While these results are promising, it’s crucial to avoid overfitting. The next step involves integrating the RSI indicator into our strategy:
- Buy Signal: Uptrend & Close < lower Bollinger Band & RSI < Certain Threshold
- Sell Signal: Downtrend & Close > upper Bollinger Band & RSI > Certain Threshold
We will then evaluate 138,240 different parameter combinations using only 60% of the data for training. Instead of relying solely on total returns or the Sortino ratio, we’ll develop a new scoring system based on equity curve performance.
The score is calculated by analyzing multiple overlapping windows of the equity curve, ensuring that we account for consistent performance rather than singular lucky trades.
Now, after running the tests, I’ve identified some top-performing combinations based on this new score.
Backtest results for train (60%) and test (40%) based on our simple score. Image by author.
Among these, combinations yielding consistent results in both training and testing phases include those between 30708 and 30713, balancing high returns and respectable Sortino ratios.
The second video titled "Simple Scalp Trading Strategy For Consistent Profits (LOW RISK)" further explores effective trading strategies.
Let’s review the results from combination 30708:
Combination 30708 on ETH/USD 5min timeframe (training), 0.1% fees and no leverage. Grey: ETH, Purple: Portfolio. Plot by author.
Combination 30708 on ETH/USD 5min timeframe (test), 0.1% fees and no leverage. Grey: ETH, Purple: Portfolio. Plot by author.
The strategy performs better on test data than it did during training, which is an encouraging sign.
Section 2.3: Evaluating the Sortino Ratio
In addition to total returns, I've tracked the Sortino ratios for each window in our scoring. This allows us to identify "green" windows where the Sortino ratio exceeds 2.
Backtest results for train (60%) and test (40%) based on our score for sortino ratios. Image by author.
Several combinations, particularly those between 22116 and 22121, exhibit strong Sortino ratios and robust returns throughout both training and testing phases.
Section 2.4: Final Thoughts and Cautions
While the results may seem favorable, it’s essential to exercise caution. The high risk-reward ratio of 4, coupled with an ATR factor of 3, could indicate heightened risk.
Thank you for joining me today! I encourage you to explore further, and until next time, happy trading!
# Here's the code I used for backtesting. The only thing that is missing is the price data. That is up to you!
import numpy as np
import numba
import talib
import vectorbt as vbt
import pandas as pd
# The rest of the code follows...