Thanks
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Macd Diff Change Direction
Collapse
X
-
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 WizardRyan M.NinjaTrader Customer Service
-
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
Comment
-
I tried the following:
//Condition set 7
if (Macd(Fast, Slow, Smooth).Diff[1] > Macd(Fast, Slow, Smooth).Diff[2]
&& Falling(Macd(Fast, Slow, Smooth).Diff) == true)
{
DrawTriangleDown("My triangle down" + CurrentBar, false, 0, (Macd(Fast, Slow, Smooth).Diff[0]) * (1 + 2), Color.Red);
}
It compiled but did not display. When I added condition 7 only an empty panel displayed.
Last edited by kenb2004; 09-21-2010, 09:08 AM.
Comment
-
I tried the following and only got a blank panel. I'm trying to get a conditon that watches for a Diff Direction Change, from up to down Or down to up. I'm thinking that the Rising Method isn't the best way to ackomplish this. What do you think?
//Condition set 7
if (Macd(Fast, Slow, Smooth).Diff[1] > Macd(Fast, Slow, Smooth).Diff[2]
&& Falling(Macd(Fast, Slow, Smooth).Diff) == true)
{
DrawArrowDown("My down arrow" + CurrentBar, false, 0, (Macd(Fast, Slow, Smooth)[0]) * (1 + -6), Color.Red);
//DrawTriangleDown("My triangle down" + CurrentBar, false, 0, Diff[0] + .4 * TickSize, Color.Red);
//DrawTriangleDown("My triangle down" + CurrentBar, false, 0, (Macd(Fast, Slow, Smooth).Diff[0]) + .4 * TickSize, Color.Red);
}
Last edited by kenb2004; 09-21-2010, 11:06 AM.
Comment
-
Yes. _KenMac2 is the name of the script. It works fine until the I put in the code you suggested.
I also put in the following and it works fine:
if (CrossAbove(_KenMac(Fast, Slow, Smooth).Diff, 0.001, 1))
Error on calling the 'OnBarUpdate' method for indicator '_KenMac2' on bar 0: Index was out of range. Must be non-negative and less than the
Parameter name: index
9/21/2010 12:23:34 PM Strategy Starting NinjaScript strategy
Comment
-
Hi Ken,
You will need to follow this article about accessing invalid objects:
Make sure you have enough bars in the data series you are accessing
To resolve, you can add a CurrentBar check for the highest index [ ] value in your script.
if (CurrentBar < 2)
return;Ryan M.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
672 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
379 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
111 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
575 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
582 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment