I would like to create a stock market scanner to detect Simple Moving Average 13 over 30 Simple Moving Average crossover on the HOURLY time frame of all stocks. I would also like to incorporate the parameter of a stock in an uptrend or downtrend for about 14 days period before they signal cross over. I would also like the scanner to continuously give results. There is a refresh on the page to update the movement of stocks which has increments of 15 seconds if that helps.
I use [login to view URL] for charting and analysis and i am not sure how to scrape the data from there.
I have attached below how a scanner would alert based on the parameters met in the picture red color for when the 13 hourly crosses above the 30 hourly and when the 13 crosses below the 30 hourly green color.
This code is just for reference to what i am looking for in creating the program for MAC.
# Hourly Scan for 13/30 Crossover After 2 Weeks
# Scans for crossovers in both directions
# Choose hourly aggregation - Do NOT include extended hours
# 70 is the number of hourly bars that total two weeks - adjust as desired
input bars_since_cross = 70;
# allows a bit of room to scan for the cross - 7 is within the current day
input max_bars_since_cross = 7;
def ma1 = average(close,13);
def ma2 = average(close,30);
def cross_up = ma1 crosses above ma2;
def cross_dn = ma1 crosses below ma2;
def count_after_cross_up = if cross_up and !cross_up then 1
def count_after_cross_dn = if cross_dn and !cross_dn then 1
def long_entry = count_after_cross_up > bars_since_cross
and cross_dn within max_bars_since_cross bars;
def short_entry = count_after_cross_dn > bars_since_cross
and cross_up within max_bars_since_cross bars;
plot scan = long_entry or short_entry;
# end scan code