NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 12-17-2009, 04:12 AM   #1
jp2890
Member
 
Join Date: Dec 2009
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
Default MACD strategy

How to set up a strategy using MACD (12,26,9)?
jp2890 is offline  
Reply With Quote
Old 12-17-2009, 07:35 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

jp2890,

You can use the MACD in the Condition Builder of the Strategy Wizard. Suggest you take a look at this tutorial: http://www.ninjatrader-support.com/H...tml?Overview34
NinjaTrader_Josh is offline  
Reply With Quote
Old 12-17-2009, 08:25 AM   #3
jp2890
Member
 
Join Date: Dec 2009
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
Default

Success!

Some questions:

1. What is look back period?

2. Can I use "second" instead of "minute" as time interval?

3. Is Zero lag MACD available? Any code available?

Thank you Josh.
jp2890 is offline  
Reply With Quote
Old 12-17-2009, 08:42 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

jp2890,

1. Depends under what context you are talking about. If you are talking about CrossAbove/Below, it determines the two data points to check. It looks at the values at two points in time, the first point in time is the most recent bar, the second being whatever the lookback period is set to.

2. Time intervals are determined by what kind of chart you ultimately run on. If you run on a 1min chart, it uses 1min. If you run on a 30 second chart, it will use that.

3. You can try going through the file sharing second for Zero lag indicators to see if you find what you want.
NinjaTrader_Josh is offline  
Reply With Quote
Old 12-21-2009, 06:20 PM   #5
jp2890
Member
 
Join Date: Dec 2009
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
Default

I would like to use the Strategy Analyser to optimize the MACD parameters.

What should I enter in the optimize box: parameters, myinput0, min, max value?

What is Myinput0?

Thanks!
jp2890 is offline  
Reply With Quote
Old 12-22-2009, 08:10 AM   #6
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
Default

jp, MyInput0 is the first variable that gets generated when creating a strategy. Unless you've included MyInput0 in your calculations, you can ignore it.

The other values you ask about are just like they seem, the low is the lowest value the optimizer will try up to high, the highest value. The other parameter is the "skip" value, which is the increment the optimizer will go from low to high by. So if the low is 9 and the high is 25 and the increment is 5 (9,25,5), the iterations tested will be 9, 14, 19, 24.
NinjaTrader_Austin is offline  
Reply With Quote
Old 12-22-2009, 06:05 PM   #7
jp2890
Member
 
Join Date: Dec 2009
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks Austin,

Since MACD has three value, say (12,26,9), in fact which value it is optimizing each time?

Where to set which value it is optimizing?

Can I optimizing three values at the same time?

Merry Christmas!
jp2890 is offline  
Reply With Quote
Old 12-23-2009, 08:08 AM   #8
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
Default

JP, it optimizes the value you tell it to. You can select these values from the optimize window, after maximizing the parameters section. Yes, it is also possible to optimize all three at the same time.
Attached Images
File Type: jpg optimize.JPG (31.5 KB, 38 views)
NinjaTrader_Austin is offline  
Reply With Quote
Old 12-23-2009, 08:26 AM   #9
jp2890
Member
 
Join Date: Dec 2009
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks Austin,

I understand the case of SMA crossover i.e. fast and slow value.

For a MACD optimzation, where to specify which particular value to optimize, i.e. the MACD value, Ave and Diff.

Thanks.
jp2890 is offline  
Reply With Quote
Old 12-23-2009, 08:37 AM   #10
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
Default

JP, the optimize process is exactly the same for any strategy. If you've created the MACD strategy to be optimized, it is possible the inputs haven't been "exposed", thus they can't be optimized. In your code, the inputs for the MACD must be variables in order for the strategy analyzer to be able to optimize it. Please see the attached screenshots to see where to put what.
Attached Images
File Type: jpg parameters.JPG (25.1 KB, 37 views)
File Type: jpg code.JPG (14.4 KB, 40 views)
File Type: jpg inputs.JPG (31.5 KB, 39 views)
NinjaTrader_Austin is offline  
Reply With Quote
Old 12-23-2009, 09:15 AM   #11
jp2890
Member
 
Join Date: Dec 2009
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks Austin,

Not too understand what steps follow screenshot 3.

Is there any help menu related to this?
jp2890 is offline  
Reply With Quote
Old 12-23-2009, 09:18 AM   #12
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
Default

JP, indeed there is a help guide article for this. Optimizing a strategy.
NinjaTrader_Austin is offline  
Reply With Quote
Old 12-23-2009, 09:45 AM   #13
jp2890
Member
 
Join Date: Dec 2009
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks Austin,

The critical step is to "expose" the inputs. Understand.

Merry Christmas!
jp2890 is offline  
Reply With Quote
Old 02-02-2010, 08:30 AM   #14
jp2890
Member
 
Join Date: Dec 2009
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
Default

I would like to set a strategy with MACD cross over as entry. Can I use certain points (say 10 points profit) as exit?

If yes, how to write the exit setting?

Thanks!
jp2890 is offline  
Reply With Quote
Old 02-02-2010, 08:38 AM   #15
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

You enter the stops and targets in the wizard's dedicated section to this -

http://www.ninjatrader-support.com/H...egyWizard5.png

For 10 pts on the ES for example just enter 40 ticks.
NinjaTrader_Bertrand is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What about MACD X Over evensteven Suggestions And Feedback 2 02-27-2011 10:47 AM
Help with MACD strategy tomonly23 Automated Trading 8 02-10-2010 02:05 AM
MACD with up down arrows on MACD signal line crosses moonriver Indicator Development 1 12-03-2008 10:34 AM
Simple MACD Strategy Problem diamondpearl Strategy Development 13 12-02-2008 10:35 AM
Using MACD.avg vs. MACD Jim-Boulder Strategy Development 1 05-23-2007 07:41 AM


All times are GMT -6. The time now is 12:09 PM.