Trading with Python: Simple Scalping Strategy

preview_player
Показать описание
Welcome again! In this video we will discuss a trading strategy that has shown remarkable potential. Our Python-based approach to this simple scalping system has yielded over 200% returns in just a three-month testing period, demonstrating its effectiveness and potential for both manual and algorithmic trading styles.

Our focus is on a trading strategy that can be easily optimized and adapted to your trading needs. The strategy is straightforward, making it ideal for both new and experienced traders. We use a 5-minute timeframe to accelerate trading and increase the number of trades, optimizing the risk-reward ratio and other key parameters through Python and numerical backtesting.

The Python code for this backtest is readily available for download from the link below,this allows you to follow along, experiment, and tailor the strategy to your trading preferences. We utilize two moving average curves to identify market trends: a fast moving average and a slow moving average. This helps in determining uptrends and downtrends, guiding our decision on whether to take long or short positions.

Additionally, we incorporate Bollinger bands to pinpoint entry points for positions.

We also discuss how to set stop-loss (SL) and take-profit (TP) distances by considering market volatility and using the Average True Range (ATR) indicator. The exact numerical values for the lengths of the moving averages and the parameters of the Bollinger bands will be detailed in the coding part of the video.

💲 Discount Coupon for My Course on Algorithmic Trading:

PDF Book (Amazon):

The Python Code is available here:

The data file:
Рекомендации по теме
Комментарии
Автор

Great video! Concise and clear explanations. In my backtesting, I found this strategy only worked well in 2024. Running this strategy on previous years did not yield the same results. Market behaviour does change over the years.

bravesirdonald
Автор

Yes, test it out. Nothing gets done by thought 👌

cap
Автор

Another well-thought out video, concise and helpful! Many thanks!

athanasrenti
Автор

I think it would be interesting seeing it traded on a paper account. Throw it up a few different tickers, a few up trends, a few down trends, and a few that are just oscillating. Maybe even some ETF pairs. Cool little video.

cachecoder
Автор

Notice that if you want to use prop firms, their max open DD is 5%. To get that, lower the lot size. As to trading costs, EURUSD is the best. Many brokers have zero spread, and you can adopt a spread filter. As you're scalping, no swap required. For the equity curve, you need both the balance and equity as function of time.

FighterFred
Автор

I think the calculation of the SL (Stop Loss) and TP (Take Profit) needs to be re-evaluated, as sometimes the TP/SL is less than 5 pips, which most brokers will not accept. With such low values, the probability of having a correct prediction increases, and the drawdown will be less, which might look impressive in backtesting. However, in reality, it may not meet expectations. Also, the ratio between the SL and the TP is low, ranging from 1.1 to 1.5. I believe this is bet low, especially when considering a 40% win rate.
With that being said, the video is great.

abdsh
Автор

First thank you so much for such amasing and excellent video. I propose to implement the long position scalping strategy using MACD as a signal for potential entry position, then wait until EMA 21 crosses EMA 50, price has to be on top of EMA 200 and VWAP, price hitting support line with red candles with acceptable body and long whicks, high body green candles and high trading volume to make sure the price will bounce to up trend, as higher number of confluence we have, higher is the probability to enter a good position. Additionall, it will be interesting to add market sentiment analysis to connect our technical analysis with fundamental analysis., stop loss and take profit same conditions you shiwed on the video.

Maximus.
Автор

great work, simple and effective, thank you for sharing those informations, keep going !!

mohammedkerdoud
Автор

Very cool, thanks! Going to give it a try this week.

strathausen
Автор

Hi thank you for this precious contents. I envy the ability you have to explain. just a consideration, you buy/sell, placing a market order and you set sl and tp considering current price, this has sense using limit order but, in this case, I guess that is better to place market order and during the next candle set sl and tp using the trade averaged price...this avoid situation in which entry price is over tp or sl. anyway thank you very much.

tradingbotconale
Автор

Very interesting video ! Question - was there a particular reason you used the BB value of 1.5 rather than 1 and a length of 15 rather than the standard 20 ?

icometofightrocky
Автор

Have any tools or backtest library that we can backtest the strategy with the spreads? Examples add the spreads with 1 pips or 0.5 pips for the backtesting.

trantrunghieu
Автор

Excellent.
I propose another idea of ​​regression to the mean.
Consider VWAP and a channel some distance from the line.
Only in high trading hours or with minimal volume does the price tend to return to the vwap trading point.

juanbernal
Автор

Great video! I'm also going through your Udemy courses as well. Love them! I do have a question on this video though. What is meant by "MySize=3000" and "Margin=1/30"? Are we assuming each trade is 3000 units (dollars, in this case) and the we're leveraging at 30:1?

CptnYarface
Автор

hi, i love your videos ! Do you have the script to implement this strategy in Tradingview ? Thanks

timnguyen
Автор

Hi, very nice work, I'm testing it with other currency, but where i can find your backtesting package? To test it your full metrics?

williamlacerra
Автор

Interesting video, thank you for making it.
1/ I'd like to see it run against a paper account.
2/ I'd like to see the code for interacting with a brokerage like Interactive Brokers.
3/ I'd like to see all fees included too.

Thanks!

daithi
Автор

HI hi!! nice to meet you! great video!. I have a cuestion. Where you get the information of the data file?

JoseMariaAcuña-vk
Автор

Awesome content as always, keep up the great work!
Also wanted to share some small optimization for the calculations part of the code:

def vectorized_ema_signal(df, backcandles):

df['EMA_fast < EMA_slow'] = 0
df['EMA_fast > EMA_slow'] = 0

df.loc[(df['EMA_fast'] < df['EMA_slow']), 'EMA_fast < EMA_slow'] = 1
df.loc[(df['EMA_fast'] > df['EMA_slow']), 'EMA_fast > EMA_slow'] = 1

df['PreEMASignal'] = 0
df.loc[(df['EMA_fast < EMA_slow'] == 0) & (df['EMA_fast > EMA_slow'] == 0), 'PreEMASignal'] = 3
df.loc[(df['EMA_fast < EMA_slow'] == 1) & (df['EMA_fast > EMA_slow'] == 0), 'PreEMASignal'] = 1
df.loc[(df['EMA_fast < EMA_slow'] == 0) & (df['EMA_fast > EMA_slow'] == 1), 'PreEMASignal'] = 2

df['BackcandleSequence'] = df['PreEMASignal'].rolling(backcandles, min_periods=1).sum()
df['EMASignal'] = 0
== backcandles * 1), 'EMASignal'] = 1
== backcandles * 2), 'EMASignal'] = 2

df['EMASignal'] = df['EMASignal'].shift(1)
df['EMASignal'].fillna(1, inplace = True)

df.drop('EMA_fast < EMA_slow', axis=1, inplace=True)
df.drop('EMA_fast > EMA_slow', axis=1, inplace=True)
df.drop('PreEMASignal', axis=1, inplace=True)
df.drop('BackcandleSequence', axis=1, inplace=True)


def vectorized_total_signal(df):
df['TotalSignal'] = 0

df.loc[(df['EMASignal'] == 2) & (df.close <= df['BBL_12_2.5']), 'TotalSignal'] = 2
df.loc[(df['EMASignal'] == 1) & (df.close >= df['BBU_12_2.5']), 'TotalSignal'] = 1

It might speed up the code a bit, and again much appreciate the content :)

notcool
Автор

Very insightful your videos! Thank you !!! Maybe I very dumb question.. What would be the actual used case benefit of coding this in python.. rather than using trading view?

I am fairly new to all of this.. thank you a lot :-)

psychokarken