NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 05-15-2009, 02:11 PM   #1
maxreturn
Senior Member
 
Join Date: Feb 2009
Posts: 273
Thanks: 6
Thanked 0 times in 0 posts
Default 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

Max
maxreturn is offline  
Reply With Quote
Old 05-15-2009, 07:18 PM   #2
astra
Senior Member
 
Join Date: Mar 2008
Posts: 142
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by maxreturn View Post
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

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 is offline  
Reply With Quote
Old 05-16-2009, 06:39 AM   #3
maxreturn
Senior Member
 
Join Date: Feb 2009
Posts: 273
Thanks: 6
Thanked 0 times in 0 posts
Default

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
maxreturn is offline  
Reply With Quote
Old 05-16-2009, 07:05 AM   #4
astra
Senior Member
 
Join Date: Mar 2008
Posts: 142
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by maxreturn View Post
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

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
astra is offline  
Reply With Quote
Old 05-16-2009, 07:54 AM   #5
astra
Senior Member
 
Join Date: Mar 2008
Posts: 142
Thanks: 0
Thanked 0 times in 0 posts
Default

Max,

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.
Last edited by astra; 12-08-2009 at 08:59 AM.
astra is offline  
Reply With Quote
Old 05-16-2009, 08:28 AM   #6
maxreturn
Senior Member
 
Join Date: Feb 2009
Posts: 273
Thanks: 6
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by astra View Post
Max,

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.
What Can I say Astra. HUGH ROCK! Thank you so much. I will study the code and try to brush up so I can do more of this on my own. I am a professional trader. If there's anything I can ever to do help you please let me know. God Bless!

Max
maxreturn is offline  
Reply With Quote
Old 05-16-2009, 08:41 AM   #7
maxreturn
Senior Member
 
Join Date: Feb 2009
Posts: 273
Thanks: 6
Thanked 0 times in 0 posts
Default 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.
maxreturn is offline  
Reply With Quote
Old 05-16-2009, 08:47 AM   #8
astra
Senior Member
 
Join Date: Mar 2008
Posts: 142
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Max,
I am happy to have been of help.
Best wishes,
astra
astra is offline  
Reply With Quote
Old 05-16-2009, 09:54 AM   #9
maxreturn
Senior Member
 
Join Date: Feb 2009
Posts: 273
Thanks: 6
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by astra View Post
Hi Max,
I am happy to have been of help.
Best wishes,
astra
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.
maxreturn is offline  
Reply With Quote
Old 05-16-2009, 10:14 AM   #10
primoto
Junior Member
 
Join Date: Jul 2008
Posts: 28
Thanks: 2
Thanked 0 times in 0 posts
Default

Hi,
very nice ,thanks astra.
primoto is offline  
Reply With Quote
Old 05-16-2009, 10:19 AM   #11
astra
Senior Member
 
Join Date: Mar 2008
Posts: 142
Thanks: 0
Thanked 0 times in 0 posts
Default

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.
astra is offline  
Reply With Quote
Old 05-17-2009, 06:46 AM   #12
maxreturn
Senior Member
 
Join Date: Feb 2009
Posts: 273
Thanks: 6
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by astra View Post
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.
Astra, once again...thanks for your generous help. If there's anything I can ever do for you...just let me know. God Bless.

Regards
Max
maxreturn is offline  
Reply With Quote
Old 05-17-2009, 11:35 AM   #13
maxreturn
Senior Member
 
Join Date: Feb 2009
Posts: 273
Thanks: 6
Thanked 0 times in 0 posts
Default 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
maxreturn is offline  
Reply With Quote
Old 05-17-2009, 11:48 AM   #14
ctrlbrk
Senior Member
 
Join Date: Oct 2008
Location: Dallas, TX
Posts: 682
Thanks: 0
Thanked 2 times in 2 posts
Default

Screen shot?

Mike
ctrlbrk is offline  
Reply With Quote
Old 05-17-2009, 12:24 PM   #15
astra
Senior Member
 
Join Date: Mar 2008
Posts: 142
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Max,
I 'll have a thorough look this time but I suspect that you refer to the joint points when MACD changes direction. This is a problem with the way that NinjaTrader draws the lines. Anyway, I'll come back to you soon.
astra
astra is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Midas Indicator coded by NT rretch Indicator Development 51 11-23-2011 06:18 AM
Josh...Color Coded MACD? maxreturn Indicator Development 5 05-15-2009 02:05 PM
change bar color when MACD >0 or <0 suitguy1 Charting 11 03-08-2009 07:41 AM
first successful strategy coded junkone Strategy Development 3 12-15-2008 06:02 AM
Volume Bars color-coded according to Price change Lost Trader Indicator Development 6 10-23-2007 11:15 PM


All times are GMT -6. The time now is 02:32 AM.