// 4. 买入条件:趋势向上 + 相对强度强 + 成交量放大 buyCondition = trendUp and rsValid and volumeSpike
// 5. 卖出条件:趋势向下或触发止盈止损 var float entryPrice = na var bool positionActive = false if buyCondition and not positionActive entryPrice := close positionActive := true
takeProfitLevel = entryPrice * (1 + profitTargetPct) stopLossLevel = entryPrice * (1 - stopLossMultiplier * atr / entryPrice) sellCondition = positionActive and (trendDown or close >= takeProfitLevel or close <= stopLossLevel)