Simple HMA Strategy - futures io
futures io futures trading



Simple HMA Strategy


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one honkin with 3 posts (1 thanks)
    2. looks_two Big Mike with 1 posts (1 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 Trader.Jon with 1 posts (0 thanks)
    1. trending_up 3,033 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 5 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Simple HMA Strategy

(login for full post details)
  #1 (permalink)
Melbourne, Australia
 
 
Posts: 13 since Dec 2010
Thanks: 4 given, 2 received

Hi

I am extremely new to Ninja Script, so please have a little patience with me. I want to attempt to do it without using the wizard. I based what I am doing on one of Mike's video tutorials.

Basically, I want a simple HMA strategy that enters long on rising HMA and enters short on falling HMA. Naturally, when entering long, any short position would need to be closed and vice versa. I believe that EnterLong() will do the reverse without having to first exit the short position.

I want to be able to run it through the optimiser, so want to be able to allow it to alter the HMA. My preference is to run it on a 1 day chart using HMA(40) but am happy to let the optimiser do its job.

I initially set my variable, which is the HMA:

private int hmalength = 40;

The next 2 sections look like this:

protected override void Initialize()
{
CalculateOnBarClose = true;
EntryHandling = EntryHandling.UniqueEntries;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>


protected override void OnBarUpdate()
{
EntryHandling = EntryHandling.UniqueEntries;

HMA hmav = HMA(HMAlength);

//ManageOrders();

if ((Position.MarketPosition == MarketPosition.Long) && Falling(hmav))
EnterShort();

else if ((Position.MarketPosition == MarketPosition.Short) && Rising(hmav))
EnterLong();

Lastly, under properties, I have:

[Description("")]
[GridCategory("Parameters")]
public int HMAlength
{
get { return hmalength; }
set { hmalength = Math.Max(1, value); }
}

When I compile this, I get no errors, which is always a good sign. When I open the Strategy Analyser and alter any variables, I get an error message when I select an optimisation method. The error window says:

"Unable to retrieve type intos from assembly '1f9fb650f5264307ae7d5ce95e24f7e5'
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.Module._GetTypesInternal(StackCrawlMarkstacMack)

If I run the optimisation using just the default optimization, I get no trades. In output window also shows no activity.

Can anyone say what I am doing wrong, or do I need to reinstall my NT7, as I get the same message running an optimisation on one of NTs preset strategies?

cheers

honkin

Reply With Quote

Can you help answer these questions
from other members on futures io?
What blockvolume is visible? - order processing
NinjaTrader
Automatic pattern research with NT
Elite Algorithmic NinjaTrader Trading
COTbase for quant trading?
Elite Algorithmic NinjaTrader Trading
How to implement this?
MultiCharts
MACD line not plotting after change of plot order
NinjaTrader
 
 
(login for full post details)
  #3 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,785 since Jun 2009
Thanks: 32,314 given, 97,581 received



honkin View Post
Can anyone say what I am doing wrong, or do I need to reinstall my NT7, as I get the same message running an optimisation on one of NTs preset strategies?

Well the last line means it could be any strategy causing this problem. To know for sure if it is this strategy, what you need to do is go to your Documents\NinjaTrader\bin\custom\Strategy folder, locate the .cs file for this strategy, and temporarily move it out of that folder (like to your Desktop).

Then recompile something in Ninja, and see if you still get the error using a built-in strategy.

If so, you might also look at your trace log in the Documents\NinjaTrader folder, to see if it is helpful in telling you which strategy is the problem. Otherwise you might look to remove all the custom strategies (and possibly indicators) out of your installation using the method above until you can find the one causing the problem.

Have you asked NT support for help on this?

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to Big Mike for this post:
 
(login for full post details)
  #4 (permalink)
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 183 received


honkin View Post
Hi

I am extremely new to Ninja Script, so please have a little patience with me. I want to attempt to do it without using the wizard. I based what I am doing on one of Mike's video tutorials.
//ManageOrders();

if ((Position.MarketPosition == MarketPosition.Long) && Falling(hmav))
EnterShort();

else if ((Position.MarketPosition == MarketPosition.Short) && Rising(hmav))
EnterLong();
If I run the optimisation using just the default optimization, I get no trades. In output window also shows no activity.

Can anyone say what I am doing wrong, or do I need to reinstall my NT7, as I get the same message running an optimisation on one of NTs preset strategies?

cheers

honkin

If you are short and do a enter long, I think you will only flatten ... try this ..

if ((Position.MarketPosition == MarketPosition.Short) && Rising(hmav))
ExitShort();
EnterLong();

or

if ((Position.MarketPosition == MarketPosition.Flat) && Rising(hmav))
EnterLong();

Hope it helps,
Jon

Reply With Quote
 
(login for full post details)
  #5 (permalink)
Melbourne, Australia
 
 
Posts: 13 since Dec 2010
Thanks: 4 given, 2 received


Trader.Jon View Post
If you are short and do a enter long, I think you will only flatten ... try this ..

if ((Position.MarketPosition == MarketPosition.Short) && Rising(hmav))
ExitShort();
EnterLong();

or

if ((Position.MarketPosition == MarketPosition.Flat) && Rising(hmav))
EnterLong();

Hope it helps,
Jon

cheers Jon. Not saying this is incorrect, but conflicting advice from the NT forum indicated it would actually reverse the trades.

I initially had it as you have shown, but one of the mods at the forum showed me the code as you have seen it.

cheers

honkin

Reply With Quote
The following user says Thank You to honkin for this post:
 
(login for full post details)
  #6 (permalink)
Melbourne, Australia
 
 
Posts: 13 since Dec 2010
Thanks: 4 given, 2 received


Trader.Jon View Post
If you are short and do a enter long, I think you will only flatten ... try this ..

if ((Position.MarketPosition == MarketPosition.Short) && Rising(hmav))
ExitShort();
EnterLong();

or

if ((Position.MarketPosition == MarketPosition.Flat) && Rising(hmav))
EnterLong();

Hope it helps,
Jon

Hi Jon

The same mod from NT just replied to me saying that he thinks the correct code to enable the trade to reverse is this:

"please remove your MarketPosition checks in the entry conditions then you should see it trigger trades -

if (Falling(hmav))
EnterShort();

if (Rising(hmav))
EnterLong();

"The Enter() method does reverse for you if needed"

Not really sure what he means by "The Enter () does reverse for you if needed". How does NT know what I need and why wouldn't it just flatten instead of reversing? Mmm!

Not sure, but guess I will just do some testing to see.

cheers Jon

Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > Simple HMA Strategy


Last Updated on January 4, 2011


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts