Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About backtesting and real-life situations #24

Open
riven-blade opened this issue Oct 5, 2024 · 31 comments
Open

About backtesting and real-life situations #24

riven-blade opened this issue Oct 5, 2024 · 31 comments

Comments

@riven-blade
Copy link

The exit of this strategy relies too much on trailing_stop, and uses market orders. During the price drop, the slippage is more obvious, and the difference between backtesting and real trading is huge.

@Saber2pr
Copy link

这个是抄底策略,持续缓慢下跌的时候会连续止损,最好加个protection

@riven-blade
Copy link
Author

如果是抄底策略, 那更不合适了, 因为它的每次盈利点都很低, 盈利低, 抄底风险高, 显然不合适啊

@Saber2pr
Copy link

如果是抄底策略, 那更不合适了, 因为它的每次盈利点都很低, 盈利低, 抄底风险高, 显然不合适啊

超参数调一下profit factor,把盈亏比调高一些

@Saber2pr
Copy link

这个策略入场的位置很好,不好的地方就是止盈和止损,止盈太快了,大概10~20分钟就止盈了,即使后面还会上涨,因为这个策略用的fastk止盈,fastk感觉只能吃到一波上涨。止损不太行,之前的版本用custom_stoploss移动止损还好一些,现在用了硬止损-25%,现在这个用hold自定义退出的逻辑我感觉还是不行。

@imsatoshi
Copy link

可以使用这个项目来对策略进行全局优化 https://github.com/imsatoshi/GeneTrader.git

@Mastaaa1987
Copy link

You have to do a backtest with --enable-protections so that it respects the cooldown period !

This means that the profits in the backtests are close to the real ones

Mfg

@ssssi
Copy link
Owner

ssssi commented Oct 30, 2024

You have to do a backtest with --enable-protections so that it respects the cooldown period !

This means that the profits in the backtests are close to the real ones

Mfg

yeah, that is right

@ssssi
Copy link
Owner

ssssi commented Oct 30, 2024

这个策略入场的位置很好,不好的地方就是止盈和止损,止盈太快了,大概10~20分钟就止盈了,即使后面还会上涨,因为这个策略用的fastk止盈,fastk感觉只能吃到一波上涨。止损不太行,之前的版本用custom_stoploss移动止损还好一些,现在用了硬止损-25%,现在这个用hold自定义退出的逻辑我感觉还是不行。

哎,这玩意不好弄,我自己都改乱了.

@Mastaaa1987
Copy link

Mastaaa1987 commented Oct 31, 2024

So the last changes to the strategy are all unnecessary. buy_new drags down the performance of the strategy. And on top of that, the custom_stoploss only triggers when the profit is over 5%, but that is the point at which trailing_stop ends the trade. So that makes no sense.
If I test the strategy with buy_new, the performance is worse than with buy_1 alone.
But if I use the standard settings with buy_1 alone and set:
stoploss = -0.05
trailing_stop_positive = 0.0037
trailing_stop_positive_offset = 0.037
The performance of the strategy in the same test period is about 200% better! (in 150 days you: about 700%, and with my settings: 1500%)
The positive trailing_stop triggers 120x in the same period with 0.037 & only 50x with 0.05...
And it doesn't matter which period I use between 2023, 2024 for testing! With buy_1 only and the settings above, with all pairs on Binance, this setup is always better in terms of profits! There is not a single month of negative profits...
As you already said in the readme:
Don't try to create a complex strategy. Simple is often the most effective.

@ssssi
Copy link
Owner

ssssi commented Oct 31, 2024

So the last changes to the strategy are all unnecessary. buy_new drags down the performance of the strategy. And on top of that, the custom_stoploss only triggers when the profit is over 5%, but that is the point at which trailing_stop ends the trade. So that makes no sense. If I test the strategy with buy_new, the performance is worse than with buy_1 alone. But if I use the standard settings with buy_1 alone and set: stoploss = -0.05 trailing_stop_positive = 0.0037 trailing_stop_positive_offset = 0.037 The performance of the strategy in the same test period is about 200% better! (in 150 days you: about 700%, and with my settings: 1500%) The positive trailing_stop triggers 120x in the same period with 0.037 & only 50x with 0.05... And it doesn't matter which period I use between 2023, 2024 for testing! With buy_1 only and the settings above, with all pairs on Binance, this setup is always better in terms of profits! There is not a single month of negative profits... As you already said in the readme: Don't try to create a complex strategy. Simple is often the most effective.

Cool.I can see that you have been studying and paying attention to my strategy, thank you very much, my every revision is just my simple idea, I have been groping and studying. Maybe you can do better than me. And thank you for your advice.

@riven-blade
Copy link
Author

So the last changes to the strategy are all unnecessary. buy_new drags down the performance of the strategy. And on top of that, the custom_stoploss only triggers when the profit is over 5%, but that is the point at which trailing_stop ends the trade. So that makes no sense. If I test the strategy with buy_new, the performance is worse than with buy_1 alone. But if I use the standard settings with buy_1 alone and set: stoploss = -0.05 trailing_stop_positive = 0.0037 trailing_stop_positive_offset = 0.037 The performance of the strategy in the same test period is about 200% better! (in 150 days you: about 700%, and with my settings: 1500%) The positive trailing_stop triggers 120x in the same period with 0.037 & only 50x with 0.05... And it doesn't matter which period I use between 2023, 2024 for testing! With buy_1 only and the settings above, with all pairs on Binance, this setup is always better in terms of profits! There is not a single month of negative profits... As you already said in the readme: Don't try to create a complex strategy. Simple is often the most effective.

Hello, have you tested it in the real market? I have tested it in the real market. I have been losing money, but the backtest is profitable. I have analyzed the reasons. One is because of trailing_stop and the other is because of the slippage of the market price order, which is not slippage. How much loss did the points cause? It was the slippage that caused trailing_stop. I originally quit during the backtest, but now I won’t quit.

@Mastaaa1987
Copy link

Mastaaa1987 commented Nov 1, 2024

Man, I found a freqtrade strategy that has a win rate of 100% from 01/01/2024 to today and with 230 pairs on Binance...
It's just unbelievable, trade length (AVG) ~2:50:00 & ~3 trades per day...
If you're interested, look here:
https://github.com/Mastaaa1987/freqtrade-strategy
I've also uploaded several backtest results ;-)

It's actually too good to be true, but when I look at the dataframe plot of the individual pairs, the trades all seem to look good. That's why I've just switched from this strategy to the new one and am now testing it in live mode...

If you have some experience, let me know...

Best regards

@riven-blade
Copy link
Author

Man, I found a freqtrade strategy that works from 01/01/2024 to today and with 230 pairs on Binance, a win rate of 100%... It's just incredible, trade length (AVG) ~2:50:00 & ~3 trades per day... If you're interested, look here: https://github.com/Mastaaa1987/freqtrade-strategy Best regards

argrelextrema
This function will use future data, you can run it in real time

@riven-blade
Copy link
Author

Man, I found a freqtrade strategy that has a win rate of 100% from 01/01/2024 to today and with 230 pairs on Binance... It's just unbelievable, trade length (AVG) ~2:50:00 & ~3 trades per day... If you're interested, look here: https://github.com/Mastaaa1987/freqtrade-strategy I've also uploaded several backtest results ;-)

It's actually too good to be true, but when I look at the dataframe plot of the individual pairs, the trades all seem to look good. That's why I've just switched from this strategy to the new one and am now testing it in live mode...

If you have some experience, let me know...

Best regards

You could use a sliding window, limit it to future data, and then backtest it.

@Mastaaa1987
Copy link

a sliding window? Im confused what do you mean exactly?

@Saber2pr
Copy link

Saber2pr commented Nov 1, 2024

Man, I found a freqtrade strategy that has a win rate of 100% from 01/01/2024 to today and with 230 pairs on Binance... It's just unbelievable, trade length (AVG) ~2:50:00 & ~3 trades per day... If you're interested, look here: https://github.com/Mastaaa1987/freqtrade-strategy I've also uploaded several backtest results ;-)
It's actually too good to be true, but when I look at the dataframe plot of the individual pairs, the trades all seem to look good. That's why I've just switched from this strategy to the new one and am now testing it in live mode...
If you have some experience, let me know...
Best regards

You could use a sliding window, limit it to future data, and then backtest it.

argrelextrema 这个方法有个order参数貌似就是防止前瞻的

@riven-blade
Copy link
Author

Man, I found a freqtrade strategy that has a win rate of 100% from 01/01/2024 to today and with 230 pairs on Binance... It's just unbelievable, trade length (AVG) ~2:50:00 & ~3 trades per day... If you're interested, look here: https://github.com/Mastaaa1987/freqtrade-strategy I've also uploaded several backtest results ;-)
It's actually too good to be true, but when I look at the dataframe plot of the individual pairs, the trades all seem to look good. That's why I've just switched from this strategy to the new one and am now testing it in live mode...
If you have some experience, let me know...
Best regards

You could use a sliding window, limit it to future data, and then backtest it.

argrelextrema 这个方法有个order参数貌似就是防止前瞻的

没有用的, 我试过

@riven-blade
Copy link
Author

Man, I found a freqtrade strategy that has a win rate of 100% from 01/01/2024 to today and with 230 pairs on Binance... It's just unbelievable, trade length (AVG) ~2:50:00 & ~3 trades per day... If you're interested, look here: https://github.com/Mastaaa1987/freqtrade-strategy I've also uploaded several backtest results ;-)
It's actually too good to be true, but when I look at the dataframe plot of the individual pairs, the trades all seem to look good. That's why I've just switched from this strategy to the new one and am now testing it in live mode...
If you have some experience, let me know...
Best regards

You could use a sliding window, limit it to future data, and then backtest it.

argrelextrema 这个方法有个order参数貌似就是防止前瞻的

滑动窗口可以

@Mastaaa1987
Copy link

So the last changes to the strategy are all unnecessary. buy_new drags down the performance of the strategy. And on top of that, the custom_stoploss only triggers when the profit is over 5%, but that is the point at which trailing_stop ends the trade. So that makes no sense. If I test the strategy with buy_new, the performance is worse than with buy_1 alone. But if I use the standard settings with buy_1 alone and set: stoploss = -0.05 trailing_stop_positive = 0.0037 trailing_stop_positive_offset = 0.037 The performance of the strategy in the same test period is about 200% better! (in 150 days you: about 700%, and with my settings: 1500%) The positive trailing_stop triggers 120x in the same period with 0.037 & only 50x with 0.05... And it doesn't matter which period I use between 2023, 2024 for testing! With buy_1 only and the settings above, with all pairs on Binance, this setup is always better in terms of profits! There is not a single month of negative profits... As you already said in the readme: Don't try to create a complex strategy. Simple is often the most effective.

Hello, have you tested it in the real market? I have tested it in the real market. I have been losing money, but the backtest is profitable. I have analyzed the reasons. One is because of trailing_stop and the other is because of the slippage of the market price order, which is not slippage. How much loss did the points cause? It was the slippage that caused trailing_stop. I originally quit during the backtest, but now I won’t quit.

Sorry My Englisch is not the best ... I have the same problem, can you help me out, i'm not understanding the problem really

@riven-blade
Copy link
Author

So the last changes to the strategy are all unnecessary. buy_new drags down the performance of the strategy. And on top of that, the custom_stoploss only triggers when the profit is over 5%, but that is the point at which trailing_stop ends the trade. So that makes no sense. If I test the strategy with buy_new, the performance is worse than with buy_1 alone. But if I use the standard settings with buy_1 alone and set: stoploss = -0.05 trailing_stop_positive = 0.0037 trailing_stop_positive_offset = 0.037 The performance of the strategy in the same test period is about 200% better! (in 150 days you: about 700%, and with my settings: 1500%) The positive trailing_stop triggers 120x in the same period with 0.037 & only 50x with 0.05... And it doesn't matter which period I use between 2023, 2024 for testing! With buy_1 only and the settings above, with all pairs on Binance, this setup is always better in terms of profits! There is not a single month of negative profits... As you already said in the readme: Don't try to create a complex strategy. Simple is often the most effective.

Hello, have you tested it in the real market? I have tested it in the real market. I have been losing money, but the backtest is profitable. I have analyzed the reasons. One is because of trailing_stop and the other is because of the slippage of the market price order, which is not slippage. How much loss did the points cause? It was the slippage that caused trailing_stop. I originally quit during the backtest, but now I won’t quit.

Sorry My Englisch is not the best ... I have the same problem, can you help me out, i'm not understanding the problem really

这个问题在于, 它使用的是市价单, 并且它的退出是基于盈利, 没有固定的退出位置

这会导致极大的不确定性, 就是回测中可能很好, 盈利退出了, 但是实盘中, 因为滑点, 导致盈利的时候并没有退出, 进而导致亏损

@riven-blade
Copy link
Author

So the last changes to the strategy are all unnecessary. buy_new drags down the performance of the strategy. And on top of that, the custom_stoploss only triggers when the profit is over 5%, but that is the point at which trailing_stop ends the trade. So that makes no sense. If I test the strategy with buy_new, the performance is worse than with buy_1 alone. But if I use the standard settings with buy_1 alone and set: stoploss = -0.05 trailing_stop_positive = 0.0037 trailing_stop_positive_offset = 0.037 The performance of the strategy in the same test period is about 200% better! (in 150 days you: about 700%, and with my settings: 1500%) The positive trailing_stop triggers 120x in the same period with 0.037 & only 50x with 0.05... And it doesn't matter which period I use between 2023, 2024 for testing! With buy_1 only and the settings above, with all pairs on Binance, this setup is always better in terms of profits! There is not a single month of negative profits... As you already said in the readme: Don't try to create a complex strategy. Simple is often the most effective.

Hello, have you tested it in the real market? I have tested it in the real market. I have been losing money, but the backtest is profitable. I have analyzed the reasons. One is because of trailing_stop and the other is because of the slippage of the market price order, which is not slippage. How much loss did the points cause? It was the slippage that caused trailing_stop. I originally quit during the backtest, but now I won’t quit.

Sorry My Englisch is not the best ... I have the same problem, can you help me out, i'm not understanding the problem really

你使用限价单回测, 会得到两种不同的结果, try 一下呢

@Mastaaa1987
Copy link

Mastaaa1987 commented Nov 1, 2024

Okay, I understand the problem...
So if I set the order to limit, will solve the problem?

@riven-blade
Copy link
Author

Okay, I understand the problem... So if I set the order to limit, will I solve the problem?

没有解决办法, 如果我有解决办法, 我还会亏钱吗?

@riven-blade
Copy link
Author

Man, I found a freqtrade strategy that has a win rate of 100% from 01/01/2024 to today and with 230 pairs on Binance... It's just unbelievable, trade length (AVG) ~2:50:00 & ~3 trades per day... If you're interested, look here: https://github.com/Mastaaa1987/freqtrade-strategy I've also uploaded several backtest results ;-)

It's actually too good to be true, but when I look at the dataframe plot of the individual pairs, the trades all seem to look good. That's why I've just switched from this strategy to the new one and am now testing it in live mode...

If you have some experience, let me know...

Best regards

另外这个策略, 建议不要上来实盘, 先dry一段时间, 你会看到跟回测的差距

@riven-blade
Copy link
Author

riven-blade commented Nov 1, 2024

Man, I found a freqtrade strategy that has a win rate of 100% from 01/01/2024 to today and with 230 pairs on Binance... It's just unbelievable, trade length (AVG) ~2:50:00 & ~3 trades per day... If you're interested, look here: https://github.com/Mastaaa1987/freqtrade-strategy I've also uploaded several backtest results ;-)
It's actually too good to be true, but when I look at the dataframe plot of the individual pairs, the trades all seem to look good. That's why I've just switched from this strategy to the new one and am now testing it in live mode...
If you have some experience, let me know...
Best regards

You could use a sliding window, limit it to future data, and then backtest it.

argrelextrema 这个方法有个order参数貌似就是防止前瞻的

这些我之前都测试过的, 你使用滑动窗口, 优化一些参数, 进行回测, 策略整体可能会盈利, 但是绝对跟现在的回测是两码事

@Mastaaa1987
Copy link

Do you mean this strategy here or the one I posted?

@Mastaaa1987
Copy link

Mastaaa1987 commented Nov 2, 2024

This doesn't necessarily belong here, but I found another strategy that has about the same profit as this one.
I'm currently trading in real live with this strategy and if I get the number of trades per day from the backtest, then it does what it promises...
Best regards
https://github.com/jilv220/freqtrade-stuff/blob/786f1e7cdea930dc7bfc4fe926e8a9629514e27d/ElliotV8_original_ichiv3.py

P.S. this strategy and the E0V1E can also be easily combined together. Only the E0V1E strategy pulls the stats down heavily

@14790897
Copy link

14790897 commented Nov 19, 2024

Man, I found a freqtrade strategy that has a win rate of 100% from 01/01/2024 to today and with 230 pairs on Binance... It's just unbelievable, trade length (AVG) ~2:50:00 & ~3 trades per day... If you're interested, look here: https://github.com/Mastaaa1987/freqtrade-strategy I've also uploaded several backtest results ;-)

It's actually too good to be true, but when I look at the dataframe plot of the individual pairs, the trades all seem to look good. That's why I've just switched from this strategy to the new one and am now testing it in live mode...

If you have some experience, let me know...

Best regards

If a strategy's profitability is so strong that it seems unrealistic, it is likely to have made a lookahead error, meaning it used future data to predict current trends, resulting in a win rate of 100%.

Wenn die Rentabilität einer Strategie so stark ist, dass sie unrealistisch erscheint, hat sie wahrscheinlich einen Lookahead-Fehler gemacht, d.h. sie hat zukünftige Daten verwendet, um aktuelle Trends vorherzusagen, was zu einer Gewinnrate von 100 % führt.

@Mastaaa1987
Copy link

@riven-blade
You should try this version of the strategy.
In this version it calculates the fastk_sell_exit 5 sec before recalculating all pairs. This should reduce the slippage to a minimum, hopefully, as long as everything works correctly...
But give it a try...
https://raw.githubusercontent.com/Mastaaa1987/freqtrade-strategie/refs/heads/main/user_data/strategies/E0V1E_test.py

@Mastaaa1987
Copy link

Mastaaa1987 commented Nov 29, 2024

Here are a few days results in direct comparison:
Regular :
Day (count) USDT USD Profit %
2024-11-29 (2) 39.026 USDT 39.03 USD 4.10%
2024-11-28 (6) 17.443 USDT 17.44 USD 1.87%
2024-11-27 (9) 41.786 USDT 41.79 USD 4.69%
2024-11-26 (10) -46.811 USDT -46.81 USD -4.99%
2024-11-25 (14) 61.347 USDT 61.35 USD 6.99%
2024-11-24 (12) -139.507 USDT -139.51 USD -13.72%
2024-11-23 (6) 23.405 USDT 23.40 USD 2.36%

Test 5 secondes :
Day (count) USDT USD Profit %
2024-11-29 (1) 3.169 USDT 3.17 USD 0.28%
2024-11-28 (6) 46.758 USDT 46.80 USD 4.35%
2024-11-27 (9) 43.052 USDT 43.10 USD 4.17%
2024-11-26 (10) -21.676 USDT -21.70 USD -2.06%
2024-11-25 (14) 78.415 USDT 78.49 USD 8.04%
2024-11-24 (13) -81.663 USDT -81.74 USD -7.72%
2024-11-23 (12) 68.532 USDT 68.60 USD 6.93%

@14790897
Copy link

14790897 commented Dec 8, 2024

So the last changes to the strategy are all unnecessary. buy_new drags down the performance of the strategy. And on top of that, the custom_stoploss only triggers when the profit is over 5%, but that is the point at which trailing_stop ends the trade. So that makes no sense. If I test the strategy with buy_new, the performance is worse than with buy_1 alone. But if I use the standard settings with buy_1 alone and set: stoploss = -0.05 trailing_stop_positive = 0.0037 trailing_stop_positive_offset = 0.037 The performance of the strategy in the same test period is about 200% better! (in 150 days you: about 700%, and with my settings: 1500%) The positive trailing_stop triggers 120x in the same period with 0.037 & only 50x with 0.05... And it doesn't matter which period I use between 2023, 2024 for testing! With buy_1 only and the settings above, with all pairs on Binance, this setup is always better in terms of profits! There is not a single month of negative profits... As you already said in the readme: Don't try to create a complex strategy. Simple is often the most effective.

Your analysis is nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants