I want to exit with 10% profit target or 10% stop-loss is the condition for pattern is valid in the code below:
def initialize(context):
context.stock=sid(8554)
def handle_data(context, data):
closev = {}
closev = history(6, "1d", "close_price")
if (closev.iloc[-2][context.stock] > closev.iloc[-1][context.stock] and closev.iloc[-3][context.stock] > closev.iloc[-4][context.stock] and closev.iloc[-1][context.stock] > closev.iloc[-3][context.stock] and closev.iloc[-5][context.stock] > closev.iloc[-6][context.stock] and closev.iloc[-4][context.stock] > closev.iloc[-5][context.stock] ):
order_target_percent(context.stock, 1)
entry = data[context.stock].close_price
order_target_percent(context.stock, -1.0, limit_price = entry * 1.1, stop_price = entry * 0.90)
But I get no backtest results although there should be trades.