Need Coding Help for HMA Crossover Strategy for TS

clbradley17

Junior member
Messages
25
Likes
0
If I wanted to use the Hull Moving Average (jtHMA) for the crossover strategy instead of a simple or exponential moving average crossover strategy, what would I need to put in say 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 buy next bar after lines cross at open of bar, and SellShort if reverse, and want to be able to use the displace feature if possible to displace the jtHMAs +1, 2, or 3, going to test to see what works better. Also, is there a way to buy intrabar after crossing, and what other coding would need to be put in to use this on a 30 or 60 min. timeframe? Thanks for any help.

Curtis
 
I'll try to be clearer about what I'm looking for. 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 Language 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
 
have you looked at this basic jtHMA strategy by Atavachron?

it might give you a leg up to what you want.
 

Attachments

  • jtHMA_strategy.txt
    513 bytes · Views: 604
Here's a basic MA cross over strategy.

if you study the two, you might be able to come up with something.
 

Attachments

  • MA_X_strategy.txt
    1.1 KB · Views: 563
Thanks zt3k, I'll look at them. What do I need to change to code to if I only want to be in during session hours and out by the end of day? Thanks again.

Curtis
 
Place this after varialbles:


////////////////////////////////////////////////////
if time>930 and time< 1600 {4PM} then begin

your code............

end;

setexitonclose;

///////////////////////////////////////////////////
 
Building Winning Trading Systems with TradeStation. I have the book. If you want it, send me a message.

.
 
Top