//PRC_Quick Fib Trend Line | indicator
//09.01.2019 (release 1.1)
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
DefParam DrawOnLastBarOnly = true
// --- settings
//period = 100 // lookback period of the Fibonacci Retracement
//DrawRetracementBlocks = 1 // 0=false ; 1=true
//TrendLine = 1 // 0=false ; 1=true
// --- end of settings
hh = 0
ll = low
shiftlowest = barindex
for i = period downto 1 do
if high[i]>hh then
hh = high[i]
shifthighest = barindex[i]
endif
if low[i]<ll then
ll = low[i]
shiftlowest = barindex[i]
endif
next
if trendline = 1 then
// contour lines option
shiftContourDown = barindex-shiftHighest
highestSlope = 0
counth = max(1,(barindex-shifthighest))
for i = 2 to counth do
thisSlope = (High[i] - hh) / ((barindex-shiftHighest) - i)
if (thisSlope >= highestSlope or highestSlope = 0) then
shiftContourDown = i
highestSlope = thisSlope
endif
next
shiftContourUp = barindex-shiftLowest
LowestSlope = 0
countl = max(1,(barindex-shiftLowest))
for i = 2 to countl do
thisSlope = (low[i] - ll) / ((barindex-shiftLowest) - i)
if (thisSlope <= LowestSlope or LowestSlope = 0) then
shiftContourUp = i
LowestSlope = thisSlope
endif
next
DrawLine(shifthighest,hh,barindex[shiftcontourdown],high[shiftcontourdown]) coloured(r,g,b)
DrawLine(shiftlowest,ll,barindex[shiftcontourup],low[shiftcontourup]) coloured(r,g,b)
endif
isSwingDown = shiftHighest < shiftLowest
if isSwingDown then
fullrange = abs(hh-ll)
fibo100 = hh
fibo0 = ll
fibo236 = ll+(fullrange*0.236)
fibo382 = ll+(fullrange*0.382)
fibo50 = ll+fullrange/2
fibo618 = ll+(fullrange*0.618)
fibo764 = ll+(fullrange*0.764)
startbar = min(shifthighest,shiftlowest)
r = 200
g = 0
b = 0
else
fullrange = abs(hh-ll)
fibo100 = ll
fibo0 = hh
fibo236 = hh-(fullrange*0.236)
fibo382 = hh-(fullrange*0.382)
fibo50 = hh-fullrange/2
fibo618 = hh-(fullrange*0.618)
fibo764 = hh-(fullrange*0.764)
startbar = min(shifthighest,shiftlowest)
r = 0
g = 200
b = 0
endif
if Fibonacci = 1 then
if startbar>0 then
// plot fibonacci levels
DrawSegment(startbar,fibo100,barindex,fibo100) coloured(r,g,b)
DrawText(" 100%",barindex,fibo100,Dialog,Standard,11) coloured(r,g,b)
DrawSegment(startbar,fibo0,barindex,fibo0) coloured(r,g,b)
DrawText(" 0%",barindex,fibo0,Dialog,Standard,11) coloured(r,g,b)
DrawSegment(startbar,fibo236,barindex,fibo236) coloured(r,g,b)
DrawText(" 23.6%",barindex,fibo236,Dialog,Standard,11) coloured(r,g,b)
DrawSegment(startbar,fibo382,barindex,fibo382) coloured(r,g,b)
DrawText(" 38.2%",barindex,fibo382,Dialog,Standard,11) coloured(r,g,b)
DrawSegment(startbar,fibo50,barindex,fibo50) coloured(r,g,b)
DrawText(" 50.0%",barindex,fibo50,Dialog,Standard,11) coloured(r,g,b)
DrawSegment(startbar,fibo618,barindex,fibo618) coloured(r,g,b)
DrawText(" 61.8%",barindex,fibo618,Dialog,Standard,11) coloured(r,g,b)
DrawSegment(startbar,fibo764,barindex,fibo764) coloured(r,g,b)
DrawText(" 76.4%",barindex,fibo764,Dialog,Standard,11) coloured(r,g,b)
// plot price at 0% and 100% levels
DrawText("HI #hh#",shifthighest,hh+fullrange*0.03,dialog,standard,11) coloured(255,0,0)
DrawText("LO #ll#",shiftlowest,ll-fullrange*0.03,dialog,standard,11) coloured(0,255,0)
endif
endif
// retracement blocks
if DrawRetracementBlocks then
if not isSwingDown then
blockprice = hh
startbar = barindex-shifthighest
for i = startbar downto 2 do
if low[i]<blockprice then
blockprice = low[i]
blockbar = barindex[i]
endif
next
DrawRectangle(blockbar,blockprice,barindex,ll) coloured(r,g,b)
else
blockprice = ll
startbar = barindex-shiftlowest
for i = startbar downto 2 do
if high[i]>blockprice then
blockprice = high[i]
blockbar = barindex[i]
endif
next
DrawRectangle(blockbar,blockprice,barindex,hh) coloured(r,g,b)
endif
endif
return
Modification du code PRC_QuickFib réalisé par Nicolas consistant à l’ajout du niveau de 76.4% Fibonacci ainsi que l’ajout de 2 cases à cocher pour masquer “les niveaux de Fibonacci” et/ou “les Lignes de tendance oblique” afin de sélectionner visuellement ce qui vous sert le plus sans avoir besoin de mettre les mains dans le cambouis en espérant que la balise [Add PRT code] fonctionne correctement 😉
Il y a également le fichier PRC_QuickFibTL.itf en pièce jointe