I try to put 1 por trading strategy when rsi if > 30 and 0 if the previous period if < 30
data['rsi_compra'] = 1 if data.rsi > 30 & data.rsi.shift(periods = 1) < 30 else 0
Raise this error
Cannot perform 'rand_' with a dtyped [float64] array and scalar of type [bool]
Try this:
you should keep in mind yu are working with pandas series and not a scalar value , while & operand applies to a single item in that series & using parenthesis is necessary for that purpose.