0% found this document useful (0 votes)
14 views3 pages

Gold Ok

The document is a Pine Script code for a trading indicator titled 'RLD TRADING 10-10', which incorporates RSI and MACD calculations to identify potential buy and sell signals based on divergence. It includes functions to find tops and bottoms in both RSI and MACD, as well as visual labels for these signals on the trading chart. Additionally, it implements alert conditions for trend changes and provides a Supertrend indicator for trend direction visualization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

Gold Ok

The document is a Pine Script code for a trading indicator titled 'RLD TRADING 10-10', which incorporates RSI and MACD calculations to identify potential buy and sell signals based on divergence. It includes functions to find tops and bottoms in both RSI and MACD, as well as visual labels for these signals on the trading chart. Additionally, it implements alert conditions for trend changes and provides a Supertrend indicator for trend direction visualization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

//@version=5indicator(title='RLD TRADING 10-10', max_bars_back=2000, overlay=true)

rsiLengthInput = input.int(14, minval=1, title="RSI Length",group="RSI")


fastlinelen=input.int(12,title="Fast line Length",group="MACD")
slowlinelen=input.int(26,title="Slow line Length",group="MACD")
smoothlinelen=input.int(9,title="Smooth line Length",group="MACD")//-----------
//rsi function//-----------//A small amount of smoothing to reduce false divergence
hintsrsi = ta.ema(ta.rsi(close, rsiLengthInput), 2)findRSITopBl(len) => top =
ta.pivothigh(rsi, len, len) topc = 0 topc := top ? len : nz(topc[1]) + 1
newtop = ta.pivothigh(rsi, len, 0) topBL_z = newtop[1] and not newtop and
high[1] > high[topc] and rsi[1] < rsi[topc] and rsi[topc] > 60 topBL_h =
newtop[1] and not newtop and high[1] < high[topc] and rsi[1] > rsi[topc] and
rsi[topc] > 60 BLTopc = 0 if topBL_z or topBL_h BLTopc := topc
BLTopcfindRSIBotBl(len) => bot = ta.pivotlow(rsi, len, len) botc = 0
botc := bot ? len : nz(botc[1]) + 1 newbot = ta.pivotlow(rsi, len, 0) BotBL_z
= newbot[1] and not newbot and low[1] < low[botc] and rsi[1] > rsi[botc] BotBL_h
= newbot[1] and not newbot and low[1] > low[botc] and rsi[1] < rsi[botc] BLBotc
= 0 if BotBL_z or BotBL_h BLBotc := botc BLBotct5result =
findRSITopBl(5)t10result = findRSITopBl(10)t20result = findRSITopBl(20)b5result =
findRSIBotBl(5)b10result = findRSIBotBl(10)b20result = findRSIBotBl(20)//K not end
informationstring notend = ''if timenow < time_close notend := '\nk not end'//
var rsitoplabels = array.new_label()var rsibotlabels = array.new_label()var
macdtoplabels = array.new_label()var macdbotlabels = array.new_label()if t5result
array.push(rsitoplabels,label.new(x=bar_index, y=high, yloc=yloc.abovebar, text='r'
+ notend, textcolor=#ffffff, color=color.new(color.red, 40), size=size.tiny,
style=label.style_label_down))if t10result
array.push(rsitoplabels,label.new(x=bar_index, y=high, yloc=yloc.abovebar, text='r'
+ notend, textcolor=#ffffff, color=color.new(color.red, 40), size=size.tiny,
style=label.style_label_down))if t20result
array.push(rsitoplabels,label.new(x=bar_index, y=high, yloc=yloc.abovebar, text='r'
+ notend, textcolor=#ffffff, color=color.new(color.red, 40), size=size.tiny,
style=label.style_label_down))if b5result
array.push(rsibotlabels,label.new(x=bar_index, y=low, yloc=yloc.belowbar, text='r'
+ notend, textcolor=#ffffff, color=color.new(color.green, 40), size=size.tiny,
style=label.style_label_up))if b10result
array.push(rsibotlabels,label.new(x=bar_index, y=low, yloc=yloc.belowbar, text='r'
+ notend, textcolor=#ffffff, color=color.new(color.green, 40), size=size.tiny,
style=label.style_label_up))if b20result
array.push(rsibotlabels,label.new(x=bar_index, y=low, yloc=yloc.belowbar, text='r'
+ notend, textcolor=#ffffff, color=color.new(color.green, 40), size=size.tiny,
style=label.style_label_up))//recolor previous error divergence labelsif
array.size(rsitoplabels)>=1 for i=0 to array.size(rsitoplabels)-1
templabel=array.get(rsitoplabels,i) x1=label.get_x(templabel) if
bar_index-x1-1<4 and rsi>rsi[bar_index-x1+1]
label.set_color(templabel,color.new(color.gray,90))
label.set_textcolor(templabel,color.gray)if array.size(rsibotlabels)>=1 for i=0
to array.size(rsibotlabels)-1 templabel=array.get(rsibotlabels,i)
x1=label.get_x(templabel) if bar_index-x1-1<4 and rsi<rsi[bar_index-x1+1]
label.set_color(templabel,color.new(color.gray,90))
label.set_textcolor(templabel,color.gray)//-----------//macd function//-----------
diff = ta.ema(close, fastlinelen) - ta.ema(close, slowlinelen)dea = ta.ema(diff,
smoothlinelen)macd = (diff - dea) * 2findMACDTopBl(len)=> src=diff top=
ta.pivothigh(src,len, len) topc = 0 topc := top ? len : nz(topc[1]) + 1
newtop=ta.pivothigh(src,len,0) topBL_z=newtop[1] and not newtop and
high[1]>high[topc] and src[1]<src[topc] and diff[topc]>dea[topc] and src[topc]>0
topBL_h=newtop[1] and not newtop and high[1]<high[topc] and src[1]>src[topc] and
diff[topc]>dea[topc] and src[topc]>0 BLTopc=0 if topBL_z or topBL_h
BLTopc:=topc BLTopcfindMACDBotBl(len)=> src=diff bot= ta.pivotlow(src,len,
len) botc = 0 botc := bot ? len : nz(botc[1]) + 1
newbot=ta.pivotlow(src,len,0) BotBL_z=newbot[1] and not newbot and
low[1]<low[botc] and src[1]>src[botc] and diff[botc]<dea[botc] and src[botc]<0
BotBL_h=newbot[1] and not newbot and low[1]>low[botc] and src[1]<src[botc] and
diff[botc]<dea[botc] and src[botc]<0 BLBotc=0 if BotBL_z or BotBL_h
BLBotc:=botc BLBotc //5,20,40,60mt5result = findMACDTopBl(5)mt10result =
findMACDTopBl(10)mt20result = findMACDTopBl(20)mt40result = findMACDTopBl(40)
mt60result = findMACDTopBl(60)mb5result = findMACDBotBl(5)mb10result =
findMACDBotBl(10)mb20result = findMACDBotBl(20)mb40result = findMACDBotBl(40)
mb60result = findMACDBotBl(60)if mt5result
array.push(macdtoplabels,label.new(x=bar_index, y=high, yloc=yloc.abovebar,
text='m' + notend, textcolor=#ffffff, color=color.new(color.red, 40),
size=size.tiny, style=label.style_label_down))if mt10result
array.push(macdtoplabels,label.new(x=bar_index, y=high, yloc=yloc.abovebar,
text='m' + notend, textcolor=#ffffff, color=color.new(color.red, 40),
size=size.tiny, style=label.style_label_down))if mt20result
array.push(macdtoplabels,label.new(x=bar_index, y=high, yloc=yloc.abovebar,
text='m' + notend, textcolor=#ffffff, color=color.new(color.red, 40),
size=size.tiny, style=label.style_label_down))if mt40result
array.push(macdtoplabels,label.new(x=bar_index, y=high, yloc=yloc.abovebar,
text='m' + notend, textcolor=#ffffff, color=color.new(color.red, 40),
size=size.tiny, style=label.style_label_down))if mt60result
array.push(macdtoplabels,label.new(x=bar_index, y=high, yloc=yloc.abovebar,
text='m' + notend, textcolor=#ffffff, color=color.new(color.red, 40),
size=size.tiny, style=label.style_label_down))if mb5result
array.push(macdbotlabels,label.new(x=bar_index, y=low, yloc=yloc.belowbar, text='m'
+ notend, textcolor=#ffffff, color=color.new(color.green, 40), size=size.tiny,
style=label.style_label_up))if mb10result
array.push(macdbotlabels,label.new(x=bar_index, y=low, yloc=yloc.belowbar, text='m'
+ notend, textcolor=#ffffff, color=color.new(color.green, 40), size=size.tiny,
style=label.style_label_up))if mb20result
array.push(macdbotlabels,label.new(x=bar_index, y=low, yloc=yloc.belowbar, text='m'
+ notend, textcolor=#ffffff, color=color.new(color.green, 40), size=size.tiny,
style=label.style_label_up))if mb40result
array.push(macdbotlabels,label.new(x=bar_index, y=low, yloc=yloc.belowbar, text='m'
+ notend, textcolor=#ffffff, color=color.new(color.green, 40), size=size.tiny,
style=label.style_label_up))if mb60result
array.push(macdbotlabels,label.new(x=bar_index, y=low, yloc=yloc.belowbar, text='m'
+ notend, textcolor=#ffffff, color=color.new(color.green, 40), size=size.tiny,
style=label.style_label_up))//recolor previous error divergence labelsif
array.size(macdtoplabels)>=1 for i=0 to array.size(macdtoplabels)-1
templabel=array.get(macdtoplabels,i) x1=label.get_x(templabel) if
bar_index-x1-1<4 and diff>diff[bar_index-x1]
label.set_color(templabel,color.new(color.gray,90))
label.set_textcolor(templabel,color.gray)if array.size(macdbotlabels)>=1 for i=0
to array.size(macdbotlabels)-1 templabel=array.get(macdbotlabels,i)
x1=label.get_x(templabel) if bar_index-x1-1<4 and diff<diff[bar_index-x1]
label.set_color(templabel,color.new(color.gray,90))
label.set_textcolor(templabel,color.gray) //-----------//ALert
//-----------alertname = syminfo.tickerperiodDesc = ''if timeframe.period == '30'
periodDesc := 'in 30Min ' periodDescelse if timeframe.period == '60'
periodDesc := 'in 1Hour ' periodDescelse if timeframe.period == '120'
periodDesc := 'in 2Hour ' periodDescelse if timeframe.period == '240'
periodDesc := 'in 4Hour ' periodDescelse if timeframe.period == 'D'
periodDesc := 'in Day ' periodDescelse if timeframe.period == 'W'
periodDesc := 'in Week ' periodDescelse periodDesc := 'in ' +
timeframe.period + 'period ' periodDescalertname += periodDesctopbl = t5result
or t10result or t20result or mt5result or mt10result or mt20result or mt40result
or mt60resultbotbl = b5result or b10result or b20result or mb5result or mb10result
or mb20result or mb40result or mb60resultif topbl alert(alertname + ' TOP
Divergence!', alert.freq_once_per_bar_close)if botbl alert(alertname + ' Bottom
Divergence!', alert.freq_once_per_bar_close)atrPeriod = input.int(10, "ATR
Length", minval = 1, group="Supertrend")factor = input.float(3.0, "Factor",
minval = 0.01, step = 0.01, group="Supertrend")[supertrend, direction] =
ta.supertrend(factor, atrPeriod)supertrend := barstate.isfirst ? na : supertrend
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color =
color.green, style = plot.style_linebr)downTrend = plot(direction < 0 ? na :
supertrend, "Down Trend", color = color.red, style = plot.style_linebr)bodyMiddle
= plot(barstate.isfirst ? na : (open + close) / 2, "Body Middle",display =
display.none)fill(bodyMiddle, upTrend, title = "Uptrend background", color =
color.new(color.green, 90), fillgaps = false)fill(bodyMiddle, downTrend, title =
"Downtrend background", color = color.new(color.red, 90), fillgaps = false)
alertcondition(direction[1] > direction, title='Downtrend to Uptrend', message='The
Supertrend value switched from Downtrend to Uptrend ')alertcondition(direction[1]
< direction, title='Uptrend to Downtrend', message='The Supertrend value switched
from Uptrend to Downtrend')alertcondition(direction[1] != direction, title='Trend
Change', message='The Supertrend value switched from Uptrend to Downtrend or vice
versa')var co = 0if botbl co:=1if topbl co:=-1long = direction[1]>direction
and co==1short = direction[1]<direction and co==-1plotshape(long , title="Buy",
text="Buy", location=location.belowbar, style=shape.labelup, size=size.tiny,
color=color.green, textcolor=color.white)plotshape(short , title="Sell",
text="Sell", location=location.abovebar, style=shape.labeldown, size=size.tiny,
color=color.red, textcolor=color.white)alertcondition(long , "Buy")
alertcondition(short , "Sell")if long or short co:=0

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy