Big Mike's Trading Forum
 

Go Back   Big Mike's Trading Forum

> Trading Forums > Platforms and Indicators > NinjaTrader


Notices
     

VIDEO TUTORIAL: How to create an advanced NinjaTrader Strategy
Started:January 26th, 2010 (04:30 AM) by Big Mike Views / Replies:29,866 / 57
Last Reply:April 10th, 2014 (09:25 AM) Attachments:3

Welcome to Big Mike's Trading Forum.

Welcome, Guest!

This forum was established to help traders by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

BMT is fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.


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, and we will never resell your private information.

-- Big Mike
     

Reply
 3  
 
Thread Tools Search this Thread

VIDEO TUTORIAL: How to create an advanced NinjaTrader Strategy

Old January 26th, 2010, 04:30 AM   #1 (permalink)
Administrator: 'da Big Dawg
Manta, Ecuador
 
Trading Experience: Advanced
Platform: My own custom solution
Favorite Instrument: SP500, Stocks
 
Big Mike's Avatar
 
Posts: 31,117 since Jun 2009
Thanks: 20,723 given, 38,018 received

VIDEO TUTORIAL: How to create an advanced NinjaTrader Strategy

In this video tutorial I show how to create a strategy from scratch (not using the wizard, which I never use).

The strategy contains a few optimizable parameters such as SMA length, EMA length, HMA length, three different targets with custom tick settings on each, a stop size, and the option to move target 2 to breakeven after target 1 is hit, as well as move target 3 to breakeven after target 2 is hit.



The strategy is just an example! It took all of 10 minutes to write. Even though it says it made 20k in 90 days over 700 trades, it will likely fail going forward. Simple strategies are usually best, but this one is too simple to work fully automated. Most strategies I write for customers take me hours of work (this one took 10 minutes), so don't just go and copy this strategy and expect good results.

Instead, I created this so you could get your feet wet and learn some of the basics of a more advanced strategy than what Ninja includes with the base install. I also created it so if someone shows you backtest results where it makes tons of money, you can see just how easy it is to produce those results.

Also, don't forget that optimizing based on net profit is virtually worthless. I've spent two years tweaking my custom optimizer type and it considers everything you can imagine such as balanced longs/shorts, trade counts, commission costs, profit factors, expectancy, trade duration, and a bunch of other stuff I don't want to go into because I am not giving it away.

With the normal drop-down list of optimizer types in NT, you don't want to just pick the result that shows the most net profit. You should factor in as many other variables as you can. Unless you're going to do what I did with the custom optimizer, the easiest way is to dump the results to an Excel spreadsheet (feature is built-in to NinjaTrader) and then work some analysis there.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
     
The following 134 users say Thank You to Big Mike for this post:
aart1, adorati, Alan, Alinghy, AnderW, Arpad, Ashtreegambler, aslan, Atlasal, Autobot, autotrader8, aventeren, bagzi, Bamizo77, BDawg, bon1025hk, boomer50usa, Buddy, bukkan, cclsys, Cimino, Cloudy, creasy, ctbaran, dany, DaveTrading, ddspock, deadlyvenom, deandavis, devdas, doug, driver594, dsraider, DTdr2, Enalmada, engl98, evergreen, Fat Tails, firstbrain, Flash, flavs, Gary, gary9, GaryD, GaryT, GemsBot, gracepips, gregid, gretzkyless, GTNorthwest, huracan, iPipper427, jacqudy, Jathrop Swayoza, jibe, jntdigital, JohnKK, JohnnyAustin, jonesr9, JustWondering, jzbqhr, kcmotrader, kevind, kimbobm, kiro, loschle, LostTrader, maiers, MarkG, MBAGearhead, mea109, Mega, MetalTrade, MKaiser, mkaminski, mmather, MrDonQui, n0ph0bia, nanobiotech, nanook77, neilsomi, neocazimi, nickdsc, NJAMC, NTrader, optimod, PaulK410, paulmc1840, piersh, project belgrade, Pwirth, raff, raj1301, RBerry, rbrk, redford007, rem4444, resirca52009, richsan, RJay, rogerbar, rsi77, Rumann, sam028, Saroj, seeker, semoa, Sentenza, smithma01, sorin, soumi71, spinnybobo, spr1ngfl1ng, spsilage, srvsrv, Stem1, stephenszpak, steve2222, Tbax, theucreport, TomasGeissler, trader2010, Traderji, traderpards, tradesignal, Treggs, tretrader, usct, vvill, waza1960, wbear009, wdjennings, Wessel, zeller4
     

Old January 26th, 2010, 04:33 AM   #2 (permalink)
Administrator: 'da Big Dawg
Manta, Ecuador
 
Trading Experience: Advanced
Platform: My own custom solution
Favorite Instrument: SP500, Stocks
 
Big Mike's Avatar
 
Posts: 31,117 since Jun 2009
Thanks: 20,723 given, 38,018 received

This video was recorded in HD mode. Don't forget to click the bottom-right option in the video to expand to full screen, so you can see the text.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
     
The following 9 users say Thank You to Big Mike for this post:
     

Old January 27th, 2010, 02:23 AM   #3 (permalink)
Member
California
 
Trading Experience: Beginner
Platform: NinjaTrader
 
Posts: 87 since Jun 2009
Thanks: 5 given, 107 received


very nice.

a quick FYI: in NT7 (c# 3.0) you can declare your strategy/indicator properties like this if you don't care about the Math.Min part:

 
Code
			
[GridCategory("Parameters")]
public 
MAType MA1 getset; } 
saves a bit of typing...

also, there's (almost) never any need to type 'private'. it's the default and you can omit it.

Reply With Quote
     
The following 5 users say Thank You to piersh for this post:
     

Old January 27th, 2010, 06:35 AM   #4 (permalink)
Elite Member
Asia
 
Trading Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 731 received

Nice video, Mike. Thanks. I guess you are finding optimization to be a wee bit quicker in NT7 .

You mentioned that you would use the same trail stop for all contracts... but I was under the impression we had no choice.

If I code this:

 
Code
			
SetProfitTarget("Long 1a"CalculationMode.TicksTarget);
SetProfitTarget("Short 1a"CalculationMode.TicksTarget);
SetTrailStop(CalculationMode.TicksTrailStop); 
It works. I've tried something like this:

 
Code
			
SetProfitTarget("Long 1a"CalculationMode.TicksTarget);
SetProfitTarget("Short 1a"CalculationMode.TicksTarget);
SetTrailStop("Long 1a"CalculationMode.TicksTrailStopLong);
SetTrailStop("Short 1a"CalculationMode.TicksTrailStopShort); 
... but I got compiler errors which I thought meant SetTrailStop only can take two arguments (Calcmode, value).

I was trying to find a way to have different targets/stops on my shorts/longs, and using ToTime to also have different targets/stops depending on time of day.

Did I miss something obvious with SetTrail Stop?

As always, thanks for sharing your knowledge.

Reply With Quote
     

Old January 27th, 2010, 06:52 AM   #5 (permalink)
Administrator: 'da Big Dawg
Manta, Ecuador
 
Trading Experience: Advanced
Platform: My own custom solution
Favorite Instrument: SP500, Stocks
 
Big Mike's Avatar
 
Posts: 31,117 since Jun 2009
Thanks: 20,723 given, 38,018 received


MXASJ View Post
Nice video, Mike. Thanks. I guess you are finding optimization to be a wee bit quicker in NT7 .

You mentioned that you would use the same trail stop for all contracts... but I was under the impression we had no choice.

SetTrailStop is very limited. I don't use it. What I meant was coding your own trailing stop, and controlling it for each target. You also should do it on a small time frame, which means adding a second dataseries to the strategy (mtf).

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
     
The following 5 users say Thank You to Big Mike for this post:
     

Old January 27th, 2010, 10:25 PM   #6 (permalink)
Elite Member
Florida
 
Trading Experience: Intermediate
Platform: NT7
Favorite Instrument: 6E, 6J, TF, CL
 
Posts: 363 since Jun 2009
Thanks: 1,071 given, 231 received

Big Mike,

Thanks for this valuable basis for strategy writing and development.

I took the liberty to code what you demonstrated into v6.5 as I'm not yet using v7. I think every serious student of strategies should go through this exercise, partly for understanding the outline of the code as well as logic and syntax among other things.

If I may, I would like to post this for the next step of learning regarding strat writing. If you feel this shouldn't be done in this particular thread, please remove and/or place in a more appropriate location.

I'm hoping others wanting to provide additional help / suggestions will be able to share and develop this into an even more detailed or advanced code.

"gregid" has set up a new BMT community group here: https://www.bigmiketrading.com/groups/automated-strategies.html He has helped me with some issues in a Strat I'm writing involving IOrder and other advanced portions of code. I appreciated the issues you mentioned regarding CalculationMode and not using "Ticks" for this piece of code.
 
Code

SetStopLoss("target3", CalculationMode.Price, Position.AvgPrice, false);
There's alot more to be learned for optimization and limit order entry.

Looking forward to your next tutorial on Strat writing!

Kirk

Attached Files
Register to download File Type: zip MyMoneyMaker_BigMike.zip (8.2 KB, 552 views)
Reply With Quote
     
The following 8 users say Thank You to zeller4 for this post:
     

Old January 27th, 2010, 11:35 PM   #7 (permalink)
Administrator: 'da Big Dawg
Manta, Ecuador
 
Trading Experience: Advanced
Platform: My own custom solution
Favorite Instrument: SP500, Stocks
 
Big Mike's Avatar
 
Posts: 31,117 since Jun 2009
Thanks: 20,723 given, 38,018 received

zeller,

Yes, please do, and I look forward to it. I will do more videos soon, but who knows when. I have to be "in the mood"

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
     
The following user says Thank You to Big Mike for this post:
     

Old January 28th, 2010, 01:18 AM   #8 (permalink)
Elite Member
Asia
 
Trading Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 731 received

If I may, Mike...

I noted this code:

 
Code
			
SMA smav SMA(SMAlength);
EMA emav EMA(EMAlength);
HMA hmav HMA(HMAlength);
 
ManageOrders();
 
if (
Position.MarketPosition != MarketPosition.Flat) return;
 
if (
Rising(smav) && Rising(emav) && Rising(hmav))
GoLong();
else
if (
Falling(smav) && Falling(emav) && Falling(hmav))
GoShort(); 
Those first three lines have me intrigued as I've never seen that before. How does that work? Is it assigning the value SMA(SMAlength) to SMA variable (?) smav? I can see how that makes typing easier and less error prone... one would only need to type "smav" instead of "SMA(SMAlength)" in all later references to that.

Is that a correct interpretation of what you did and why you did it? I know its basic C# stuff but I'm still learning.

Thanks.

Reply With Quote
     

Old January 28th, 2010, 02:42 PM   #9 (permalink)
Elite Member
Europe
 
Trading Experience: Beginner
Platform: NinjaTrader
 
Posts: 64 since Jun 2009
Thanks: 7 given, 29 received

recorded 2:07 am

yuck!

anyways, thanks for this informative video

Reply With Quote
     
The following user says Thank You to toulouse-lautrec for this post:
     

Old January 29th, 2010, 10:08 PM   #10 (permalink)
Elite Member
Working on my LCD tan
 
Trading Experience: Advanced
Platform: NinjaTrader
 
Posts: 113 since Jun 2009
Thanks: 16 given, 41 received


Hi Mike,

Thanks for the video Just wondering if you could explain your comments on why this particular optimization gives positive results but isn't actually profitable. I have only done a little optimization (on a different trading platform) and I'm wondering what is the point of optimization if the results can be so varied?

Would your next step be to forward test an optimized strategy to ensure it works? Just interested in your work flow.

TIA

Reply With Quote
     

Reply



Tags
6e, account, ai, analysis, automated, backtest, backtesting, basic, big mike, bot, broker, brokers, c#, cd, ces, choice, close, code, coding, color, commission, compile, contracts, costs, create, custom, custom tick, daily, data, dataseries, day, demo, development, dow, ema, entry, error, errors, es, excel, exit, expectancy, feed, file, fill, filled, flow, future, group, high, hma, how to, hurley, indicator, indicators, instrument, learn, learning, limit, limit order, line, list, live, load, lot, management, market, market replay, market_replay, math, ml, mode, moves, mtf, multicharts, multiple, multiple_time_frames, ninja, ninjascript, ninjatrader, note, nt, nt7, oco, optimization, optimizer, option, order, order entry, order management, orders, parameter, parameters, platform, positions, price, price_action, profit, profitable, programming, question, replay, screen capture, script, settings, setup, simple, simulation, sma, small, speed, start, stop, stoploss, stops, strategies, strategy, support, syntax, system, ta, targets, tax, thank you, tick, ticks, time, trade, trader, trades, trading, trailing, trailing stop, tutorial, type, variable, video, xml, ym
     

Big Mike's Trading Forum > Trading Forums > Platforms and Indicators > NinjaTrader > VIDEO TUTORIAL: How to create an advanced NinjaTrader Strategy

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads
Thread Thread Starter Forum Replies Last Post
VIDEO TUTORIAL: How to create an advanced MultiCharts EasyLanguage Strategy Big Mike MultiCharts 22 March 25th, 2014 03:54 PM
VIDEO: MultiCharts vs. NinjaTrader strategy backtesting and optimization Big Mike MultiCharts 47 January 1st, 2014 09:27 PM
Anyone know of good video tutorial for C# language? whoisthere48 NinjaTrader Programming 11 April 1st, 2012 05:33 PM
Is there a video tutorial on creating a NT indicator (in 6.5)? Thanks. aquarian1 NinjaTrader 9 May 16th, 2011 05:56 PM
VIDEO TUTORIAL: How to create an advanced NinjaTrader Strategy Big Mike NinjaTrader Programming 0 January 26th, 2010 05:22 AM


All times are GMT -4. The time now is 02:34 PM.

Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
Copyright © 2014 by Big Mike Trading. 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

Page generated 2014-04-17 in 0.13 seconds with 19 queries on atlantis via your IP 54.196.196.72