명시
Dear Coders,
I need you to code an EA based off the following script :
//"UT Bot Alerts"
// Inputs
a = 1 //input(1, title='Key Vaule. \'This changes the sensitivity\'',group = "ut bot alert")
c = 10 //input(10, title='ATR Period',group = "ut bot alert")
h = false //input(false, title='Signals from Heikin Ashi Candles',group = "ut bot alert")
xATR = ta.atr(c)
nLoss = a * xATR
src = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close, lookahead=barmerge.lookahead_off) : close
xATRTrailingStop = 0.0
iff_1 = src > nz(xATRTrailingStop[1], 0) ? src - nLoss : src + nLoss
iff_2 = src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), src + nLoss) : iff_1
xATRTrailingStop := src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src - nLoss) : iff_2
pos = 0
iff_3 = src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
pos := src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0) ? 1 : iff_3
xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue
ema = ta.ema(src, 1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)
buy = src > xATRTrailingStop and above and close > signal
sell = src < xATRTrailingStop and below and close < signal
barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop
plotshape(buy, title='Buy', text='Buy', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), size=size.tiny)
plotshape(sell, title='Sell', text='Sell', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny)
barcolor(barbuy ? color.green : na)
barcolor(barsell ? color.red : na)
alertcondition(buy, 'UT Long', 'UT Long')
alertcondition(sell, 'UT Short', 'UT Short')
///tpsl
pivlen = input.int(defval = 3,title = "Swing points period",group = "strategy settings")
pivhi = ta.pivothigh(pivlen,pivlen)
// plot(pivhi)
pivlo = ta.pivotlow(pivlen,pivlen)
pivlobar = ta.valuewhen(pivlo,bar_index,0)
pivloclose = math.min(ta.lowest(low,3),ta.valuewhen(pivlo,low[pivlen],0))
buyclose = ta.valuewhen(buy,close,0)
buybar = ta.valuewhen(buy,bar_index,0)
pivloofbuy = ta.valuewhen(buy,pivloclose,0)
tp_lg = buyclose + (buyclose - pivloofbuy)*2
// plot(pivloofbuy,style = plot.style_stepline,color = color.green)
// plot(tp_lg,style = plot.style_stepline,color = color.green)
pivhibar = ta.valuewhen(pivhi,bar_index,0)
pivhiclose = math.max(ta.highest(high,3),ta.valuewhen(pivhi,high[pivlen],0))
// plot(pivhiclose)
sellclose = ta.valuewhen(sell,close,0)
sellbar = ta.valuewhen(sell,bar_index,0)
pivhiofsell = ta.valuewhen(sell,pivhiclose,0) //math.max(ta.highest(high,9),
tp_sh = sellclose - (pivhiofsell - sellclose)*2
The job involves :
Placing a buy order when buy signal comes and a sell order when sell signal comes.
The SL TP will be according to the exact levels specified in the codes.
if you have time and willing to start now, please let me know