Hi, I leave a very practical modification of Macd and Squeeze, the MACD histogram is colored in red or green depending on whether the squeeze is active or not. Additionally, the MACD line is colored green if the RSI is oversold or red, if it is in overbought.
// JJP- Marzo 2019.
// Settings
Length=20
mult=2
lenghkc=20
Multkc=1.5
Macdcorta=12
Macdlarga=26
Macdsignal=9
PeriodoRSI=14
sobreventaRSI=70
SobrecompraRSI=30
//Squeeze.
//BB
basis = average[length](close)
dev = mult * Std[length](close)
upperBB = basis + dev
lowerBB = basis - dev
//KC
ma = average[lengthKC](close)
myrange = range[lengthKC]
rangema = average[lengthKC](myrange)
upperKC = ma+rangema * multKC
lowerKC = ma-rangema * multKC
sqzOn = (lowerBB>lowerKC) AND (upperBB<upperKC)
if(sqzOn=1) then
scolorR = 0
scolorG = 300
else
scolorR = 255
scolorG = 0
ENDIF
REM MACD
myMACD=exponentialaverage[MACDCorta]-exponentialaverage[MACDLarga]
signal=exponentialaverage[MACDSignal](myMACD)
Osma=mymacd-signal
// RSI
MyRSi=rsi[PeriodRSI](close)
if MyRsi>70 then
r=255
g=0
b=0
endif
if MyRSI<30 then
r=55
g=255
b=55
endif
if myRSI>30 and myrsi<70 then
R=55
g=0
B=255
endif
return osma coloured(scolorR,scolorg,0) style(histogram) as "Osma_Sque", mymacd coloured (r,g,b)as "macd", signal as "Signal"
You must be logged in to post a comment.
Solo hay que cambiar la variable MACDSignal por otro nombre, ya que el programa reconoce a MACDSIgnal como la señal del indicador MACD disponible. (me parece)
Hello, Firtly there appears to be a typo on line 6 "lenghkc=20" should this be "lengthkc=20". Secondly this will not run on my auto trades -- "The trading system was stopped because an indicator received a negative or zero parameter ex:(-10). You can modify your code to to prevent negative parameters then backtest the system to check the correction." error on ProOrder. Any Help Please. Many thanks in advance Harry