Calculate divergence from any Oscillator
Forums › ProRealTime English forum › ProBuilder support › Calculate divergence from any Oscillator
- This topic has 2 replies, 2 voices, and was last updated 1 month ago by Kruml0v.
-
-
11/12/2024 at 9:36 AM #240266
Does anyone know how to signal divergences from oscillators? I mean, we have RSI Divergence as an indicator on the platform. Is it possible to build an indicator using Ultimate Oscillator or Chande and after that use it as a screener?? How can it be done?
Thanks.
11/12/2024 at 12:04 PM #240272Bonjour
par exemple pour les divergences ultimate oscillator ajouter cet indicateur :
Defparam CALCULATEONLASTBARS=300
//Ultimate Oscillator by Larry Williams
BuyPressure = close – min(low, close[1])
TrueRange = TR(close)
per =7
avper = summation[per](BuyPressure) / summation[per](TrueRange)
avper2 = summation[per * 2](BuyPressure) / summation[per * 2](TrueRange)
avper4 = summation[per * 4](BuyPressure) / summation[per * 4](TrueRange)
UltimateOscillator = 100 * ((4 * avper) + (2 * avper2) + avper4) / 7lowerline = 30
upperline = 70
if close>open then
newclose=close
newopen=open
endif
if close<= open then
newclose=open
newopen=close
endif
///N is the number of bars to look back for a divergence. Normal values are 20-40. Must be the same in both indicators
N=23
cache=1
baissiere=1
miultimate=UltimateOscillator
if close>open then
newclose=close
newopen=open
endif
if close<= open then
newclose=open
newopen=close
endif
IF (miultimate[1]>miultimate AND miultimate[1]>miultimate[2]) THEN
extremumr2=miultimate[1]
extremumr1=highest[N](miultimate)
preciomaxr2=close[1]
preciomaxr=Highest[N](close)
IF(extremumr2<extremumr1 AND preciomaxr2>preciomaxr[1]) THEN
for j=1 to N
if miultimate[j]=extremumr1 and baissiere then
zzr=j
drawsegment (barindex[1], miultimate[1], barindex[zzr], miultimate[zzr])coloured(0,155,0)style(dottedline,2)
DRAWPOINT(barindex[1], miultimate[1],1)coloured(0,155,0,0)BORDERCOLOR(0,155,0)
DRAWPOINT(barindex[zzr], miultimate[zzr],1)coloured(0,155,0,0)BORDERCOLOR(0,155,0)
endif
next
endif
endif
IF (miultimate[1]>miultimate AND miultimate[1]>miultimate[2]) THEN
rsiextremB2=miultimate[1]
rsiextremB1=highest[N](miultimate)
rsipmaxB2=close[1]
rsipmaxB=Highest[N](close)
IF(rsiextremB2=rsiextremB1 AND rsipmaxB2>rsipmaxB[1]) THEN
for rsik=1 to N
if close[rsik]=rsipmaxB[1] and baissiere and cache then
rsizzmB=rsik
if newclose[1]<newclose[rsizzmB] then
signalrsi=-2
flag=1
DRAWTEXT(“c”,barindex[1], miultimate[1],dialog,bold,10)coloured(0,0,180)
drawsegment (barindex[1], miultimate[1], barindex[rsizzmB],miultimate[rsizzmB]) coloured(150,0,0)style(dottedline,1)
endif
endif
next
endif
endif
IF (miultimate[1]<miultimate AND miultimate[1]<miultimate[2]) THEN
extremumr22=miultimate[1]
extremumr11=lowest[N](miultimate)
preciominr2=close[1]
preciominr=lowest[N](close)
IF(extremumr22>extremumr11 AND preciominr2<preciominr[1]) THEN
highrsi=highest[N](miultimate)
roundmonhighrsi=round(monhighrsi)
monhighrsi=highrsi
for j2=1 to N
if miultimate[j2]=extremumr11[1] then
zzr2=j2
drawsegment (barindex[1], miultimate[1], barindex[zzr2], miultimate[zzr2])coloured(0,155,0)style(line,2)
DRAWPOINT(barindex[1], miultimate[1],1)coloured(0,155,0,0)BORDERCOLOR(0,155,0)
DRAWPOINT(barindex[zzr2], miultimate[zzr2],1)coloured(0,155,0,0)BORDERCOLOR(0,155,0)
endif
next
endif
endif
IF (miultimate[1]<miultimate AND miultimate[1]<miultimate[2]) THEN
rsiextremC2=miultimate[1]
rsiextremC1=lowest[N](miultimate)
rsipminC2=close[1]
rsipminC=Lowest[N](close)
IF(rsiextremC2=rsiextremC1 AND rsipminC2>rsipminC[1]) THEN
for rsil=1 to N
if close[rsil]=rsipminC[1] and cache then
rsizzmC=rsil
DRAWTEXT(“c”,barindex[1], miultimate[1],dialog,bold,10)coloured(0,0,180)
drawsegment (barindex[1], miultimate[1], barindex[rsizzmC],miultimate[rsizzmC]) coloured(150,0,0)style(line,1)
endif
next
endif
endif
if miultimate crosses over 19 then
DRAWPOINT(barindex, miultimate, 2)
endifreturn UltimateOscillator coloured(0,0,0), lowerline coloured(0,0,255) as “lower line”, upperline coloured(0,0,255) as “upper line”
puis ajouter ce screener :
CapitaLisationMini =100000
timeframe (monthly)
c1=average[20](close*volume)>(CapitaLisationMini*21)
timeframe (weekly)
c1=average[20](close*volume)>(CapitaLisationMini*5)
TIMEFRAME(4 HOUR)
c1=average[20](close*volume)>(CapitaLisationMini/2.14)
TIMEFRAME(1 HOUR)
c1=average[20](close*volume)>(CapitaLisationMini/8.5)
TIMEFRAME(30 minutes)
c1=average[20](close*volume)>(CapitaLisationMini/17)
TIMEFRAME(15 minutes)
c1=average[20](close*volume)>(CapitaLisationMini/34)
TIMEFRAME(5 minutes)
c1=average[20](close*volume)>(CapitaLisationMini/102)
TIMEFRAME(2 minutes)
c1=average[20](close*volume)>(CapitaLisationMini/255)
TIMEFRAME(daily)
c1=average[20](close*volume)>(CapitaLisationMini)
Timeframe(default)
N=23///N is the number of bars to look back for a divergence. Normal values are 20-40. Must be the same in both indicators
//using any other indicator is as easy as changing the values
mymonultimate, ignored, ignored = CALL “mon ultimate”
miultimate =mymonultimate //RSI[14](close)// exponentialAverage[12](close) – exponentialAverage[26](close)
signalh=0
signalb=0
if close<= open then
newclose=open
newopen=close
endif
IF (miultimate[1]>miultimate AND miultimate[1]>miultimate[2]) THEN
rsiextrem2=miultimate[1]
rsiextrem1=highest[N](miultimate)
rsipmax2=close[1]
rsipmax=Highest[N](close)
IF(rsiextrem2<rsiextrem1 AND rsipmax2>rsipmax[1]) THEN
for rsii=1 to N
if close[rsii]=rsipmax[1] then
rsizzm=rsii
if newclose[1]>newclose[rsizzm] then
signalb=-1
endif
endif
next
endif
endif
IF (miultimate[1]>miultimate AND miultimate[1]>miultimate[2]) THEN
rsiextremB2=miultimate[1]
rsiextremB1=highest[N](miultimate)
rsipmaxB2=close[1]
rsipmaxB=Highest[N](close)
IF(rsiextremB2=rsiextremB1 AND rsipmaxB2>rsipmaxB[1]) THEN
for rsik=1 to N
if close[rsik]=rsipmaxB[1] then
rsizzmB=rsik
if newclose[1]<newclose[rsizzmB] then
signalb=-2
endif
endif
next
endif
endif
IF (miultimate[1]<miultimate AND miultimate[1]<miultimate[2]) THEN
rsiextrem22=miultimate[1]
rsiextrem11=lowest[N](miultimate)
rsipmin2=close[1]
rsipmin=lowest[N](close)
IF(rsiextrem22>rsiextrem11 AND rsipmin2<rsipmin[1]) THEN
for rsij2=1 to N
if close[rsij2]=rsipmin[1] then
rsizzm2=rsij2
if newopen[1]<newopen[rsizzm2] then
signalh=1
endif
endif
next
endif
endif
IF (miultimate[1]<miultimate AND miultimate[1]<miultimate[2]) THEN
rsiextremC2=miultimate[1]
rsiextremC1=lowest[N](miultimate)
rsipminC2=close[1]
rsipminC=Lowest[N](close)
IF(rsiextremC2=rsiextremC1 AND rsipminC2>rsipminC[1]) THEN
for rsil=1 to N
if close[rsil]=rsipminC[1] then
rsizzmC=rsil
if newopen[1]>newopen[rsizzmC] then
signalh=2
endif
endif
next
endif
endif
screener [c1 and (signalh>0)](signalh as “divhaussiere”,signalb as “divbaissiere”)//////////////////////////////////////////////
2 users thanked author for this post.
11/14/2024 at 7:44 PM #240387 -
AuthorPosts
Find exclusive trading pro-tools on