Max
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
Need Help With Color Coded MACD
Collapse
X
-
Need Help With Color Coded MACD
I've downloaded the MACDUpDn indicator which plots a different color for upticks and downticks in the histogram. What I would like to do is the same thing for the MACD plot itself. Is there anyone that would care to help me? Thanks and Best Regards
MaxTags: None
-
Originally posted by maxreturn View PostI've downloaded the MACDUpDn indicator which plots a different color for upticks and downticks in the histogram. What I would like to do is the same thing for the MACD plot itself. Is there anyone that would care to help me? Thanks and Best Regards
Max
Hi Max,
Here we go: Place this piece of code after line 78.
if (Rising(Value))
{
MacdRisingPlot.Set(1, Value[1]);
MacdRisingPlot.Set(Value[0]);
}
else if (Falling(Value))
{
MacdFallingPlot.Set(1, Value[1]);
MacdFallingPlot.Set(Value[0]);
}
else
{
MacdNeutralPlot.Set(1, Value[1]);
MacdNeutralPlot.Set(Value[0]);
}
Then in line 40, i.e: Add(new Plot(Color.Green, "Macd"));
Copy it twice below this one and change "Macd" with MacdRisingPlot, MacdFallingPlot,MacdNeutralPlot and also choose the colors you wish.
Finally in the properties Section find:
[Browsable(false)]
[XmlIgnore()]
public DataSeries Default
{
get { return Values[0]; }
}
again copy it twice, replace "Default" as above with MacdRisingPlot, MacdFallingPlot,MacdNeutralPlotand and in Values increase by one: Values[0], Values[1],Values[2].
Also, change the values that the other plots had ie Avg from [1] now [4],
2->5, 3->6 .
Cheers
-
Astra, thanks a bunch. I understand most of what you said but I'm a little confused about the last part. I understand copying the "default" twice and having MacdRisingPlot, MacdFalingPlot and MacdNeutralPlot but I'm confused about the values. If I understand you correctly you're saying to have values 0-2 for the new plots and then change all the other values correct? Also, I noticed that there are two lines of code "///Summary" before and after each piece of code in this section. Do I need to edit the code to include this before and after my new plots? Again, thanks for all your help!
Best Regards
Max
Comment
-
Originally posted by maxreturn View PostAstra, thanks a bunch. I understand most of what you said but I'm a little confused about the last part. I understand copying the "default" twice and having MacdRisingPlot, MacdFalingPlot and MacdNeutralPlot but I'm confused about the values. If I understand you correctly you're saying to have values 0-2 for the new plots and then change all the other values correct? Also, I noticed that there are two lines of code "///Summary" before and after each piece of code in this section. Do I need to edit the code to include this before and after my new plots? Again, thanks for all your help!
Best Regards
Max
Max,
Give me few minutes and I will make it ready for you. Maybe others (including myself!) will benefit as well.
If in the meantime you like to have a go (I remember how it feels when
I managed my first code in C#!), the idea is that you have to match the sequence the plots are placed under Initialize, in the properties section, starting from 0. So, the first plot under Initialize, in the properties section will be
{
get { return Values[0]; }
}
The second [1], and so on. Don't bother about the summaries, either live them or delete them.
astra
Comment
-
-
Originally posted by astra View PostMax,
Here is your requested indicator. I left the Macd as transparent in case you need the value for a strategy. Also, I have added background color (if you don't need it you can remove this line of code).
Have a nice day.
Max
Comment
-
Astra, slight problem with MACD plot
Hello Astra. I just did a visual inspection of the indicator and it appears there's a slight problem I believe is just limited to the MacdFallingPlot. For some reason in a number of cases even the the MACD plot clearly ticks down it stays th same color as MacdRisingPlot. I verified this by looking in the data window. Even though it ticks down both MacdRisingPlot and MacdFallingPlot show a value.
Regards
Max
BTW...I love the background color.
Comment
-
Originally posted by astra View PostHi Max,
I am happy to have been of help.
Best wishes,
astra
Regards
Max
BTW...I love the background color.
Comment
-
Oopps! You have right. It is fixed now. Please download it again from my previous post. The reason was that when I changed the plot name from Value to MacdPlot I overlooked to make the changes in some places. Now it should plot correctly. Thanks for telling me.
Comment
-
Originally posted by astra View PostOopps! You have right. It is fixed now. Please download it again from my previous post. The reason was that when I changed the plot name from Value to MacdPlot I overlooked to make the changes in some places. Now it should plot correctly. Thanks for telling me.
Regards
Max
Comment
-
Astra, there are still problems
Hello Astra. I downloaded and imported the revised indi and there is still a problem on several datapoints where the MACD clearly ticks down but for some reason the color stays the same as when the MACD ticks up. Any ideas? Thanks for all your help.
Regards
Max
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