Intraday MACD Scan
Author: iasavage22
Creation Date: 9/13/2021 1:01 PM
profile picture

iasavage22

#1
Hello. I am having difficulty trying to run an intraday MACD scan using 130 minutes sampling frequency. The data I am using is at 10-minute frequency. I am using the standard code shown below:

CODE:
Please log in to see this code.



a) I set the scale to 130 minutes (upper corner on the left side). Is that the correct way to guarantee the frequency of computation of MACD of the scan? Is there a way to programmatically set the frequency to 130 minutes?

b) I try to show the results of a specific stock in a chart. I set the chart scale to 130 minutes and I would expect to see data in the charts at the following intervals -- 11:40am, 1:50pm, 4:00pm. Instead the chart is plotting at the following intervals – 10:50am, 1:00pm, 3:10pm, 4:00pm. I see the same intervals when I "Copy Price Data to Clipboard" and past into Excel.

c) s there a way to speed up the scan time? It currently takes about 14 minutes to run the scan on about 800 stocks. Other products I using take seconds to perform similar screens. By passing the series for the entire history of the stock, am I inadvertently unnecessarily computing the MACD for the entire history, when all I really need is a stabilized MACD series for at most the last month? Could I save time by truncating the data I pass to the routines?


Thanks in advance for your assistance.
profile picture

Eugene

#2
QUOTE:
Is there a way to programmatically set the frequency to 130 minutes?

CODE:
Please log in to see this code.


QUOTE:
I would expect to see data in the charts at the following intervals

Answered in the FAQ > When compressed into a higher intraday scale, the bars are being built in an unexpected manner.

QUOTE:
c) s there a way to speed up the scan time?

Unlike EMA, MACD doesn't have a .Value method to calculate indicator's value on the last bar for your screener. To speed up you can
1) load as less data as possible. Given MACD's largest period (26 bars) and the fact that it's an "unstable" indicator (see WS Programming Guide > Indicators > Stability of Indicators), the seed period would be about ~100 bars i.e. 26 * 3-4.
2) adjust the code accordingly:
CODE:
Please log in to see this code.
profile picture

iasavage22

#3
Thanks for the quick reply. I do have some follow-up questions:

On b) I read the article on “compression into a higher intraday scale” and it still is not apparent to me why for 10 minute data compressed into 130 minute bars the intervals would be 10:50am, 1:00pm, 3:10pm, 4:00pm. With a market open of 9:30am, it would be more reasonable to expect the following intervals 11:40am, 1:50pm, 4:00pm. Any thoughts on why I might be getting the former and not the latter?

On c) I agree that loading less data would make the most sense. My question is how would I go about doing that. This is a scan so it is NOT looping through the array. It only looks at the latest value to evaluate the result. I believe the MACD computation happens with the following line of code where the array is initialized and sized to accommodate the entire price history of the stock:

DataSeries macd = MACD.Series(Close);

Is there a way to limit the range of data that is loaded into the MACD.Series function?

Thanks again.
profile picture

Eugene

#4
1 - Have you followed the FAQ pointer to Market Manager?

2 - Yes, by limiting the loaded bars only.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).