Big Mike's Trading Forum
 

Go Back   Big Mike's Trading Forum

> Trading Forums > Platforms and Indicators > NinjaTrader


VIDEO TUTORIAL: How to create an advanced NinjaTrader Strategy
Started:January 26th, 2010 (04:30 AM) by Big Mike Views / Replies:37,086 / 61
Last Reply:October 18th, 2014 (02:15 PM) 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: 38,572 since Jun 2009
Thanks: 25,139 given, 58,166 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


Want my help or input?
1) Please don't PM me, instead make a post on the forum.
2) In your post, mention me by typing @Big Mike.

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

Reply With Quote
     
The following 152 users say Thank You to Big Mike for this post:
aart1, adorati, Alan, Alinghy, AnderW, arbuthnot, Arpad, Ashtreegambler, aslan, Atlasal, Autobot, autotrader8, aventeren, bagzi, Bamizo77, bd92154, BDawg, bon1025hk, boomer50usa, Buddy, bukkan, cclsys, chakspin, Cimino, Cloudy, creasy, ctbaran, dany, DaveTrading, ddspock, deadlyvenom, deandavis, devdas, doug, driver594, dsraider, DTdr2, Enalmada, engl98, evergreen, Fat Tails, firstbrain, Flash, flavs, ganamide, Gary, gary9, GaryD, GaryT, GemsBot, gracepips, gregid, GregLGTP, gretzkyless, GTNorthwest, huracan, Icehouse, im197, iPipper427, jacqudy, Jathrop Swayoza, jibe, jntdigital, JohnKK, JohnnyAustin, jonesr9, JustWondering, jwhtrades, jzbqhr, kcmotrader, kevind, kimbobm, kiro, KPreston, listu, loschle, LostTrader, maiers, MarkG, Maxwell, MBAGearhead, mea109, Mega, MetalTrade, MKaiser, mkaminski, mmather, MrDonQui, MrTrader, n0ph0bia, nanobiotech, nanook77, neilsomi, neocazimi, Nibble, nickdsc, Nientenickgrazie, NJAMC, NTrader, optimod, PaulK410, paulmc1840, piersh, project belgrade, Pwirth, raff, raj1301, RBerry, rbrk, redford007, rem4444, resirca52009, richsan, RJay, rogerbar, rsi77, rtace1, Rumann, sam028, Sammy C, Saroj, seeker, semoa, Sentenza, smithma01, sorin, soumi71, spinnybobo, spr1ngfl1ng, spsilage, srvsrv, Stem1, stephenszpak, steve2222, SteveZ, Tbax, theucreport, TomasGeissler, trader2010, Traderji, traderpards, tradesignal, Treggs, tretrader, tshunhu, 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: 38,572 since Jun 2009
Thanks: 25,139 given, 58,166 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


Want my help or input?
1) Please don't PM me, instead make a post on the forum.
2) In your post, mention me by typing @Big Mike.

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

Reply With Quote
     
The following 11 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, 116 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 6 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, 760 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
     
The following user says Thank You to MXASJ for this post:
     

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: 38,572 since Jun 2009
Thanks: 25,139 given, 58,166 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


Want my help or input?
1) Please don't PM me, instead make a post on the forum.
2) In your post, mention me by typing @Big Mike.

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

Reply With Quote
     
The following 6 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: NG, NQ, TF, CL
 
Posts: 365 since Jun 2009
Thanks: 1,086 given, 241 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, 644 views)
Reply With Quote
     
The following 11 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: 38,572 since Jun 2009
Thanks: 25,139 given, 58,166 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


Want my help or input?
1) Please don't PM me, instead make a post on the forum.
2) In your post, mention me by typing @Big Mike.

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

Reply With Quote
     
The following 2 users say 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, 760 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: 71 since Jun 2009
Thanks: 11 given, 43 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: 127 since Jun 2009
Thanks: 25 given, 48 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
     
The following user says Thank You to Treggs for this post:
     

Reply



Tags
#region, --, 00, 6e, account, ai, analysis, art, asia, automated, backtest, backtesting, basic, beginners, big mike, bot, broker, brokers, buy, c#, cbi, cd, ces, choice, close, code, coding, color, commission, compile, contracts, costs, covered, create, custom, custom tick, daily, data, dataseries, day, demo, development, don, dow, drawline, ema, entry, entry price, error, errors, es, excel, exit, expectancy, false, feed, file, fill, filled, flow, future, group, high, hma, how to, hurley, indicator, indicators, instrument, job, learn, learning, limit, limit order, line, lines, list, live, load, location, lot, manage, management, market, market replay, market_replay, math, max, minutes, ml, mode, money, moves, mtf, multicharts, multiple, multiple_time_frames, namespace, ninja, ninjascript, ninjatrader, ninjatrader strategy, note, nt, nt7, oco, optimization, optimizer, option, order, order entry, order management, orders, parameter, parameters, platform, positions, price, price_action, process, profit, profitable, programming, properties, question, realtime, red, replay, return, screen capture, script, settings, setup, simple, simulation, size, sma, small, speed, spot, start, stop, stoploss, stops, strategies, strategy, success, suggestions, summary, support, syntax, system, ta, target, targets, tax, thank you, tick, ticks, time, trade, trader, trades, trading, trailing, trailing stop, tutorial, type, ux, 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 32 August 27th, 2014 04:11 AM
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 12:58 AM.

Powered by vBulletin®
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
Copyright © 2015 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 2015-05-24 in 0.12 seconds with 20 queries on phoenix via your IP 54.82.50.27