I am trying to setup alerts for TradingView with my strategy to use on a trading bot.
I want to add alerts for:
- Buying Long
- Closing Long
- Buying Short
- Closing Short
when I try adding alerts I don't get the buy/sell conditions in the "Add Alerts" window.
This is my code:
//@version=5
strategy('ChatGPT Algo Bitcoin', overlay=true)
// Input parameters
len = input.int(14, title='SSL Channel Length', minval=1)
src = close
emaLength = input.int(130, title='EMA Length', minval=1)
atrLength = input.int(14, title='ATR Length', minval=1)
slMultiplier = input(2.0, title='SL Multiplier')
tpMultiplier = input(4.0, title='TP Multiplier')
thresholdHigh = input(0.8, title='High Volume Threshold')
thresholdMedium = input(0.8, title='Medium Volume Threshold')
volumeLength = input(750, title='Volume MA Length')
// Calculate SSL Channel
smaHigh = ta.sma(high, len)
smaLow = ta.sma(low, len)
var float Hlv = na
Hlv := src > smaHigh ? 1 : src < smaLow ? -1 : nz(Hlv[1])
sslDown = Hlv < 0 ? smaHigh : smaLow
sslUp = Hlv < 0 ? smaLow : smaHigh
// Calculate 200 EMA
ema200 = ta.ema(src, emaLength)
// Calculate ATR
atr = ta.atr(atrLength)
// Calculate Heatmap Volume
volumeMean = ta.sma(volume, volumeLength)
volumeStd = ta.stdev(volume, volumeLength)
stdBar = (volume - volumeMean) / volumeStd
// Define Volume Filter
volumeFilter = stdBar > thresholdMedium or stdBar > thresholdHigh
// Define Buy and Sell conditions
bullishCross = ta.crossover(sslUp, sslDown) and src < ema200 and volumeFilter
bearishCross = ta.crossunder(sslUp, sslDown) and src > ema200 and volumeFilter
buyCondition = bullishCross
sellCondition = bearishCross
// Set SL and TP levels
longStopLoss = src - atr * slMultiplier
longTakeProfit = src + atr * tpMultiplier
shortStopLoss = src + atr * slMultiplier
shortTakeProfit = src - atr * tpMultiplier
// Implement strategy.entry functions with SL and TP
strategy.entry('Buy', strategy.long, when=buyCondition, stop=longStopLoss, limit=longTakeProfit)
strategy.entry('Sell', strategy.short, when=sellCondition, stop=shortStopLoss, limit=shortTakeProfit)
// Plot SSL Channel and 200 EMA
plot(sslDown, title='SSL Down', linewidth=2, color=color.new(color.red, 0))
plot(sslUp, title='SSL Up', linewidth=2, color=color.new(color.lime, 0))
plot(ema200, title='200 EMA', color=color.new(color.orange, 0), linewidth=2)
// Plot long and short signals
plotshape(buyCondition, title='Buy', style=shape.labelup, location=location.belowbar, size=size.normal, text='Buy', textcolor=color.new(color.white, 0), color=color.new(color.green, 0))
plotshape(sellCondition, title='Sell', style=shape.labeldown, location=location.abovebar, size=size.normal, text='Sell', textcolor=color.new(color.white, 0), color=color.new(color.red, 0))
Any advice will be helpful, it's my first time attempting to setup a trading bot. Thanks in advance