lookback_natr = natr_values[start:end]
natr_pos = natr_values[pos]
median_natr = np.median(lookback_natr)
-
- natr_ratio = natr_pos / (median_natr + np.finfo(float).eps)
+ if median_natr == 0:
+ median_natr = np.finfo(float).eps
+ natr_ratio = natr_pos / median_natr
smoothed_natr_ratio = np.sqrt(natr_ratio)
depth_factor = (
return min_value
natr_min = np.min(natr_values[start:end])
natr_max = np.max(natr_values[start:end])
- normalized_natr_pos = (natr_pos - natr_min) / (
- natr_max - natr_min + np.finfo(float).eps
- )
+ natr_range = natr_max - natr_min
+ if natr_range == 0:
+ natr_range = np.finfo(float).eps
+ normalized_natr_pos = (natr_pos - natr_min) / natr_range
return min_value + (max_value - min_value) * normalized_natr_pos
INTERFACE_VERSION = 3
def version(self) -> str:
- return "3.3.36"
+ return "3.3.37"
timeframe = "5m"
else:
entry_natr_weight += weight_adjustment
current_natr_weight -= weight_adjustment
- entry_natr_weight = max(0.0, min(1.0, entry_natr_weight))
- current_natr_weight = max(0.0, min(1.0, current_natr_weight))
+ entry_natr_weight = np.clip(entry_natr_weight, 0.0, 1.0)
+ current_natr_weight = np.clip(current_natr_weight, 0.0, 1.0)
take_profit_natr = (
entry_natr_weight * entry_natr + current_natr_weight * current_natr
)
stoploss_distance = self.get_stoploss_distance(df, trade, current_rate)
if isna(stoploss_distance):
return None
- if np.isclose(stoploss_distance, 0) or stoploss_distance < 0:
+ if stoploss_distance <= 0:
return None
sign = 1 if trade.is_short else -1
return stoploss_from_absolute(
take_profit_distance = self.get_take_profit_distance(df, trade)
if isna(take_profit_distance):
return None
- if np.isclose(take_profit_distance, 0) or take_profit_distance < 0:
+ if take_profit_distance <= 0:
return None
take_profit_price = (
trade.open_rate + (-1 if trade.is_short else 1) * take_profit_distance
lookback_natr = natr_values[start:end]
natr_pos = natr_values[pos]
median_natr = np.median(lookback_natr)
-
- natr_ratio = natr_pos / (median_natr + np.finfo(float).eps)
+ if median_natr == 0:
+ median_natr = np.finfo(float).eps
+ natr_ratio = natr_pos / median_natr
smoothed_natr_ratio = np.sqrt(natr_ratio)
depth_factor = (
return min_value
natr_min = np.min(natr_values[start:end])
natr_max = np.max(natr_values[start:end])
- normalized_natr_pos = (natr_pos - natr_min) / (
- natr_max - natr_min + np.finfo(float).eps
- )
+ natr_range = natr_max - natr_min
+ if natr_range == 0:
+ natr_range = np.finfo(float).eps
+ normalized_natr_pos = (natr_pos - natr_min) / natr_range
return min_value + (max_value - min_value) * normalized_natr_pos