MathFloor Hull Period

Kbone

New member
Hi @mashume,
First of all, I thank you for your ongoing MASSIVE support on this forum. You have amazing skills! Bonissimo.

Now, I'm wondering if you have any insight on this post I found online about a modified HULL, and what it might be trying to 'find'.

Here's the post (and I don't really understand the 'MathFloor' meaning in the description given):
Indicator name: Hull Moving Average MTF.

TOS has default Hull MA, but it is limited. I need additional features:

1. MTF - multi time frame (ability to display indicator on a smaller time frame based on the data of higher time frame)

2. Calculation in Hull MA are based on one the subtraction of two weighted averages where period of the second is X time smaller than the period of the first one. By default X = 2. This would preferrably be converted into Variable, that can be changed via indicator properties menu.

Sample code:

input TimeFrame = "Current time frame";

input HMAPeriod = 35;

input HMAPrice = PRICE_CLOSE;

input HMASpeed X = 2.0;

input displace = 0



HMAPeriod = MathMax(HMAPeriod);

HalfPeriod = MathFloor(HMAPeriod/HMASpeed);

HullPeriod = MathFloor(MathSqrt(HMAPeriod)); <----- THIS is the part that I do not understand HOW to code and/or see the hopeful benefit.

--------------------------------------------------------------------

I assume you're a busy person, but any insights would be appreciated! Of course, ANYONE else with the same feedback/effort would be appreciated---- I just remember Mashume's work on the Hull Concavity!!
 
Last edited by a moderator:
Solution
This page in the docs:
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Math---Trig/Floor
will tell you about the FLOOR() function. Floor returns the next lower integer for a given number:

6.0 --> 6
6.5 --> 6
6.999 --> 6

Since we need an integer value for the period of a moving average, and taking the square root will almost always result in a non-integer number, using the floor() function returns just the integer part and the moving average function will be happy. We like happy functions.

Code:
# HMAPeriod = MathMax(HMAPeriod);
# this is already addressed as an input value -- ToS doesn't like to redefine variables the way tradeview allows.

# HalfPeriod = MathFloor(HMAPeriod/HMASpeed);
def HalfPeriod =...
This page in the docs:
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Math---Trig/Floor
will tell you about the FLOOR() function. Floor returns the next lower integer for a given number:

6.0 --> 6
6.5 --> 6
6.999 --> 6

Since we need an integer value for the period of a moving average, and taking the square root will almost always result in a non-integer number, using the floor() function returns just the integer part and the moving average function will be happy. We like happy functions.

Code:
# HMAPeriod = MathMax(HMAPeriod);
# this is already addressed as an input value -- ToS doesn't like to redefine variables the way tradeview allows.

# HalfPeriod = MathFloor(HMAPeriod/HMASpeed);
def HalfPeriod = floor(HMAPeriod / HMASpeed));

# HullPeriod = MathFloor(MathSqrt(HMAPeriod)); 
def HullPeriod = floor(sqrt(HMAPeriod));

That should get you most of the way. If you have more questions, do reach out.
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

This page in the docs:
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Math---Trig/Floor
will tell you about the FLOOR() function. Floor returns the next lower integer for a given number:

6.0 --> 6
6.5 --> 6
6.999 --> 6

Since we need an integer value for the period of a moving average, and taking the square root will almost always result in a non-integer number, using the floor() function returns just the integer part and the moving average function will be happy. We like happy functions.

Code:
# HMAPeriod = MathMax(HMAPeriod);
# this is already addressed as an input value -- ToS doesn't like to redefine variables the way tradeview allows.

# HalfPeriod = MathFloor(HMAPeriod/HMASpeed);
def HalfPeriod = floor(HMAPeriod / HMASpeed));

# HullPeriod = MathFloor(MathSqrt(HMAPeriod));
def HullPeriod = floor(sqrt(HMAPeriod));

That should get you most of the way. If you have more questions, do reach out.
Thank you, good sir. I will spend some time with it this afternoon!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
404 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top