Implementing Hull Moving Average on Multiple Time Frames (MTF) with GRAPHONPRICE

18 Nov 2017
0 comment
0 attachment

This code snippet demonstrates how to replace a standard moving average with a Hull Moving Average (HMA) in a multi-time frame (MTF) indicator setup using the GRAPHONPRICE feature in ProBuilder. The Hull Moving Average provides a faster and smoother average, which is often preferred for its reduced lag compared to traditional moving averages.


// Define the time frame and period for the Hull Moving Average
TimeFrame1 = 15
Period = 9

// Calculate the Hull Moving Average for the specified time frame
HMA = HullAverage[Period](close) as TimeFrame1

// Plot the Hull Moving Average on the price chart
return HMA as "HMA on Price"

Explanation of the code:

  • TimeFrame1 and Period: The variables TimeFrame1 and Period are set to define the time frame (15 minutes) and the period (9 periods) for the Hull Moving Average calculation.
  • Hull Moving Average Calculation: The HullAverage[Period](close) function calculates the Hull Moving Average of the closing prices over the specified period. The as TimeFrame1 part ensures that the calculation is applied to the 15-minute time frame.
  • Plotting the HMA: The calculated Hull Moving Average is returned and labeled as “HMA on Price” to be plotted directly on the price chart. This allows for visual comparison of the HMA against the price movements within the same chart.

This example is useful for traders or analysts who want to utilize a more responsive moving average in their technical analysis, particularly in a multi-time frame context.

Related Post

Check out this related content for more information:

https://www.prorealcode.com/topic/timeframe-3/#post-95572

Visit Link
What is a Snippet? A snippet is a small, reusable chunk of code designed to solve specific tasks quickly. Think of it as a shortcut that helps you achieve your coding goals without reinventing the wheel. How to Use: Simply copy the snippet and paste it into your project where needed. Don't forget to tweak it to fit your context. Snippets are not just time-savers; they're also learning tools to help you become a more efficient coder.
robertogozzi Master
Roberto https://www.ots-onlinetradingsoftware.com
Author’s Profile

Comments

Search Snippets

Showing some results...
Sorry, no result found!

Snippets Categories

global
33
indicator
132
strategy
171

Recent Snippets

How to Build a Step-Based Trailing Stop That Moves to Break-Even First
strategy
This snippet implements a step trailing stop that advances in fixed increments once price reaches predefined profit [...]
Utilizing Arrays to Track and Compare Indicator Values Within the Same Bar in ProBuilder
indicator
This ProBuilder code snippet demonstrates how to use arrays to compare the values of an indicator (RSI in this case) [...]
Calculating Break-Even Points in ProBuilder
strategy
This ProBuilder code snippet demonstrates how to calculate the break-even point for a trading position. The break-even [...]
Implementing Time and Day Restrictions in Trading Algorithms
strategy
This code snippet demonstrates how to set restrictions on trading activities based on specific days of the week and [...]
Implementing Partial Position Closure Based on Price Retracement in ProBuilder
strategy
This code snippet demonstrates how to partially close a trading position when the price retraces to a certain level in [...]
Logo Logo
Loading...