MTF Moving Average Slope Historgram

DaysOff

New member
Hey good people...thought I'd break the ice with a cut and paste of the first ToS indicator that I've managed to cobble together.

Looking at Rob Hoffman's IRB strategy, I thought it would be handy to have a view of the slope of a higher timeframe moving average. I've been using this to day trade ES mini futures, 2 min chart. I like using the EZ Trend indicator on 2 min and MA Slope Histogram on 5 min or 10 min...trade in the direction the colors line up. Do whatever works for you. Simple but it works.

I did some digging and put this together:

Code:
# MTF Moving Average Slope Histogram
# DaysOff

declare lower;

input price = close;
input length = 10;
input agperiod = { "1 min", "2 min", "5 min", default "10 min", "15 min", "30 min", "60 min", "4 hours"};

def avg = ExpAverage(close(period = agperiod), length);
plot height = avg - avg[length];

height.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
height.DefineColor("height >= 0" , Color.GREEN);
height.DefineColor("height < 0", Color.RED);
height.assignValueColor(if height >= 0 then height.color("height >= 0") else height.color("height < 0"));

S&P E-micro futures, 2 min chart w/ EMA slope histogram on 10 min...

cIF4oD7.jpg
 
Last edited by a moderator:

MerryDay

Administrative
Staff member
Staff
VIP
@DaysOff This is a perfect illustration of the use of a higher time-frame on a lower aggregation. Your chart provides clear indications of long-term direction, slope, trend, momentum which is a textbook because it is always better to trade with the trend as defined by the higher timeframe as you said. Love it!

Explanation of How this and other MultiTimeFrame Indicators work is for any future readers who might not be aware of how to read and trade with a higher aggregation plotted on a lower timeframe.
 
Last edited:

DaysOff

New member
As stated in OP, I created this indicator to give me a quick view of higher timeframe MA trend for day trading/scalping the ES futures. Combined with the EZ Trend indicator which can be found here, I have been trading the IRB strategy (see here) when the 2 min EZ Trend indicator lines up with the MA slope on higher timeframe...usually 5 min or 10 min. You miss some entries, but better to trade with the trend as defined by the higher timeframe.

Cheers.

WhAoTAc.jpg
 

westonsloan

New member
Hey good people...thought I'd break the ice with a cut and paste of the first ToS indicator that I've managed to cobble together.

Looking at Rob Hoffman's IRB strategy, I thought it would be handy to have a view of the slope of a higher timeframe moving average. I've been using this to day trade ES mini futures, 2 min chart. I like using the EZ Trend indicator on 2 min and MA Slope Histogram on 5 min or 10 min...trade in the direction the colors line up. Do whatever works for you. Simple but it works.

I did some digging and put this together:

Code:
# MTF Moving Average Slope Histogram
# DaysOff

declare lower;

input price = close;
input length = 10;
input agperiod = { "1 min", "2 min", "5 min", default "10 min", "15 min", "30 min", "60 min", "4 hours"};

def avg = ExpAverage(close(period = agperiod), length);
plot height = avg - avg[length];

height.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
height.DefineColor("height >= 0" , Color.GREEN);
height.DefineColor("height < 0", Color.RED);
height.assignValueColor(if height >= 0 then height.color("height >= 0") else height.color("height < 0"));

S&P E-micro futures, 2 min chart w/ EMA slope histogram on 10 min...

cIF4oD7.jpg
I literally only signed into my account right now just to thank you for this contribution to the trading community! Thank you so much! This is remarkably efficient for visual people like me, and it definitely shows you another perspective -- a color coded multi time frame histogram to plot a higher timeframe's moving average slope curve was absolutely brilliant! This study was created at the intersection of ingenuity and conceptual refinement. I am very satisfied with this, please be well!
 
Last edited:

westonsloan

New member
@westonsloan, thanks for the kind words. I'm glad someone finds this indicator useful!
Back again, still the most useful indicator that I have to date -- I have a question.

How can I turn this into a scan to find upwards trending stocks or to query results that have a trending positive ratio? Anything that can basically tell me a trend reversal would be nice. I tried to work with what I got yet the system says that the code cannot use the second time aggregate (error). I am assuming bc if I set the time aggregate for scan to 5MIN yet the study is taking another higher timeframe (15) its like having the data double the scan on itself. Idk if that makes sense. Any tips? Have you made this into a scanner? Even when I set study is greater than or equal to "value" that I sent, still does not work. Any insight is greatly appreciated. @BenTen @DaysOff @MerryDay
 

DaysOff

New member
Hi @westonsloan...very happy to hear you find the indicator useful. However, I'm sorry I can't offer assistance with the question on using it to scan. Scanning in ToS is not a feature I use. Hopefully someone else will chime in with some advice.
 

Pensar

Well-known member
VIP
@westonsloan Try this code. I removed the higher aggregation from the code since it isnt compatible with the scanner - it has to be chosen from the dropdown menu. I havent tested it or anything, but it should scan for the bullish direction by default. When testing the results, make sure that the scan and the indicator you're using on the chart have the same aggregation selections.

Code:
# --- SCAN CODE ---
# Choose your desired aggregation from the scanner choices

# MTF Moving Average Slope Histogram Scan
# DaysOff

declare lower;

input price = close;
input length = 10;

def avg = ExpAverage(close, length);

# --- comment out the unwanted scan side

# bullish direction
plot height = avg - avg[length] >= 0;

# bearish direction
#plot height = avg - avg[length] < 0;
 

westonsloan

New member
@westonsloan Try this code. I removed the higher aggregation from the code since it isnt compatible with the scanner - it has to be chosen from the dropdown menu. I havent tested it or anything, but it should scan for the bullish direction by default. When testing the results, make sure that the scan and the indicator you're using on the chart have the same aggregation selections.

Code:
# --- SCAN CODE ---
# Choose your desired aggregation from the scanner choices

# MTF Moving Average Slope Histogram Scan
# DaysOff

declare lower;

input price = close;
input length = 10;

def avg = ExpAverage(close, length);

# --- comment out the unwanted scan side

# bullish direction
plot height = avg - avg[length] >= 0;

# bearish direction
#plot height = avg - avg[length] < 0;
Hello, just checked back and saw this contribution -- I appreciate your finding! I will backtest the code right away.

Also, I have created a scanner that seems to ONLY work with 10 min aggregate period which removes the "error: secondary time frame not allowed" message that you get while in thinkscript editor. All I did was set the scan period to 10 Min. Seems like the only time period for a scan that worked. That was before coming back to this amazing community and seeing this reply to my question. Thank you so much! Cheers to you!
 

westonsloan

New member
Hello, just checked back and saw this contribution -- I appreciate your finding! I will backtest the code right away.

Also, I have created a scanner that seems to ONLY work with 10 min aggregate period which removes the "error: secondary time frame not allowed" message that you get while in thinkscript editor. All I did was set the scan period to 10 Min. Seems like the only time period for a scan that worked. That was before coming back to this amazing community and seeing this reply to my question. Thank you so much! Cheers to you!
Can confirm this works. Comment out (#) the commands whether you want bearish or bullish directions. Match the aggregate to the aggregate you have on the indicator. For me it scans on the 15 min aggregation with the indicator placed on 5MIN chart. Brilliant work. This alone has increased efficiency tenfold and reduced chart time by a landslide. This contribution can win a nobel prize. Cheers!
 

Similar threads

Top