Welcome to the Traders Laboratory Forums.
Automated Trading Black box systems, strategy automation, algorithmic trading, etc...

Reply
Old 02-08-2009, 09:00 AM   #1

Join Date: Jul 2008
Location: Valdosta, GA
Posts: 48
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Need Help with Hull MA Crossover Strategy

If I wanted to use the Hull Moving Average (jtHMA) for a crossover strategy instead of a simple or exponential moving average crossover strategy, how would it be coded in Easy Langurage for a fast length jtHMA(10) and a slow length jtHMA (20) with parameters that if fast avg jtHMA crosses above slow avg jtHMA then BuyLong 100 shares next bar at market, and SellShort if reverse, and would like to be able to displace the jtHMAs + or -1, 2, or 3, and will be using this on a 30 or 60 min. timeframe?

Also, is it possible, or even necessary, to put within the strategy a buy/sellshort order with a pre-set stoploss? Possibly something like:

If conditions are met for fast jtHMAavg crosses slow jtHMAavg, then begin;
buy/sellshort 100 shares next bar at market;
SetProfitTarget(1000);
SetStopLoss( 100);
end;

This is going to be my first time using a strategy, and want to backtest it, haven't tried that and not sure how to figure it in for possible flaws and slippage for backtesting in tradestation. I'm going to use it on a 2x or 3x Proshares or Direxion index fund, and the position will reverse immediately when the jtHMAs cross on the next bar after the cross, from long to sellshort, or vice-versa. Not sure if that brings more problems, the instant reversal.


Thanks for any help.

Curtis
clbradley is offline  
Reply With Quote
Old 02-08-2009, 10:02 AM   #2

Blu-Ray's Avatar

Join Date: Nov 2006
Location: England
Posts: 508
Ignore this user

Thanks: 164
Thanked 292 Times in 105 Posts

Re: Need Help with Hull MA Crossover Strategy

Quote:
Originally Posted by clbradley »
If I wanted to use the Hull Moving Average (jtHMA) for a crossover strategy instead of a simple or exponential moving average crossover strategy, how would it be coded in Easy Langurage for a fast length jtHMA(10) and a slow length jtHMA (20) with parameters that if fast avg jtHMA crosses above slow avg jtHMA then BuyLong 100 shares next bar at market, and SellShort if reverse, and would like to be able to displace the jtHMAs + or -1, 2, or 3, and will be using this on a 30 or 60 min. timeframe?

Also, is it possible, or even necessary, to put within the strategy a buy/sellshort order with a pre-set stoploss? Possibly something like:

If conditions are met for fast jtHMAavg crosses slow jtHMAavg, then begin;
buy/sellshort 100 shares next bar at market;
SetProfitTarget(1000);
SetStopLoss( 100);
end;

This is going to be my first time using a strategy, and want to backtest it, haven't tried that and not sure how to figure it in for possible flaws and slippage for backtesting in tradestation. I'm going to use it on a 2x or 3x Proshares or Direxion index fund, and the position will reverse immediately when the jtHMAs cross on the next bar after the cross, from long to sellshort, or vice-versa. Not sure if that brings more problems, the instant reversal.


Thanks for any help.

Curtis

Curtis


You mention you would like to displace 1,2 or 3...... the displace feature is only affected on where to plot the lines..... the actual real time values are the same, all the displace feature does is move the lines back x amount of bars.

With regards to your strategy, here's a code that should get you started...

Inputs:
FastLength(10), SlowLength(20);

Vars:
FastAvg(0),SlowAvg(0);

FastAvg = jTHMA(Close,FastLength);
SlowAvg = jTHMA(Close,SlowLength);


If FastAvg crosses above SlowAvg then
buy 100 shares next bar at market;

If FastAvg crosses below SlowAvg then
sellshort 100 shares next bar at market;


SetProfitTarget(1000);
SetStopLoss( 100);



Hope this helps

Blu-Ray
__________________

“ Search is the ultimate expression of the power of the individual, using a computer, looking at the world, and finding exactly what they want ” – Eric Schmidt, Google
Blu-Ray is offline  
Reply With Quote
Old 02-08-2009, 10:36 AM   #3

Join Date: Jul 2008
Location: Valdosta, GA
Posts: 48
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Re: Need Help with Hull MA Crossover Strategy

Thanks so much...headed to work, but I'll try and test it when I get home tonight.

Curtis
clbradley is offline  
Reply With Quote
Old 02-09-2009, 06:29 AM   #4

Join Date: Jul 2008
Location: Valdosta, GA
Posts: 48
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Re: Need Help with Hull MA Crossover Strategy

Thanks again, Blu-Ray. Do I need to put in anything to state if I want this to repeat buy/sellshort order on a daily timeframe or 60 minute timeframe? No need to use (end at the end? Thanks for any more info, especially on the time issue.

Curtis
clbradley is offline  
Reply With Quote
Old 02-09-2009, 05:48 PM   #5

Blu-Ray's Avatar

Join Date: Nov 2006
Location: England
Posts: 508
Ignore this user

Thanks: 164
Thanked 292 Times in 105 Posts

Re: Need Help with Hull MA Crossover Strategy

Quote:
Originally Posted by clbradley »
Thanks again, Blu-Ray. Do I need to put in anything to state if I want this to repeat buy/sellshort order on a daily timeframe or 60 minute timeframe? No need to use (end at the end? Thanks for any more info, especially on the time issue.

Curtis
Hi Curtis

The code will work on any timeframe, just insert the strategy onto the relevant chart and it will work.

There's no need to use the word "end" on that code, you only use the word end if the true/ false condition is to specify more than one outcome and then you would have to use the word "begin" as well.

Here's an example.....

This is to specify only one outcome.... to plot something

If FastAvg crosses above SlowAvg then
Plot1(High,"Long");

_________________________ ______________________

This is to specify two outcomes... to plot & also to alert.

If FastAvg crosses above SlowAvg then begin
Plot1(High,"Long");
Alert("CrossOver Long");
end;


Hope this helps

Blu-Ray
__________________

“ Search is the ultimate expression of the power of the individual, using a computer, looking at the world, and finding exactly what they want ” – Eric Schmidt, Google
Blu-Ray is offline  
Reply With Quote
Old 02-12-2009, 05:07 AM   #6

Join Date: Jul 2008
Location: Valdosta, GA
Posts: 48
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Re: Need Help with Hull MA Crossover Strategy

Thanks again so much Blu-Ray, they've been working me to death this week, and haven't had any time off. I don't know why I thought that you had to specify if it was on a 15, 30, 60 minute, or daily basis in the code. If I wanted to have the trade for just during the session 9:30-4 Eastern Standard Time and end at the end of day each day instead of holding overnight, what would be required? I have a couple others that look good, one with a simple moving average crossover, and the other with an exponential crossover, so should I just replace
FastAvg = jTHMA(Close,FastLength);
SlowAvg = jTHMA(Close,SlowLength);
with SMA or EMA, instead of jtHMA?

Thanks again for all your help.

Curtis
clbradley is offline  
Reply With Quote
Old 02-12-2009, 08:20 AM   #7

Blu-Ray's Avatar

Join Date: Nov 2006
Location: England
Posts: 508
Ignore this user

Thanks: 164
Thanked 292 Times in 105 Posts

Re: Need Help with Hull MA Crossover Strategy

Quote:
Originally Posted by clbradley »
Thanks again so much Blu-Ray, they've been working me to death this week, and haven't had any time off. I don't know why I thought that you had to specify if it was on a 15, 30, 60 minute, or daily basis in the code. If I wanted to have the trade for just during the session 9:30-4 Eastern Standard Time and end at the end of day each day instead of holding overnight, what would be required? I have a couple others that look good, one with a simple moving average crossover, and the other with an exponential crossover, so should I just replace
FastAvg = jTHMA(Close,FastLength);
SlowAvg = jTHMA(Close,SlowLength);
with SMA or EMA, instead of jtHMA?

Thanks again for all your help.

Curtis
Hi Curtis

You just need to insert a start & endtime to the code.... so it would like this....

Inputs:
FastLength(10), SlowLength(20), StartTime(0930),EndTime( 1600 );

Vars:
FastAvg(0),SlowAvg(0);

FastAvg = jTHMA(Close,FastLength);
SlowAvg = jTHMA(Close,SlowLength);

If Time > StartTime and Time < EndTime then begin

If FastAvg crosses above SlowAvg then
buy 100 shares next bar at market;

If FastAvg crosses below SlowAvg then
sellshort 100 shares next bar at market;

end;


SetProfitTarget(1000);
SetStopLoss( 100);

SetExitOnClose;



With regards to changing the type of moving average, yes just replace the jTHMA with xaverage for EMA or average for SMA.

Hope this helps

Blu-Ray
__________________

“ Search is the ultimate expression of the power of the individual, using a computer, looking at the world, and finding exactly what they want ” – Eric Schmidt, Google
Blu-Ray is offline  
Reply With Quote
Old 02-15-2009, 07:37 PM   #8

Join Date: Jul 2008
Location: Valdosta, GA
Posts: 48
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Re: Need Help with Hull MA Crossover Strategy

Finally got another day off and once again you have fantastic advice and help. I need to put these strategies into TS now and backtest them. Thanks again for all you have done with this.

Curtis
clbradley is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Creating a 9/30 Crossover Paintbar Indicator Disco Scottie Coding Forum 3 12-13-2010 04:38 AM
Hull Moving Average Strategy Minetoo Trading Indicators 25 07-02-2009 05:23 PM
DMI Crossover for Charts, Radarscreen clbradley Coding Forum 4 01-29-2009 09:18 AM
Hull MACD Minetoo Coding Forum 12 11-07-2007 04:10 PM
MACD with Hull Moving Averages Soultrader Trading Indicators 2 09-06-2007 05:52 PM

All times are GMT -4. The time now is 05:48 AM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.