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 algospoke, Yesterday, 06:40 PM
|
2 responses
19 views
0 likes
|
Last Post
by algospoke
Today, 07:04 PM
|
||
Started by ghoul, Today, 06:02 PM
|
3 responses
14 views
0 likes
|
Last Post Today, 06:43 PM | ||
Started by jeronymite, 04-12-2024, 04:26 PM
|
3 responses
45 views
0 likes
|
Last Post
by jeronymite
Yesterday, 10:10 PM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
7 responses
20 views
0 likes
|
Last Post Today, 06:16 PM | ||
Started by AttiM, 02-14-2024, 05:20 PM
|
10 responses
181 views
0 likes
|
Last Post
by jeronymite
Today, 06:11 PM
|
Comment