NexusFi: Find Your Edge


Home Menu

 





Hull Moving Average Strategy


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one donmat with 6 posts (1 thanks)
    2. looks_two ABCTG with 5 posts (0 thanks)
    3. looks_3 Meytar Savir with 2 posts (0 thanks)
    4. looks_4 futuros with 1 posts (2 thanks)
    1. trending_up 8,119 views
    2. thumb_up 5 thanks given
    3. group 12 followers
    1. forum 16 posts
    2. attach_file 0 attachments




 
Search this Thread

Hull Moving Average Strategy

  #11 (permalink)
 Meytar Savir 
Tel Aviv, Israel
 
Experience: Advanced
Platform: TradeStation
Trading: Futures
Posts: 2 since Jul 2020
Thanks Given: 0
Thanks Received: 0

Hey Guys,
I want to use Hull MA in easylanguage - but when using Hull on RENKO charts or even on time based chart,
the error message is: "Tried to reference back more bars than aloowed by CurrentMaxBarsBack settings. Please increase the MaxBarBack settings".

I have been looking for it and coult not find where to change it,
I know the Hull function (HMA) uses Weighted EMA function (WAverage),
so I suppose WAvergae is using too many bars back...

I saw the attached function you added here,
But - it still uses Waverage (which I don't get why is it so problematic....)


I will appreciate help,
All the best,
Meytar

you can contact me through my Email - Savirtrade @ G M A I L. com

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
Quant vue
Trading Reviews and Vendors
How to apply profiles
Traders Hideout
Better Renko Gaps
The Elite Circle
 
  #12 (permalink)
 Meytar Savir 
Tel Aviv, Israel
 
Experience: Advanced
Platform: TradeStation
Trading: Futures
Posts: 2 since Jul 2020
Thanks Given: 0
Thanks Received: 0

Hey Guys,
I want to use Hull MA in easylanguage - but when using Hull on RENKO charts or even on time based chart,
the error message is: "Tried to reference back more bars than aloowed by CurrentMaxBarsBack settings. Please increase the MaxBarBack settings".

I have been looking for it and coult not find where to change it,
I know the Hull function (HMA) uses Weighted EMA function (WAverage),
so I suppose WAvergae is using too many bars back...

I saw the attached function you added here,
But - it still uses Waverage (which I don't get why is it so problematic....)


I will appreciate help,
All the best,
Meytar

you can contact me through my Email - Savirtrade @ G M A I L. com

Reply With Quote
  #13 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629


Meytar Savir,

the following links should get you going:

Maximum Number of Bars Study Will Reference Setting
About Strategy Properties

In case you are using Multicharts it has a similar setting on the general "Strategy Properties" dialog window.

Regards,

ABCTG


Meytar Savir View Post
Hey Guys,
I want to use Hull MA in easylanguage - but when using Hull on RENKO charts or even on time based chart,
the error message is: "Tried to reference back more bars than aloowed by CurrentMaxBarsBack settings. Please increase the MaxBarBack settings".

I have been looking for it and coult not find where to change it,
I know the Hull function (HMA) uses Weighted EMA function (WAverage),
so I suppose WAvergae is using too many bars back...

I saw the attached function you added here,
But - it still uses Waverage (which I don't get why is it so problematic....)


I will appreciate help,
All the best,
Meytar

you can contact me through my Email - Savirtrade @ G M A I L. com


Follow me on Twitter Reply With Quote
  #14 (permalink)
cadad100
Cumming
 
Posts: 1 since Jul 2020
Thanks Given: 0
Thanks Received: 0

Hi Guys,
please help
as the strategy with color displays correctly on Renko chart but buy/sell signals are displaced to right by about 2/3 bars ,
how to overcome this.

Thanks
Cadad

Reply With Quote
  #15 (permalink)
 Prototyper 
Reno Nevada
 
Experience: Intermediate
Platform: In flux
Trading: in Flux
Posts: 35 since Dec 2016
Thanks Given: 7
Thanks Received: 31

Regarding the OP's second post:

I have a similar question, possibly the same question, but stated differently:
When using the Hull MA to generate signals, ie, when HMA is postive, go long and when HMA is negative, go short, I would like to generate an indicator that plots the price that would cause the HMA to change from the current slope to the other slope.

So, for example, if currently the HMA is positive, and we are long, what is the price (below the current HMA reading) needed to cause the HMA to switch to a negative slope?

If HMA has a negative slope, and we are short, what is the price above the HMA that would cause the slope to change to positive?

This line would be below the HMA when its sloping upwards, and above the HMA when its sloping downwards. This line could represent the current stop price.

I'm not sure how to code this. I have a copy of the same code the OP has and I'm using it to plot HMA. Using MultiCharts - Easy Language

Here's an example that "predicts" the required price for a regular Moving Average. I'm looking for the same thing, but with Hull MA.

https://www.technicaltradingindicators.com/indicators-for-tradestation/predictive-moving-average-indicators-for-tradestation/

Reply With Quote
  #16 (permalink)
 futuros 
Weston, Florida, USA
 
Experience: Advanced
Platform: Ninja Trader
Trading: ES, CL, TF, 6E, GC
Posts: 47 since Oct 2010
Thanks Given: 49
Thanks Received: 49

Hi Guys, here is a HULL MA Strategy that may help some of you, the only problem with this one is that it is a LONG-only strategy, I am trying to change the code to Go-short only or both long and short but coding in EasyLanguage is not my forte, if anyone can help me turn this into a short-only strategy I'll appreciate it.

_HMA_MGStrategy (Strategy)
[Intrabarordergeneration = False]

inputs:
RSILength( 9 ), { RSI Length }
HMALength( 9 ), { Length for Hull Moving Average }
HMAPrice( Close ), { Price used in Hull Moving Average }
ExitPercent( 15 ), { percentage points, i.e., 15% is entered as 15 }
StopLossPercent( 5 ) ; { percentage points, i.e., 5% is entered as 5 }
variables:
EP( 0 ), { holds EntryPrice for the position }
MP( 0 ), { holds strategy MarketPosition }
HullMA( 0 ), { holds Hull Moving Average }
HMAForTurnUp( 0 ), { hold HMA for TurnUp determination }
RSIofHMA( 0 ),
HMATurnUp( false ),
ExitTarget( 0 ), { holds exit price for target }
StopLoss( 0 ) ; { holds stop loss price }
EP = EntryPrice ;
MP = MarketPosition ;

HullMA = _HMA( HMAPrice, HMALength ) ;
HMAForTurnUp = _HMA( HMAPrice, 4 ) ;
RSIofHMA = RSI( HullMA, RSILength ) ;

HMATurnUp = CurrentBar > 2 and HMAForTurnUp > HMAForTurnUp[1]
and HMAForTurnUp[1] <= HMAForTurnUp[2] ;
ExitTarget = Iff( MP = 1, EP * ( 1 + ExitPercent * 0.01 ),
Close * ( 1 + ExitPercent * 0.01 ) ) ;
StopLoss = Iff( MP = 1, EP * ( 1 - StopLossPercent * 0.01 ),
Close * ( 1 - StopLossPercent * 0.01 ) ) ;

{ Entry Code }
If Close > Average( Close, 50 ) and
RSIofHMA <= 50 and
Close > Close[59] and
HMATurnUp
then
Buy next bar market ;

{ EXITS }
{ RSI exit delayed for RSI calculation convergence }
If CurrentBar >= 10 * RSILength and RSIofHMA >= 90 then
Sell ( "RSI LX" ) next bar market ;

Sell ( "Target LX" ) next bar at ExitTarget Limit ; { Profit Target }
Sell ( "StopLoss LX" ) next bar at StopLoss Stop ; { Stop Loss }
===========================================
_HMA (Function)
inputs:
Price( numericseries ),
int Length( numericsimple) ;
once
if Length <= 1 then
RaiseRunTimeError( "Length must be greater than 1." ) ;

_HMA = WAverage( 2 * WAverage( Price, IntPortion( Length * 0.5 ) ) -
WAverage( Price, Length ), IntPortion( SquareRoot( Length ) ) ) ;

Reply With Quote
Thanked by:
  #17 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

Hi,

I have completed the formula by including the short as well:


{_HMA_MGStrategy (Strategy)}


[Intrabarordergeneration = False]

Inputs:
RSILength( 9 ), { RSI Length }
HMALength( 9 ), { Length for Hull Moving Average }
HMAPrice( Close ), { Price used in Hull Moving Average }
ExitPercent( 15 ), { percentage points, i.e., 15% is entered as 15 }
StopLossPercent( 5 ) ; { percentage points, i.e., 5% is entered as 5 }

Variables:
EP( 0 ), { holds EntryPrice for the position }
MP( 0 ), { holds strategy MarketPosition }
HullMA( 0 ), { holds Hull Moving Average }
HMAForTurnUp( 0 ), { hold HMA for TurnUp determination }
RSIofHMA( 0 ),
HMATurnUp( false ),
HMATurnDn( false),
ExitTarget( 0 ), { holds exit price for target }
StopLoss( 0 ) ; { holds stop loss price }

EP = EntryPrice ;
MP = MarketPosition ;

HullMA = _HMA( HMAPrice, HMALength ) ;
HMAForTurnUp = _HMA( HMAPrice, 4 ) ;
RSIofHMA = RSI( HullMA, RSILength ) ;

HMATurnUp = CurrentBar > 2 and HMAForTurnUp > HMAForTurnUp[1]
and HMAForTurnUp[1] <= HMAForTurnUp[2] ;
ExitTarget = Iff( MP = 1, EP * ( 1 + ExitPercent * 0.01 ),
Close * ( 1 + ExitPercent * 0.01 ) ) ;
StopLoss = Iff( MP = 1, EP * ( 1 - StopLossPercent * 0.01 ),
Close * ( 1 - StopLossPercent * 0.01 ) ) ;

{ Entry Buy }
If Close > Average( Close, 50 ) and
RSIofHMA <= 50 and
Close > Close[59] and
HMATurnUp
then
Buy next bar market ;

{ EXITS BUY }
{ RSI exit delayed for RSI calculation convergence }
If CurrentBar >= 10 * RSILength and RSIofHMA >= 90 then
Sell ( "RSI LX" ) next bar market ;

Sell ( "Target LX" ) next bar at ExitTarget Limit ; { Profit Target }
Sell ( "StopLoss LX" ) next bar at StopLoss Stop ; { Stop Loss }


HMATurnDn = CurrentBar > 2 and HMAForTurnUp < HMAForTurnUp[1]
and HMAForTurnUp[1] >= HMAForTurnUp[2] ;
ExitTarget = Iff( MP = -1, EP * ( 1 - ExitPercent * 0.01 ),
Close * ( 1 - ExitPercent * 0.01 ) ) ;
StopLoss = Iff( MP = -1, EP * ( 1 + StopLossPercent * 0.01 ),
Close * ( 1 + StopLossPercent * 0.01 ) ) ;

{ Entry Sellshort }
If Close < Average( Close, 50 ) and
RSIofHMA >= 50 and
Close < Close[59] and
HMATurnDn
then
Sellshort next bar market ;

{ EXITS SELLSHORT}
{ RSI exit delayed for RSI calculation convergence }
If CurrentBar <= 10 * RSILength and RSIofHMA <= 20 then
Buytocover ( "RSI SX" ) next bar market ;

Buytocover ( "Target SX" ) next bar at ExitTarget Limit ; { Profit Target }
Buytocover ( "StopLoss SX" ) next bar at StopLoss Stop ; { Stop Loss }

Reply With Quote
Thanked by:




Last Updated on January 23, 2022


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts