joshyattridge / smart-money-concepts

Discover our Python package designed for algorithmic trading. It brings ICT's smart money concepts to Python, offering a range of indicators for your trading strategies.
https://pypi.org/project/smartmoneyconcepts/
MIT License
334 stars 190 forks source link

Issue with bos_choch Function Returning Empty DataFrame #53

Open B14ckP4nd4 opened 2 months ago

B14ckP4nd4 commented 2 months ago

Hi,

I'm encountering an issue with the bos_choch function. Despite following the documentation and ensuring that the input dataframes are correctly formatted, the bos_choch function consistently returns an empty dataframe.

Here's a brief overview of my setup:

The intermediate outputs seem correct, but the final bos_choch result is empty. Here is a snippet of my code:

from smartmoneyconcepts import smc

dataframe.columns = [col.lower() for col in dataframe.columns]
swing_highs_lows = smc.swing_highs_lows(dataframe, swing_length=20)
if not swing_highs_lows.empty:
    breakOFStructure = smc.bos_choch(dataframe, swing_highs_lows, close_break=False)
    print(breakOFStructure.head())
else:
    print("Swing Highs and Lows DataFrame is empty.")

I've ensured that the dataframe and swing_highs_lows contain valid data.

dataframe is belong to BTCUSDT:USDT Binance and I'm sure its contain some Break of Structures

thank you

my chart screenshot :

hint : the double x is swings points image

keiser1080 commented 3 weeks ago

@B14ckP4nd4 post the result of

print(dataframe.head())
print(smc.swing_highs_lows(dataframe, swing_length=40).dropna())
print(breakOFStructure .dropna())

i will try to help

@joshyattridge this repo is still maintained ?

huynhphuong10284 commented 3 days ago

@B14ckP4nd4 the following is results: 1. dataframe.head() index date open high low close volume spike 0 251 2024-09-12 12:15:00 2519.820 2522.116 2519.284 2522.021 1221 0 1 252 2024-09-12 12:20:00 2522.056 2523.528 2521.239 2522.730 1212 0 2 253 2024-09-12 12:25:00 2522.690 2523.076 2520.674 2520.687 1114 0 3 254 2024-09-12 12:30:00 2520.786 2524.630 2518.912 2524.449 1491 0 4 255 2024-09-12 12:35:00 2524.478 2526.298 2523.466 2525.773 1848 1 5 256 2024-09-12 12:40:00 2525.798 2530.420 2525.756 2527.592 2621 1 6 257 2024-09-12 12:45:00 2527.539 2535.317 2527.216 2534.519 1856 0 7 258 2024-09-12 12:50:00 2534.485 2535.351 2532.711 2532.936 2006 0 8 259 2024-09-12 12:55:00 2532.963 2533.962 2527.315 2528.528 1980 0 9 260 2024-09-12 13:00:00 2528.552 2531.049 2522.090 2531.005 3638 1 10 261 2024-09-12 13:05:00 2530.997 2540.841 2529.942 2539.140 2789 0 11 262 2024-09-12 13:10:00 2539.098 2542.393 2537.651 2538.162 3685 1 12 263 2024-09-12 13:15:00 2538.102 2538.415 2531.371 2532.815 2163 0 13 264 2024-09-12 13:20:00 2532.771 2535.229 2531.005 2535.229 2697 0 14 265 2024-09-12 13:25:00 2535.179 2539.565 2534.909 2539.565 2398 0 15 266 2024-09-12 13:30:00 2539.598 2540.730 2537.347 2537.651 2998 0 16 267 2024-09-12 13:35:00 2537.618 2544.770 2537.439 2544.434 2672 0 17 268 2024-09-12 13:40:00 2544.409 2549.012 2543.671 2548.097 2862 0 18 269 2024-09-12 13:45:00 2548.131 2551.715 2543.798 2546.873 3709 0 19 270 2024-09-12 13:50:00 2546.922 2548.918 2544.721 2545.711 2712 0 20 271 2024-09-12 13:55:00 2545.740 2549.131 2545.270 2545.384 2179 0 21 272 2024-09-12 14:00:00 2545.359 2548.575 2544.370 2547.295 2828 0 22 273 2024-09-12 14:05:00 2547.335 2550.600 2547.079 2548.050 2098 0 23 274 2024-09-12 14:10:00 2548.086 2548.537 2542.858 2543.303 2249 0 24 275 2024-09-12 14:15:00 2543.332 2545.053 2542.019 2543.109 845 0

2. swing_highs_lows HighLow Level 0 1.0 2522.116 1 NaN NaN 2 NaN NaN 3 NaN NaN 4 NaN NaN 5 NaN NaN 6 NaN NaN 7 NaN NaN 8 NaN NaN 9 -1.0 2522.090 10 NaN NaN 11 NaN NaN 12 NaN NaN 13 NaN NaN 14 NaN NaN 15 NaN NaN 16 NaN NaN 17 NaN NaN 18 1.0 2551.715 19 NaN NaN 20 NaN NaN 21 NaN NaN 22 NaN NaN 23 NaN NaN 24 -1.0 2542.019

3. breakOFStructure BOS CHOCH Level BrokenIndex 0 NaN NaN NaN NaN 1 NaN NaN NaN NaN 2 NaN NaN NaN NaN 3 NaN NaN NaN NaN 4 NaN NaN NaN NaN 5 NaN NaN NaN NaN 6 NaN NaN NaN NaN 7 NaN NaN NaN NaN 8 NaN NaN NaN NaN 9 NaN NaN NaN NaN 10 NaN NaN NaN NaN 11 NaN NaN NaN NaN 12 NaN NaN NaN NaN 13 NaN NaN NaN NaN 14 NaN NaN NaN NaN 15 NaN NaN NaN NaN 16 NaN NaN NaN NaN 17 NaN NaN NaN NaN 18 NaN NaN NaN NaN 19 NaN NaN NaN NaN 20 NaN NaN NaN NaN 21 NaN NaN NaN NaN 22 NaN NaN NaN NaN 23 NaN NaN NaN NaN 24 NaN NaN NaN NaN

Even though swing_highs_lows has data, however breakOFStructure is always NaN (print(breakOFStructure .dropna()) is empty)