//-----------------------------------------------------------------------//
//PRC_MACD RHO
//version = 0
//29.05.24
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//-----------------------------------------------------------------------//
//-----Inputs------------------------------------------------------------//
PeriodMA1 = 5
PeriodMA2 = 10
PeriodMA3 = 11
PeriodMA4 = 13
MAType=1
src=customclose
CrossType=1// 0=Cross_Fast_and_SlowLine / 1=Cross_FastLine_and_Zero
//-----------------------------------------------------------------------//
//-----Moving averages calculation---------------------------------------//
maa1=average[PeriodMA1,MAType](src)
maa2=average[PeriodMA2,MAType](src)
maa3=average[PeriodMA3,MAType](src)
maa4=average[PeriodMA4,MAType](src)
//-----------------------------------------------------------------------//
//-----MACD Calculation--------------------------------------------------//
FastMACD=maa1-maa2
SlowMACD=maa3-maa4
//-----------------------------------------------------------------------//
//-----Signals-----------------------------------------------------------//
if CrossType=1 then
//-----Crossing Fast Line with Zero
if fastMACD crosses over 0 then
drawarrowup(barindex,0)coloured("green")
elsif fastMACD crosses under 0 then
drawarrowdown(barindex,0)coloured("red")
endif
else
//-----Crossing Fast Line with SlowLine
//-----Special case - fast line is zero (MA1/2 Periods = 0)
if periodMA1=0 and periodMA2=0 then
if slowmacd crosses under 0 then
drawarrowdown(barindex,0)coloured("red")
endif
else
//-----Standard case
if fastmacd crosses over slowmacd then
drawarrowup(barindex,slowmacd)coloured("green")
elsif fastmacd crosses under slowmacd then
drawarrowdown(barindex,slowmacd)coloured("red")
endif
endif
endif
//-----------------------------------------------------------------------//
//-----Color-------------------------------------------------------------//
if slowMACD>0 then
r=0
b=255
else
r=255
b=0
endif
//-----------------------------------------------------------------------//
return fastMACD as "FastMACD"style(histogram)coloured("yellow"), slowMACD as "SlowMACD"style(histogram)coloured(r,0,b),0 as "Zero"style(dottedline2,2)