Need help with macd screener

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #30319 quote
    Patrick K Templar
    Participant
    Average

    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

    #30474 quote
    Nicolas
    Keymaster
    Master

    This 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!

    signal=MACDline[12,26,9](close)
    
    lookback=10
    
    for i = 0 to lookback do 
    if signal[i] crosses over 0 then 
    condition=1
    direction=1
    break
    endif
    if signal[i] crosses under 0 then 
    condition=1
    direction=-1
    break
    endif
    next
    
    screener[condition](direction as "bull or bear")
    MACD-screener.png MACD-screener.png
    #30560 quote
    Patrick K Templar
    Participant
    Average

    thank 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

    #30562 quote
    Patrick K Templar
    Participant
    Average

    hello 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

    look.png look.png
    #30749 quote
    Nicolas
    Keymaster
    Master

    I 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.

    Mline=MACDline[12,26,9](close)
    Msignal=exponentialaverage[9](Mline)
    
    lookback=3
     
    condition=0
    for i = 0 to lookback do
    if MLine[i] crosses over Msignal[i] then
    condition=1
    direction=1
    break
    endif
    if Mline[i] crosses under Msignal[i] then
    condition=1
    direction=-1
    break
    endif
    next
    
    screener[condition](direction as "bull or bear")
    #31013 quote
    Patrick K Templar
    Participant
    Average

    Thank 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

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Need help with macd screener


ProScreener: Market Scanners & Detection

New Reply
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by Patrick K Templar
8 years, 11 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 03/30/2017
Status: Active
Attachments: 2 files
Logo Logo
Loading...