//-------------------------------------------------------------------//
//PRC_Fibonacci Golden Wave
//version = 0
//13.03.24
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//-------------------------------------------------------------------//
//-------------------------------------------------------------------//
prd=20
usepivots=0 //Boolean/ 0=Calculate Donchian Channel / 1=Calculate Pivot Points
level1=2 //1=0.236 / 2=0.382 / 3=0.500 / 4=0.618 / 5=0.786
level2=4//1=0.236 / 2=0.382 / 3=0.500 / 4=0.618 / 5=0.786
//-------------------------------------------------------------------//
//-----Level 1 Selection---------------------------------------------//
if level1=1 then
fibArea1=0.236
elsif level1=2 then
fibArea1=0.382
elsif level1 = 4 then
fibArea1=0.618
elsif level1=5 then
fibArea1=0.786
else
fibArea1=0.500
endif
//-------------------------------------------------------------------//
//-----Level 2 Selection---------------------------------------------//
if level2=1 then
fibArea2=0.236
elsif level2=2 then
fibArea2=0.382
elsif level2=3 then
fibArea2=0.500
elsif level2=5 then
fibArea2=0.786
else
fibArea2=0.618
endif
//-------------------------------------------------------------------//
//-----Level Top and Bottom Calculation------------------------------//
if usepivots then
//-----Pivot Points Method----------------------------------------//
src1 = low
src2 = high
//-----pivots low
if src1 > src1[prd] and lowest[prd](src1) > src1[prd] and src1[prd] < lowest[prd](src1)[prd+1] then
$ply[z+1] = src1[prd]
$plx[z+1] = barindex[prd]
z = z+1
endif
//-----pivots high
if src2 < src2[prd] and highest[prd](src2)<src2[prd] and src2[prd]>highest[prd](src2)[prd+1] then
$phy[t+1]=src2[prd]
$phx[t+1]=barindex[prd]
t=t+1
endif
//-----Top and Bottom level
if isset($phy[t]) and isset($ply[z]) then
fibtop=$phy[t]
fibbot=$ply[z]
diff=fibtop-fibbot
fib1=fibtop-(diff*fibArea1)
fib2=fibtop-(diff*fibArea2)
endif
else
//-----Donchian----- Method----------------------------------------//
fibtop=highest[prd](high)
fibbot=lowest[prd](low)
diff=fibtop-fibbot
fib1=fibtop-(diff*fibArea1)
fib2=fibtop-(diff*fibArea2)
endif
//-------------------------------------------------------------------//
colorbetween(fib1,fib2,"orange",100)
//-------------------------------------------------------------------//
myfib1=round(fib1,2)
myfib2=round(fib2,2)
if islastbarupdate then
drawtext("Fibo Level #fibArea1#: #myfib1#",barindex+5,fib1)
drawtext("Fibo Level #fibArea2#: #myfib2#",barindex+5,fib2)
endif
//-------------------------------------------------------------------//
MidLine=(fib1+fib2)/2
//-------------------------------------------------------------------//
return fib1 as "Fibonacci Level1" coloured("orange"), fib2 as "Fibonacci Level2" coloured("orange"), MidLine coloured("blue")