发明者量化
```
tp1Open = input.bool(true, "TP1", group = "Take Profits")
tp1 = input.float(2.0, "TP Level (%)", step = 0.1, group = "Take Profits") / 100
tp1Amount = input.int(30, "Amount (%)", step = 1, group = "Take Profits")
tp2Open = input.bool(true, "TP2", group = "Take Profits")
tp2 = input.float(2.5, "TP Level (%)", step = 0.1, group = "Take Profits") / 100
tp2Amount = input.int(71, "Amount (%)", step = 1, group = "Take Profits")
tp3Open = input.bool(true, "TP3", group = "Take Profits")
tp3 = input.float(3.0, "TP Level (%)", step = 0.1, group = "Take Profits") / 100
tp3Amount = input.int(100, "Amount (%)", step = 1, group = "Take Profits")
st5=input.float(1.3, "止损", step = 0.1, group = "Take Profits") / 100
alertfg = input(true)
///////////////////////////////////////////////////////开仓逻辑
longCondition = alertfg and close>close[1]
if (longCondition)
strategy.entry("long", strategy.long, comment='做多',alert_message="做多")
longsl=alertfg and close<close[1]
strategy.close ("long",when=low <strategy.position_avg_price * (1 - st5) or longsl , comment='多损',alert_message="多头止损")
shortCondition = alertfg and close<close[1] //and close<ta.ema(close,ema)
if (shortCondition)
strategy.entry("short", strategy.short, comment='做空',alert_message="做空")
shortsl=alertfg and close>close[1]
strategy.close ("short", when=high > strategy.position_avg_price * (1 + st5) or shortsl ,comment='空损',alert_message="空头止损")
//平仓逻辑
if tp1Open
strategy.exit ("long1", when=strategy.position_size > 0, limit=strategy.position_avg_price * (1 + tp1), qty_percent=tp1Amount,comment='多平1',alert_message="平多30%")
strategy.exit ("short1", when=strategy.position_size < 0, limit=strategy.position_avg_price * (1 - tp1), qty_percent=tp1Amount,comment='空平1',alert_message="平空30%")
if tp2Open
strategy.exit ("long2", when=strategy.position_size > 0, limit=strategy.position_avg_price * (1 + tp2), qty_percent=tp2Amount,comment='多平2',alert_message="平多50%")
strategy.exit ("short2", when=strategy.position_size < 0, limit=strategy.position_avg_price * (1 - tp2), qty_percent=tp2Amount,comment='空平2',alert_message="平空50%")
if tp3Open
strategy.exit ("long3", when=strategy.position_size > 0, limit=strategy.position_avg_price * (1 + tp3), qty_percent=tp3Amount,comment='多平3',alert_message="平多100%")
strategy.exit ("short3", when=strategy.position_size < 0, limit=strategy.position_avg_price * (1 - tp3), qty_percent=tp3Amount,comment='空平3',alert_message="平空100%")
```
直接复制这个应该没问题 你的最后几行缩进也不对给你改了
2022-05-16 21:40:21