StockFetcher Forums · General Discussion · MACD cross above not working on all charts<< >>Post Follow-up
rfresh737
9 posts
msg #161462
Ignore rfresh737
12/10/2024 5:07:05 AM

I'm trying to write a script that shows me stocks where the MACD has crossed above within the last 3 days but the charts I see showing the cross over 10 days ago or more or no cross over at 3 days.
What am I doing wrong?

chart-time is 20 days
MACD Line(12,26) crossed above Signal Line(12,26,9) within the last 3 days
and MACD Line(12,26) is above Signal Line(12,26,9) since 3 days ago
draw MACD Line(12,26)
draw Signal Line(12,26,9)



xarlor
585 posts
msg #161463
Ignore xarlor
12/10/2024 8:39:06 AM

Signal Line is not an indicator in SF.

Are you looking for the crossover of the fast MACD line over the slow MACD line or are you looking for one of these to cross above 0?

SAFeTRADE
645 posts
msg #161464
Ignore SAFeTRADE
modified
12/10/2024 11:56:22 AM

Try this on for size.

Fetcher[
/* CODE FOR MACD233 */
set{f, 13 + 1}
set{s, 26 + 1}
set{fastcoef, 2.00 / f}
set{slowcoef, 2.00 / s}

set{ema3, ema(13)}
set{ema6, ema(26)}

set{a, ema3 * fastcoef}
set{b, ema6 * slowcoef}
set{c, a - b}
set{d, fastcoef - slowcoef}
set{e, c / d}
set{e_ema, cema(e,12)}
set{cls2, close}
set{a1,1 - fastcoef}
set{a2, a1 * ema3}
set{b1,1 - slowcoef}
set{b2, b1 * ema6}
set{c1, a2 - b2}
set{c2, 0 - c1}
set{zl, c2 / d}

set{z, a + b}
set{zz, fastcoef + slowcoef}
set{zzz, z / zz}
set{mid1,zzz + e}
set{mid,mid1 / 2}
draw zl on plot price
draw e_ema on plot price

chart-time is 9 months
symlist(spy,qqq,dia,nvda,iwm,aapl)
set{macdx,count(MACD fast Line(12,26,9) crossed above macd slow Line(12,26,9) within the last 3 days,1)}
set{macdx0,count(MACD fast Line(12,26,9) crossed above 0 within the last 3 days,1)}
set{fabvs,count(MACD(12,26,9) fast Line crossed above macd(12,26,9) slow Line 3 days ago,1)}

draw macd(12,26,9)
draw macdx
draw macdx0
draw fabvs
]


draw zzz on plot price

Alterations can be made, just ask your tailor. :>)

added ZL(zero line) and fast line (e_ema) on chart for better visual. Hope that helps.


rfresh737
9 posts
msg #161465
Ignore rfresh737
12/10/2024 4:30:04 PM

>Are you looking for the crossover of the fast MACD line over the slow MACD line or are you looking for one of these to cross above 0?

I'm looking for the Fast cross over of the Slow, and for that to happen when both are below 0.


rfresh737
9 posts
msg #161466
Ignore rfresh737
12/10/2024 4:31:35 PM

>Try this on for size.
Thank you SAFeTrade for that code. I'm still learning SF so it will take me a little while to understand what you wrote, but thank you very much.

xarlor
585 posts
msg #161467
Ignore xarlor
12/11/2024 8:43:05 AM

In simplest terms, here is what you're after:

Fetcher[
chart-time is 20 days
MACD Fast Line(12,26,9) crossed above MACD Slow Line(12,26,9) within the last 3 days
MACD Fast Line(12,26,9) > MACD Slow Line(12,26,9)

MACD Fast Line(12,26,9) < 0
MACD Slow Line(12,26,9) < 0
]



rfresh737
9 posts
msg #161468
Ignore rfresh737
12/11/2024 8:53:32 AM

Thank you very much.

StockFetcher Forums · General Discussion · MACD cross above not working on all charts<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2022 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.