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 wish i knew enough code to contribute something here. I could program in Trade Station but ninja has me scratching my head. I'm trying to build a simple strategy that can buy or short on a tick above/below an adjacent bar, when it is above or below 2 ma's. I do manually and am missing some ticks. If anyone could get me started, I'd be very grateful.
Happy trading
Can you help answer these questions from other members on NexusFi?
hi SPMCC,
i think you mean a MA-cross as entry-trigger, is this right ?
can you post us a screenshot of your chart with this setup marked to understand what you mean ?
If you dont know how to code with c#, have you tired it with the ninja strategy-wizard yet ?
have you checked the MA-cross-startegy-example that you have native in your NinjaTrader yet ?
if not, these are some good ways to start this project !
Thanks for the replies. What I do manually is wait until 2 or more MA's cross, then wait for a HH or LL. In tradeStation, for longs, I could buy on the next bar's tick above the prev H, or even let it come back a tick or 2, run my stops. But in ninja, I sort of mmade it work via Wizard - but the Wizard is a little sneaky.
Sounds like a moving average crossover. What indicator or chart pattern are you using for confirmation? I assume you mean HH to be Higher High and LL to mean Lower Low...
There is a moving average cross over script on the NT support site. As for your HH and LL you could submit a stop entry order based on the High or Low of the current or last bar.
I would "test" this condition set carefully before I spent a lot of time coding it. I have worked with MA crossovers before and for me they were not very reliable.
When I've experiment with MA crossovers I've discovered two inherent problems. First, the lag built into most MA's cause issues of missing good entry points. So the trick seems to be to use the lag to your advantage. For example, combining a slow MA like SMA 50 with a faster MA like HMA 16 yields the best results.
Secondly, Ninja strategies only work "on bar close". So if you're trading out of the high of the previous bar (or bars), then you have to wait until the current bar closes. This really messes up a lot of good strategies. For example, if the previous high was 1100 and you want to go long at 1102 then you have a problem. The current bar must trade to 1102 and then close before an entry is made.
You almost have to have 2 charts that "talk to each other" to make the strategy viable. One chart would be short term and the other longer term.
Strategies can use the OnMarketUpdate instead of OnBarUpdate.
I also have use a Stop entry order as well. When the current bar closes and my entry conditions have been met but I want to be sure the market is actually moving in the anticipated direction I will set a StopEntry order rather than a Market Order.
I've had trouble making OnMarketUpdate work with Ninja, but that could just my my system. Maybe I need to go back and see if I can get it to work properly because it would surely change my way of approaching a strategy. Especially for back testing.
When entering, I like to use a stop as a means of entering as well.
Are you using NT7? I'm still on v6.5. I looked into OnMarketUpdate and couldn't find it listed in the NT support helpguide. Or maybe I need to use a different link for current methods. If you have a link, please provide.
I've tried stop entries and may just need a little tweaking for error handling. Sometimes I've let my strat run during the night just to test operation and find that it has submitted orders that were subsequently rejected which then stopped the strat.
Do you have a sample of this portion of the code that you could share?