Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

New Microsoft Word Document

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

INICATOR 1

//@version=6

indicator('KUTOKA BLOCK', overlay = true)

// === Inputs for ATR and Take Profit Signals ===


a = input.int(3, title = 'Key Value. \'This changes the sensitivity\'')
c = input.int(10, title = 'ATR Period')
h = input.bool(false, title = 'Signals from Heikin Ashi Candles')

ShowTEX = input.bool(true, 'Enable Take Profit Signals on Chart')


rsiLengthInput = input.int(22, 'RSI Length')
rsiSourceInput = input.source(close, 'RSI Source')
maLength = input.int(14, 'MA Length for RSI Smoothing')

// === Inputs for SMMA ===


len2 = input.int(100, minval = 1, title = 'Length for SMMA')
src2 = input.source(close, title = 'Source for SMMA')
width2 = input.int(2, minval = 1, title = 'Line Width for SMMA')
transp2 = input.int(0, minval = 0, maxval = 100, title = 'Transparency for
SMMA (%)')

// === ATR and Trailing Stop Logic ===


xATR = ta.atr(c)
nLoss = a * xATR

// Heikin Ashi Calculations


var float heikinAshiOpen = na
heikinAshiClose = (open + high + low + close) / 4
heikinAshiOpen := na(heikinAshiOpen[1]) ? (open + close) / 2 :
(heikinAshiOpen[1] + heikinAshiClose[1]) / 2
heikinAshiHigh = math.max(high, math.max(heikinAshiOpen, heikinAshiClose))
heikinAshiLow = math.min(low, math.min(heikinAshiOpen, heikinAshiClose))

src = h ? heikinAshiClose : close

var float xATRTrailingStop = na


xATRTrailingStop := src > nz(xATRTrailingStop[1], 0) and src[1] >
nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src - nLoss) :
src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0) ?
math.min(nz(xATRTrailingStop[1]), src + nLoss) : src >
nz(xATRTrailingStop[1], 0) ? src - nLoss : src + nLoss

var int pos = na


pos := src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1],
0) ? 1 : src[1] > nz(xATRTrailingStop[1], 0) and src <
nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
xcolor = pos == -1 ? color.red : pos == 1 ? color.blue : color.blue

emaVal = ta.ema(src, 1)
above = ta.crossover(emaVal, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, emaVal)

buy = src > xATRTrailingStop and above


sell = src < xATRTrailingStop and below

barbuy = src > xATRTrailingStop


barsell = src < xATRTrailingStop

plotshape(buy, title = 'Buy', text = 'Buy', style = shape.labelup, location =


location.belowbar, color = color.green, textcolor = color.white, size =
size.small)
plotshape(sell, title = 'Sell', text = 'Sell', style = shape.labeldown,
location = location.abovebar, color = color.red, textcolor = color.white,
size = size.small)

barcolor(barbuy ? color.blue : na)


barcolor(barsell ? color.red : na)

alertcondition(buy, 'UT Long', 'UT Long')


alertcondition(sell, 'UT Short', 'UT Short')

// === RSI Calculation for Take Profit Labels ===


up66 = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
downw = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi66 = downw == 0 ? 100 : up66 == 0 ? 0 : 100 - 100 / (1 + up66 / downw)
rsiMA = ta.sma(rsi66, maLength)

// === Long Signals for Take Profit Labels ===


long1 = ta.crossover(rsi66, 30)
long2 = ta.crossover(rsi66, 20)
long3 = ta.crossover(rsi66, 15)

// === Short Signals for Take Profit Labels ===


short1 = ta.crossunder(rsi66, 70)
short2 = ta.crossunder(rsi66, 80)
short3 = ta.crossunder(rsi66, 85)

// === Plot TP Labels on Chart ===


plotshape(long1 and ShowTEX, title = 'TP 1', location = location.belowbar,
style = shape.diamond, size = size.tiny, color = color.lime, text = 'TP')
plotshape(long2 and ShowTEX, title = 'TP 2', location = location.belowbar,
style = shape.diamond, size = size.tiny, color = color.red, text = 'TP')
plotshape(long3 and ShowTEX, title = 'TP 3', location = location.belowbar,
style = shape.diamond, size = size.tiny, color = color.yellow, text = 'TP')
plotshape(short1 and ShowTEX, title = 'TP 1', location = location.abovebar,
style = shape.diamond, size = size.tiny, color = color.lime, text = 'TP')
plotshape(short2 and ShowTEX, title = 'TP 2', location = location.abovebar,
style = shape.diamond, size = size.tiny, color = color.red, text = 'TP')
plotshape(short3 and ShowTEX, title = 'TP 3', location = location.abovebar,
style = shape.diamond, size = size.tiny, color = color.yellow, text = 'TP')

// === Alerts for Take Profit Levels ===


alertcondition(long1 or short1, 'TP 1', 'Take Profit 1 Signal')
alertcondition(long2 or short2, 'TP 2', 'Take Profit 2 Signal')
alertcondition(long3 or short3, 'TP 3', 'Take Profit 3 Signal')

// === Optional Plotting for Debugging ===


plot(rsi66, title = 'RSI', color = color.new(color.blue, 0), linewidth = 2)
hline(70, 'Overbought', color = color.red)
hline(30, 'Oversold', color = color.blue)

// === SMMA Calculation and Plot ==


var float smma2 = na
smma2 := na(smma2[1]) ? ta.sma(src2, len2) : (smma2[1] * (len2 - 1) + src2) /
len2

// Color Logic for Bullish/Bearish


color_bullish = color.new(color.blue, transp2) // Color for bullish movement
color_bearish = color.new(color.red, transp2) // Color for bearish movement
current_color = smma2 > smma2[1] ? color_bullish : color_bearish // Check
trend
// Plot SMMA with Trend-Based Color
plot(smma2, color = current_color, linewidth = math.max(1, width2)

Rules to be added
1.THE buy signal should only be when price is above the smma
else it should apper at the crossing over with a diffent color from the other buy indicating a weak
signal…this should also be applied inversely for the sell signal

add this logic and give the script as document……..without any elimination of the current things in the
script

You might also like