![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Feb 2009
Posts: 273
Thanks: 6
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#2 | |
|
Senior Member
Join Date: Mar 2008
Posts: 142
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
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 |
|
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Feb 2009
Posts: 273
Thanks: 6
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#4 | |
|
Senior Member
Join Date: Mar 2008
Posts: 142
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
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 |
|
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Mar 2008
Posts: 142
Thanks: 0
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#6 | |
|
Senior Member
Join Date: Feb 2009
Posts: 273
Thanks: 6
Thanked 0 times in 0 posts
|
Quote:
Max |
|
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Feb 2009
Posts: 273
Thanks: 6
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Mar 2008
Posts: 142
Thanks: 0
Thanked 0 times in 0 posts
|
Hi Max,
I am happy to have been of help. Best wishes, astra |
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Feb 2009
Posts: 273
Thanks: 6
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#10 |
|
Junior Member
Join Date: Jul 2008
Posts: 28
Thanks: 2
Thanked 0 times in 0 posts
|
Hi,
very nice ,thanks astra. |
|
|
|
|
|
#11 |
|
Senior Member
Join Date: Mar 2008
Posts: 142
Thanks: 0
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#12 | |
|
Senior Member
Join Date: Feb 2009
Posts: 273
Thanks: 6
Thanked 0 times in 0 posts
|
Quote:
Regards Max |
|
|
|
|
|
|
#13 |
|
Senior Member
Join Date: Feb 2009
Posts: 273
Thanks: 6
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#14 |
|
Senior Member
Join Date: Oct 2008
Location: Dallas, TX
Posts: 682
Thanks: 0
Thanked 2 times in 2 posts
|
Screen shot?
Mike |
|
|
|
|
|
#15 |
|
Senior Member
Join Date: Mar 2008
Posts: 142
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |