Add check if trigger is in parameters
This commit is contained in:
parent
5e08769366
commit
798ae460d8
@ -98,12 +98,13 @@ So let's write the buy strategy using these values:
|
|||||||
conditions.append(dataframe['rsi'] < params['rsi-value'])
|
conditions.append(dataframe['rsi'] < params['rsi-value'])
|
||||||
|
|
||||||
# TRIGGERS
|
# TRIGGERS
|
||||||
if params['trigger'] == 'bb_lower':
|
if 'trigger' in params:
|
||||||
conditions.append(dataframe['close'] < dataframe['bb_lowerband'])
|
if params['trigger'] == 'bb_lower':
|
||||||
if params['trigger'] == 'macd_cross_signal':
|
conditions.append(dataframe['close'] < dataframe['bb_lowerband'])
|
||||||
conditions.append(qtpylib.crossed_above(
|
if params['trigger'] == 'macd_cross_signal':
|
||||||
dataframe['macd'], dataframe['macdsignal']
|
conditions.append(qtpylib.crossed_above(
|
||||||
))
|
dataframe['macd'], dataframe['macdsignal']
|
||||||
|
))
|
||||||
|
|
||||||
dataframe.loc[
|
dataframe.loc[
|
||||||
reduce(lambda x, y: x & y, conditions),
|
reduce(lambda x, y: x & y, conditions),
|
||||||
|
@ -57,16 +57,17 @@ class DefaultHyperOpts(IHyperOpt):
|
|||||||
conditions.append(dataframe['rsi'] < params['rsi-value'])
|
conditions.append(dataframe['rsi'] < params['rsi-value'])
|
||||||
|
|
||||||
# TRIGGERS
|
# TRIGGERS
|
||||||
if params['trigger'] == 'bb_lower':
|
if 'trigger' in params:
|
||||||
conditions.append(dataframe['close'] < dataframe['bb_lowerband'])
|
if params['trigger'] == 'bb_lower':
|
||||||
if params['trigger'] == 'macd_cross_signal':
|
conditions.append(dataframe['close'] < dataframe['bb_lowerband'])
|
||||||
conditions.append(qtpylib.crossed_above(
|
if params['trigger'] == 'macd_cross_signal':
|
||||||
dataframe['macd'], dataframe['macdsignal']
|
conditions.append(qtpylib.crossed_above(
|
||||||
))
|
dataframe['macd'], dataframe['macdsignal']
|
||||||
if params['trigger'] == 'sar_reversal':
|
))
|
||||||
conditions.append(qtpylib.crossed_above(
|
if params['trigger'] == 'sar_reversal':
|
||||||
dataframe['close'], dataframe['sar']
|
conditions.append(qtpylib.crossed_above(
|
||||||
))
|
dataframe['close'], dataframe['sar']
|
||||||
|
))
|
||||||
|
|
||||||
dataframe.loc[
|
dataframe.loc[
|
||||||
reduce(lambda x, y: x & y, conditions),
|
reduce(lambda x, y: x & y, conditions),
|
||||||
|
@ -66,16 +66,17 @@ class SampleHyperOpts(IHyperOpt):
|
|||||||
conditions.append(dataframe['rsi'] < params['rsi-value'])
|
conditions.append(dataframe['rsi'] < params['rsi-value'])
|
||||||
|
|
||||||
# TRIGGERS
|
# TRIGGERS
|
||||||
if params['trigger'] == 'bb_lower':
|
if 'trigger' in params:
|
||||||
conditions.append(dataframe['close'] < dataframe['bb_lowerband'])
|
if params['trigger'] == 'bb_lower':
|
||||||
if params['trigger'] == 'macd_cross_signal':
|
conditions.append(dataframe['close'] < dataframe['bb_lowerband'])
|
||||||
conditions.append(qtpylib.crossed_above(
|
if params['trigger'] == 'macd_cross_signal':
|
||||||
dataframe['macd'], dataframe['macdsignal']
|
conditions.append(qtpylib.crossed_above(
|
||||||
))
|
dataframe['macd'], dataframe['macdsignal']
|
||||||
if params['trigger'] == 'sar_reversal':
|
))
|
||||||
conditions.append(qtpylib.crossed_above(
|
if params['trigger'] == 'sar_reversal':
|
||||||
dataframe['close'], dataframe['sar']
|
conditions.append(qtpylib.crossed_above(
|
||||||
))
|
dataframe['close'], dataframe['sar']
|
||||||
|
))
|
||||||
|
|
||||||
dataframe.loc[
|
dataframe.loc[
|
||||||
reduce(lambda x, y: x & y, conditions),
|
reduce(lambda x, y: x & y, conditions),
|
||||||
|
Loading…
Reference in New Issue
Block a user