所有的金字塔交易同时结束



我有基于进入时刻值的TP和SL。我打开了金字塔期权,但随后,所有在特定时间开盘的交易(方向相同:多头或空头(都在同一时刻收盘。如何使每一笔交易独立,以及如何使每笔交易在进入TP或SL时在一个集合上关闭。

Ps。TP=2,SL=1

Ps 2。Pine脚本版本5

类似的问题在这里:金字塔交易与独立获利(Pinescript(

我的做多交易代码:

ATR = ta.atr(14)
if EntryLongCondiction1 and EntryLongCondiction2
strategy.entry("Long", strategy.long)
lastLongEntryPrice = strategy.opentrades.entry_price(strategy.opentrades - 1)
var float LongProfit = na
var float LongStop = na
if (strategy.position_size[1] != strategy.position_size)
LongProfit := lastLongEntryPrice + (ATR * 2)
LongStop := lastLongEntryPrice - (ATR * 1)
strategy.exit("Long", stop=LongStop, limit=LongProfit)

因为"Long"中所有的入口和出口条件都是相同的名称,所以入口可能不在同一个位置,但出口会。将以"Long"顺序命中并触发所有名称的退出条件。如果你有一个不同的条件或固定的tp/sl比率,试着把它命名为Long 1Long2等。

最新更新