仅当 PnL 为正时金字塔

Pyramiding only when PnL is positive

快速提问。关于 pine strategies 中的金字塔订单,我希望只有当当前 PnL 为正时,才能让第二个和后续订单通过。松树有解决方法吗?我想不出任何主意。我不需要确切的代码,请指出正确的方向。

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © adolgov

//@version=4
strategy("My Strategy", overlay=true, pyramiding = 10)

longCondition = crossover(sma(close, 14), sma(close, 28))
if strategy.position_size > 0 and  strategy.openprofit < 0 and longCondition
    longCondition := false
if (longCondition)
    strategy.entry("My Long Entry Id", strategy.long)

shortCondition = crossunder(sma(close, 14), sma(close, 28))
if strategy.position_size > 0 and  strategy.openprofit < 0 and shortCondition
    shortCondition := false
if (shortCondition)
    strategy.entry("My Short Entry Id", strategy.short)