PROTECTED SOURCE SCRIPT

Gope-All In One - v1.0

25
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
// © mmxgu2
// With help of(financegalaxie.fr/les-indicateurs-en-analyse-technique-dynamique://www.financegalaxie.fr/cest-quoi-analyse-technique-dynamique/
//version=5
indicator(title='Gope-All In One - v1.0', overlay=true)
// based upon ATD strategy
// financegalaxie.fr/les-indicateurs-en-analyse-technique-dynamique/
// financegalaxie.fr/cest-quoi-analyse-technique-dynamique/
// SAR code provided by Chris Moody with adaptations
// version 1.0

fastPer = input.int(7, minval=1, title='Fast MM')
slowPer = input.int(20, minval=1, title='Slow MM')

start = input.int(2, minval=0, maxval=10, title='Start - Default = 2 - Multiplied by .01')
increment = input.int(2, minval=0, maxval=10, title='Step Setting (Sensitivity) - Default = 2 - Multiplied by .01')
maximum = input.int(2, minval=1, maxval=10, title='Maximum Step (Sensitivity) - Default = 2 - Multiplied by .10')

bbLength = input.int(20, minval=1)
bbDev = input.float(2.0, minval=0.1, maxval=50)

basis = ta.sma(close, bbLength)
dev1 = bbDev * ta.stdev(close, bbLength)
bbh = basis + dev1
bbl = basis - dev1
plot(bbh, color=ta.rising(bbh, 2) ? color.green : color.red)
plot(bbl, color=ta.rising(bbl, 2) ? color.green : color.red)

startCalc = start * .01
incrementCalc = increment * .01
maximumCalc = maximum * .10

sarUp = ta.sar(startCalc, incrementCalc, maximumCalc)
sarDown = ta.sar(startCalc, incrementCalc, maximumCalc)

colUp = close >= sarDown ? color.green : na
colDown = close <= sarUp ? color.red : na


fastMM = ta.sma(close, fastPer)
slowMM = ta.sma(close, slowPer)

ma1 = plot(fastMM, color=ta.rising(fastMM, 2) ? color.green : color.red, linewidth=2, title='Fast MM', transp=20)
ma2 = plot(slowMM, color=ta.rising(slowMM, 2) ? color.green : color.red, linewidth=2, title='Slow MM', transp=20)
plot(sarUp, title='Up Trending SAR', style=plot.style_circles, linewidth=2, color=colUp)
plot(sarDown, title='Up Trending SAR', style=plot.style_circles, linewidth=2, color=colDown)

fcolor = fastMM > slowMM ? color.green : color.red
fill(ma1, ma2, color=color.new(fcolor,80))

// === INPUTS ===
rsiLen = input.int(14, title="RSI Length")
showBuySell = input.bool(true, title="Show Buy/Sell Signals")
showReverseSignals = input.bool(true, title="Show Reverse Signals")

// === RSI CALCULATIONS ===
rsiVal = ta.rsi(close, rsiLen) // Current timeframe RSI
rsiValD = request.security(syminfo.tickerid, "D", ta.rsi(close, rsiLen)) // Daily RSI

// === RSI LADDER LEVELS ===
var int[] ladderLevels = array.new_int()
if bar_index == 0
array.push(ladderLevels, 0)
array.push(ladderLevels, 10)
array.push(ladderLevels, 30)
array.push(ladderLevels, 50)
array.push(ladderLevels, 70)
array.push(ladderLevels, 90)
array.push(ladderLevels, 100)

// === Price range for mapping RSI to price scale (last 50 bars) ===
priceMin = ta.lowest(low, 50)
priceMax = ta.highest(high, 50)

// === Mapping Function ===
rsiToPrice(rsi) =>
priceMin + (rsi / 100) * (priceMax - priceMin)

// === PLOT MAPPED CURRENT RSI (invisible by default) ===
plot(rsiToPrice(rsiVal), title="RSI (mapped)", color=color.new(color.white, 100), linewidth=1)

// === DEFINE COLORS FOR LADDER ===
getColor(level) =>
color result = color.gray
if level == 0 or level == 100 or level == 20 or level == 80
result := color.red
else if level == 10 or level == 30 or level == 70 or level == 90
result := color.blue
else if level == 50
result := color.white
result

// === DRAW RSI LADDER (Current TF and Daily TF) ===
var line[] linesCurrent = array.new_line()
var line[] linesDaily = array.new_line()
var label[] labelsCurrent = array.new_label()
var label[] labelsDaily = array.new_label()

if barstate.islast
// === CLEAN UP OLD LINES & LABELS ===
for l in linesCurrent
line.delete(l)
for l in linesDaily
line.delete(l)
for lbl in labelsCurrent
label.delete(lbl)
for lbl in labelsDaily
label.delete(lbl)
array.clear(linesCurrent)
array.clear(linesDaily)
array.clear(labelsCurrent)
array.clear(labelsDaily)

x1 = bar_index - 50
x2 = bar_index

for i = 0 to array.size(ladderLevels) - 1
lvl = array.get(ladderLevels, i)

// === Current TF RSI Ladder Line ===
priceLevel = rsiToPrice(lvl)
lineColor = getColor(lvl)
ln = line.new(x1, priceLevel, x2, priceLevel, color=lineColor, width=(lvl==50 ? 2 : 1), style=line.style_dashed)
array.push(linesCurrent, ln)

lbl = label.new(bar_index + 5, priceLevel, str.tostring(lvl), color=color.new(lineColor, 100), style=label.style_label_right, textcolor=color.new(color.white,100), size=size.large)
array.push(labelsCurrent, lbl)

// === Daily RSI Mapped Ladder Line ===
mappedPriceD = rsiToPrice(lvl)
lnD = line.new(x1, mappedPriceD, x2, mappedPriceD, color=color.new(lineColor, 0), width=2, style=line.style_solid)
array.push(linesDaily, lnD)

lblD = label.new(bar_index + 8, mappedPriceD, "D:" + str.tostring(lvl), color=color.new(lineColor, 90), style=label.style_label_left, textcolor=color.white, size=size.normal)
array.push(labelsDaily, lblD)

// === BUY / SELL LOGIC ===
// Normal signals
buySignalb = ta.crossover(fastMM,basis)
sellSignalb = ta.crossunder(fastMM,basis)

// Reverse signals
revBuySignalb = ta.crossunder(rsiVal, 30)
revSellSignalb = ta.crossover(rsiVal, 70)

// === PLOT SIGNALS ON CHART ===
plotshape(showBuySell and buySignalb, title="Buy Signal", location=location.belowbar, color=color.lime,size = size.tiny, style=shape.triangleup, text="Buy", textcolor=color.white)
plotshape(showBuySell and sellSignalb, title="Sell Signal", location=location.abovebar, color=color.red,size = size.tiny, style=shape.triangledown, text="Sell", textcolor=color.white)

plotshape(showReverseSignals and revBuySignalb, title="Rev BUY", location=location.belowbar, color=color.new(color.blue, 0),size = size.tiny, style=shape.triangleup, text="R+", textcolor=color.white)
plotshape(showReverseSignals and revSellSignalb, title="Rev SELL", location=location.abovebar, color=color.new(color.orange, 0), size = size.tiny,style=shape.triangledown, text="R-", textcolor=color.white)

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.