Need help with macd screener
Forums › ProRealTime English forum › ProScreener support › Need help with macd screener
- This topic has 5 replies, 2 voices, and was last updated 7 years ago by Patrick K Templar.
-
-
03/30/2017 at 12:01 PM #30319
Hello I just need help with the macd screener with a variable look back.
I tried using the automated service but I can’t get it to work
all I wanted to know is when the Macd signal line and MacD Liner have crossed or are equal and if that is up or if that is down,
and then be able to adjust how many bars it looks back so on a 4hour chart I want it to look back 20, so that’s 20 4hour bars, if someone here could be really helpful and get this sorted for me I would be so grateful thank you very much
03/31/2017 at 9:50 AM #30474This is the code you need. It will fetch through the last lookback periods to know if the MACD signal line has crosses over or under the zero line. It will always give you the last signal (bearish=1 or bullish=-1 one), because of course many crosses may have occurred in the lookback period!
123456789101112131415161718signal=MACDline[12,26,9](close)lookback=10for i = 0 to lookback doif signal[i] crosses over 0 thencondition=1direction=1breakendifif signal[i] crosses under 0 thencondition=1direction=-1breakendifnextscreener[condition](direction as "bull or bear")03/31/2017 at 6:34 PM #30560thank you Nicolas BUT it need to be the macd line NOT zero line, I am going to try and fix it my self but just in cases could you as well please
03/31/2017 at 7:31 PM #30562hello iv just gave it a try and i found the same issues if that the look back period never seems to work it set to 2 or 3 and it still counting all the crosses it does not seam to do it job, any thoughts on that
04/02/2017 at 7:00 PM #30749I found the mistake sorry, I didn’t reset the condition variable at each iteration.
I changed the crosses detection to the MACD line with its signal line instead of the zero one.
1234567891011121314151617181920Mline=MACDline[12,26,9](close)Msignal=exponentialaverage[9](Mline)lookback=3condition=0for i = 0 to lookback doif MLine[i] crosses over Msignal[i] thencondition=1direction=1breakendifif Mline[i] crosses under Msignal[i] thencondition=1direction=-1breakendifnextscreener[condition](direction as "bull or bear")04/04/2017 at 4:21 PM #31013Thank you ever so much for what you just did, really appreciate it I struggle a lot with the code on PReal it even though it’s very simple I just do not have the hindsight I haven’t got it, so thank you very much
kind regards
Patrick k Templar
-
AuthorPosts
Find exclusive trading pro-tools on