Professional Documents
Culture Documents
Utc SC
Utc SC
// Indicator 1 Settings
keyvalue1 = input(2, title="Key Value (Indicator 1)", step=0.5)
atrperiod1 = input(1, title="ATR Period (Indicator 1)")
// Indicator 2 Settings
keyvalue2 = input(2, title="Key Value (Indicator 2)", step=0.5)
atrperiod2 = input(300, title="ATR Period (Indicator 2)")
// Indicator 1
src1 = close
xATR1 = atr(atrperiod1)
nLoss1 = keyvalue1 * xATR1
xATRTrailingStop1 = 0.0
xATRTrailingStop1 := iff(src1 > nz(xATRTrailingStop1[1], 0) and src1[1] >
nz(xATRTrailingStop1[1], 0), max(nz(xATRTrailingStop1[1]), src1 - nLoss1),
iff(src1 < nz(xATRTrailingStop1[1], 0) and src1[1] < nz(xATRTrailingStop1[1],
0), min(nz(xATRTrailingStop1[1]), src1 + nLoss1),
iff(src1 > nz(xATRTrailingStop1[1], 0), src1 - nLoss1, src1 + nLoss1)))
pos1 = 0
pos1 := iff(src1[1] < nz(xATRTrailingStop1[1], 0) and src1 >
nz(xATRTrailingStop1[1], 0), 1,
iff(src1[1] > nz(xATRTrailingStop1[1], 0) and src1 < nz(xATRTrailingStop1[1],
0), -1, nz(pos1[1], 0)))
// Indicator 2
src2 = close
xATR2 = atr(atrperiod2)
nLoss2 = keyvalue2 * xATR2
xATRTrailingStop2 = 0.0
xATRTrailingStop2 := iff(src2 > nz(xATRTrailingStop2[1], 0) and src2[1] >
nz(xATRTrailingStop2[1], 0), max(nz(xATRTrailingStop2[1]), src2 - nLoss2),
iff(src2 < nz(xATRTrailingStop2[1], 0) and src2[1] < nz(xATRTrailingStop2[1],
0), min(nz(xATRTrailingStop2[1]), src2 + nLoss2),
iff(src2 > nz(xATRTrailingStop2[1], 0), src2 - nLoss2, src2 + nLoss2)))
pos2 = 0
pos2 := iff(src2[1] < nz(xATRTrailingStop2[1], 0) and src2 >
nz(xATRTrailingStop2[1], 0), 1,
iff(src2[1] > nz(xATRTrailingStop2[1], 0) and src2 < nz(xATRTrailingStop2[1],
0), -1, nz(pos2[1], 0)))
// [SHK] STC
EEEEEE = input(80, 'Length')
BBBB = input(27, 'FastLength')
BBBBB = input(50, 'SlowLength')
// Buy Strategy
buyCondition = buy_filtered and strategy.position_size <= 0
strategy.entry("Buy", strategy.long, when=buyCondition)
strategy.exit("Sell", "Buy", stop=strategy.position_avg_price * (1 - stopLossBuy /
100), limit=strategy.position_avg_price * (1 + takeProfitBuy / 100))
// Sell Strategy
sellCondition = sell_filtered and strategy.position_size >= 0
strategy.entry("Sell", strategy.short, when=sellCondition)
strategy.exit("Cover", "Sell", stop=strategy.position_avg_price * (1 + stopLossSell
/ 100), limit=strategy.position_avg_price * (1 - takeProfitSell / 100))
// Alert conditions
alertcondition(sell_filtered, title="UT BOT Sell", message="UT BOT Sell")
alertcondition(buy_filtered, title="UT BOT Buy", message="UT BOT Buy")