Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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.
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
Can you help answer these questions from other members on NexusFi?
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.
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.