Hi,
Please help me with a screener
1.Price moving average 20 cross e.g. over
2. Refer to attached code. I need a condition where the moving average cross takes place under conditions/ during the times where e.g. the zerolagMACD is currently/must be trading over signalMACD and vice versa, at the time of the moving average cross (note: not referring to the point where both need to cross at the same time).
3. trading range macd e.g 0 to 0.1
Regards,
Segie
// — settings
short = 12
long = 26
signal = 9
/ — end of settings
MAshort1 = exponentialaverage[short](close)
EMAshort2 = exponentialaverage[short](EMAshort1)
DifferenceShort = EMAshort1 - EMAshort2
ZeroLagShort = EMAshort1 + DifferenceShort
flag=0
EMAlong1 = exponentialaverage[long](close)
EMAlong2 = exponentialaverage[long](EMAlong1)
DifferenceLong = EMAlong1 - EMAlong2
ZeroLagLong = EMAlong1 + DifferenceLong
ZeroLagMACD = ZeroLagShort - ZeroLagLong
signal1=ExponentialAverage[signal](ZEROLAGMACD)
signal2=ExponentialAverage[signal](signal1)
DIFFERENCE2=signal1-signal2
SignalMACD=signal1+DIFFERENCE2
if zerolagMACD crosses over signalMACD then
flag=1
endif
if zerolagMACD crosses under signalMACD then
flag=2
endif
// Price between 1-20
PriceRang = close>=3 and close<=10
screener [flag=2 and PriceRang](flag as "flag")
Can you better explain rule 2?
Please see attached.
When 20ma cross takes place it must correspond with the appropriate color of the MACD.
E.g Whith Bull MA cross then MACD must also be in the ‘blue’. zerolagMACD currently trading over signalMACD
If there’s a bull MA cross but MACD in the ‘red’ then shouldn’t be part if the screened items. i,e zerolagMACD currently trading under signalMACD
Both must align.
Hi! I think instead using flags you should just code macd>signal.
// — settings
short = 12
long = 26
signal = 9
EMAshort1 = exponentialaverage[short](close)
EMAshort2 = exponentialaverage[short](EMAshort1)
DifferenceShort = EMAshort1 - EMAshort2
ZeroLagShort = EMAshort1 + DifferenceShort
EMAlong1 = exponentialaverage[long](close)
EMAlong2 = exponentialaverage[long](EMAlong1)
DifferenceLong = EMAlong1 - EMAlong2
ZeroLagLong = EMAlong1 + DifferenceLong
ZeroLagMACD = ZeroLagShort - ZeroLagLong
signal1=ExponentialAverage[signal](ZEROLAGMACD)
signal2=ExponentialAverage[signal](signal1)
DIFFERENCE2=signal1-signal2
SignalMACD=signal1+DIFFERENCE2
screener[close crosses over average[20](close) and zerolagMACD>signalMACD and (zerolagMACD>0 and zerolagMACD<0.1)]