请问各位大佬,tradingview的alert_message改如何对接FMZ

Author: q631207207, Created: 2022-05-16 21:10:12, Updated: 2022-05-16 21:11:40

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%”)

这是我TV的分批止盈策略,请问该怎么搭建机器人对接?社区的那个直连教程 好像并没有针对这个警报的设置和分批止盈

More

发明者量化 只有exit没有entry啊怎么开的仓. 另外发明者可以直接创建pine创建把策略直接拿过来看看能跑通不能

q631207207 搬过,没法用,因为有些东西转不过来,现在我的问题就是,我的策略应该怎么接FMZ的机器人,社区的那个机器人代码好像没有分批的

发明者量化 ``` 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%") ``` 直接复制这个应该没问题 你的最后几行缩进也不对给你改了

发明者量化 alertfg没定义啊,少了这个变量

q631207207 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 ///////////////////////////////////////////////////////开仓逻辑 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%") 这是我的止盈止损,直接搬过来跑不通,