AlertaScript / 文件
流程控制
條件與有限次重複。
運作方式
if 選擇分支,三元運算式選擇數值。條件以目前 K 棒的情境評估。
實際應用
一致計算需要重用的序列,再套用條件。限制迴圈次數,避免集合隨 K 棒無限增長。
程式範例
AlertaScript
indicator("Bar direction", overlay=false)direction = close > open ? 1 : close < open ? -1 : 0plot(direction, "Direction", style=plot.style_histogram)