// Exit conditions exitLong = crossunder(close, fastMA) or (strategy.position_size > 0 and close < (1 - stopLossPct/100) * strategy.position_avg_price) or (strategy.position_size > 0 and close > (1 + takeProfitPct/100) * strategy.position_avg_price) exitShort = crossover(close, fastMA) or (strategy.position_size < 0 and close > (1 + stopLossPct/100) * strategy.position_avg_price) or (strategy.position_size < 0 and close < (1 - takeProfitPct/100) * strategy.position_avg_price)
// Execute trades if enterLong strategy.entry("Long", strategy.long)
if enterShort strategy.entry("Short", strategy.short)
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.