1

I have been trying to translate a strategy into study (for alerts), but I'm stuck with these few lines :

longStop := strategy.position_size <= 0 ? longCondition ? tempStopLong : na : longStop[1]
longProfit := strategy.position_size <= 0 ? longCondition ? tempProfitLong : na : longProfit[1]
shortStop := strategy.position_size >= 0 ? shortCondition ? tempStopShort : na : shortStop[1]
shortProfit := strategy.position_size >= 0 ? shortCondition ? tempProfitShort : na : shortProfit[1]

They are used for exiting a position. I would be really grateful if somebody could help me with that ! It's from an open source code, here is the full code if the context could help : https://www.tradingview.com/script/FUnOi1Nx-3x-SuperTrend-Strategy-Mel0nTek-V1/

Thanks !

4

1 回答 1

0

您需要两个变量,例如isLongisShort来确定您是多头还是空头。然后你可以strategy.position_size >= 0isLongstrategy.position_size <= 0替换isShort

于 2022-01-13T09:21:36.183 回答