Thanks
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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 judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
59 views
0 likes
|
Last Post
by DynamicTest
Today, 08:25 PM
|
||
Started by ScottWalsh, Today, 06:52 PM
|
4 responses
36 views
0 likes
|
Last Post
by ScottWalsh
Today, 07:40 PM
|
||
Started by olisav57, Today, 07:39 PM
|
0 responses
7 views
0 likes
|
Last Post
by olisav57
Today, 07:39 PM
|
||
Started by trilliantrader, Today, 03:01 PM
|
2 responses
21 views
0 likes
|
Last Post
by helpwanted
Today, 07:25 PM
|
||
Started by cre8able, Today, 07:24 PM
|
0 responses
10 views
0 likes
|
Last Post
by cre8able
Today, 07:24 PM
|
Comment