NexusFi: Find Your Edge


Home Menu

 





Strategy Help


Discussion in NinjaTrader

Updated
    1. trending_up 1,728 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 4 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
 
gretzkyless's Avatar
 gretzkyless 
Chicago, IL/USA
 
Experience: Intermediate
Platform: Ninja Trader
Broker: AMP Trading - CQG/ThinkorSwim
Trading: Futures
Posts: 30 since Jan 2013
Thanks Given: 13
Thanks Received: 19

Hello everyone. I'm pretty new to this site and from what I have found, this is a pretty good site to learn how to develop your own code. I have attached a very simple code that I created through Ninjatrader's Ninjascript editor using the slow moving average to trigger into a trade. I'm just trying to get a feel for how code looks and was surprised when I back-tested and saw that I wasn't triggered into a trade everytime the moving averages crossed. Additionally, the trailing stop doesn't seem to be working correctly either. I have attached the unlocked code here for any help you can provide.

Here is what I'm trying to accomplish with this strategy:

Get triggered into a trade when the small trigger lines cross above/below and the large trigger lines cross above/below each other. If filled, the have exit at 10 ticks and the second have a trailing stop of 15 ticks with a 50 tick profit target.

The other problem I'm having, which I think additional code would need to be written to do this, is to not reverse a trade I'm in even though the slow and fast cross. I know there will be resting periods before the trend continues and don't want to have extra trades triggered. Basically, I would like to cut out the noise when the instrument is clearly moving one direction. First trying to get the code correct for the first part. Any help would be greatly appreciated. Thanks.


Attached Files
Elite Membership required to download: AutoTradeStrategy1.cs
Follow me on X Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Iran Ceasefire Surges to 19.5% on US 15-Point Plan -- 82 …
Prediction Markets & Event Contracts
Penalties in Budapest, Peace Deadline in Tehran: Arsenal …
Prediction Markets & Event Contracts
Trump Truth Social Fires Hormuz From 10% to 59% -- Arsen …
Prediction Markets & Event Contracts
Topstep Acquires The Futures Desk -- Prop Firm Consolida …
Funded Trading Evaluation Firms
Tradeify 3.0 Overhauls Futures Prop Firm Model -- One-Ti …
Funded Trading Evaluation Firms
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 
gretzkyless's Avatar
 gretzkyless 
Chicago, IL/USA
 
Experience: Intermediate
Platform: Ninja Trader
Broker: AMP Trading - CQG/ThinkorSwim
Trading: Futures
Posts: 30 since Jan 2013
Thanks Given: 13
Thanks Received: 19


ok. figured out first part, on to second part.


Follow me on X Started this thread Reply With Quote
  #4 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,557

Please use this thread only instead of double/cross posting.

Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
  #5 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,557

There is a great deal of strategy code on the forum, but almost all of it is in Elite section. You can look at the Elite Automated forums for group projects and code, and the Battle of the Bots thread. Within those threads will be dozens and dozens of examples for trade management.

Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote




Last Updated on January 24, 2013


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts