![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Senior Member
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
|
Can you please tell me how to program a condition to be true when the Macd "diff" has changed direction from up to down or down to up?
Thanks
Last edited by kenb2004; 09-20-2010 at 02:55 PM.
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hello Kenb2004,
You can use Rising and Falling conditions if you just want to compare the MACD value to its prior value. The following reference sample can help you set this up in the Strategy wizard condition builder: Using Rising and Falling conditions in the Strategy Wizard
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
|
I get
if (Rising(MACD(12, 26, 9).Diff) == true) but how do I compare it to the "Diff" Falling AbarAgo? Thanks |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hello Ken,
These methods only compare the current MACD value to its prior value. If you want to test a longer duration condition, you have to reference specific values to compare. if (MACD(12, 26, 9).Diff[0] > MACD(12, 26, 9).Diff[1]) //this is all rising method checks for. You work with the index [] values to specify the condition you're looking for.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
|
What you showed only creates a condition that shows Rising. I am trying to create a condition that shows a "Change in Direction". Rising is Rising whether it has changed direction or not. How do I create a condition that shows a "Change in Direction"?
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
You can specify that there was a falling condition just prior to that, by specifying the bars ago setting for the index.
if (MACD(12, 26, 9).Diff[1] < MACD(12, 26, 9).Diff[2]) //Checks if one bar back was less than 2.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
|
I tried
if (Rising(MACD(12, 26, 9).Diff) == true && Rising(MACD(12, 26, 9).Diff, 1) == false) but I got an error "No overload for method 'Rising' takes '2' arguments |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Entries per direction | Maletor | Strategy Development | 1 | 06-13-2009 06:29 AM |
| MA direction change counter | JamesF | Indicator Development | 15 | 06-11-2009 03:50 PM |
| Entries per direction | philxhong | Strategy Analyzer | 5 | 03-20-2009 10:24 AM |
| change bar color when MACD >0 or <0 | suitguy1 | Charting | 11 | 03-08-2009 07:41 AM |
| MACD with up down arrows on MACD signal line crosses | moonriver | Indicator Development | 1 | 12-03-2008 10:34 AM |