timuko / FlowerPowerX

0 stars 0 forks source link

Lookahead not "neutralised" #1

Open froggleston opened 7 months ago

froggleston commented 7 months ago

Experimental or not, this strategy still exhibits lookahead bias. This doesn't fix the underlying issue of shifting negatively to allow you to see future candles from the current candle: https://github.com/timuko/FlowerPowerX/commit/2e63686d04ce1fa5692d4c2620af8bd7747ab358

def find_pivot_highs(dataframe, leftbars, rightbars):
    """Find pivot highs in the dataframe."""
    highs = dataframe['high'].shift(rightbars)
    pivot_highs = highs[(highs.shift(leftbars) < highs) & (highs.shift(-rightbars) < highs)]
    return pivot_highs

This is solved by using only current data:

def find_pivot_highs(dataframe, leftbars):
    """Find pivot highs in the dataframe."""
    highs = dataframe['high']
    pivot_highs = highs[(highs.shift(leftbars) < highs) & (highs.shift() < highs)]
    return pivot_highs

However, you'll see that your pivots will lag, and you won't see the currently unrealistic profits from your published backtests.

enrick0 commented 7 months ago

@froggleston it certainly needs to be rewritten, but I don't see a bias, it shifts into the past and then shifts into the future +x-x=0, I don't know if I'm wrong, but it doesn't seem to read into the future.

I'm running a dry run test and it seems to be promising, in case of bias should there be a difference between dry_run and backtesting?

timuko commented 7 months ago

@enrick0 My observation is with busy strats its always a bit different. while i run the dry or live run i backtest the time range of the current run from time to time to compare. At this time it seems that the win rate is in the range of the backtest. In "Live Run" the losses are slightly less then in backtesting. The profit is less but the exit strategy has a lot of room for more sophisticated implementations. The strat needs a lot of pairs (i do 50 pairs) so that looser will be replaced quicker due to the 4% SL it also benefits form stoploss_on_exchange True some shitty coins fall very fast when they hit the SL.

timuko commented 7 months ago

@froggleston it certainly needs to be rewritten, but I don't see a bias, it shifts into the past and then shifts into the future +x-x=0, I don't know if I'm wrong, but it doesn't seem to read into the future.

I'm running a dry run test and it seems to be promising, in case of bias should there be a difference between dry_run and backtesting?

@enrick0 lets connect on discord to share our findings find me in the freqtrade discord machete8303