attempt fix for lookahead bias
This commit is contained in:
parent
6916722a43
commit
b013183f67
@ -123,12 +123,12 @@ class DefaultStrategy(StrategyBase):
|
|||||||
if not self.initialized:
|
if not self.initialized:
|
||||||
return StrategySignal("HOLD", 0.0)
|
return StrategySignal("HOLD", 0.0)
|
||||||
|
|
||||||
if df_index < 1:
|
if df_index < 2: # shifting one index to prevent lookahead bias
|
||||||
return StrategySignal("HOLD", 0.0)
|
return StrategySignal("HOLD", 0.0)
|
||||||
|
|
||||||
# Check for meta-trend entry condition
|
# Check for meta-trend entry condition
|
||||||
prev_trend = backtester.strategies["meta_trend"][df_index - 1]
|
prev_trend = backtester.strategies["meta_trend"][df_index - 2]
|
||||||
curr_trend = backtester.strategies["meta_trend"][df_index]
|
curr_trend = backtester.strategies["meta_trend"][df_index - 1]
|
||||||
|
|
||||||
if prev_trend != 1 and curr_trend == 1:
|
if prev_trend != 1 and curr_trend == 1:
|
||||||
# Strong confidence when all indicators align for entry
|
# Strong confidence when all indicators align for entry
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user