Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Normalising the Output of the MACD
Collapse
X
-
Bertrand, here you go.
The MACDUpDown file is the original file downloaded from this forum.
The MACDUpDownEuro file is the modified file where I included the relevant part of your MACDScale code, applied to the Euro FX (6E).
There are 2 issues:
1. The "diffArr" (Histogram) is declared as a private variable in the original MACDUpDown code and when I modify it to "public" the code works but then I get an error message regarding deserialisation when I restart Ninja.
2. The Histogram of my version (MACDUpDownEuro) plots very different values than the original MACDUpDown file. The values for the macd line and the Avg line are correct.
ThanksAttached Files
Comment
-
Laocoon,
Normalizing is a mathematical process by which you compare the current data point to the range of data points over a particular period. When you normalize something you basically remove any associated unit or scaling. When that is done you can compare the current value of a data point to the range of data points.
- You will not have the same values as the MACD indicator, b/c the units are removed.
- The NormPeriod is the lookback period to compare the current value to the range of previous (how many previous values) back.
You will only have positive values between 0 and 10.
I hope this explains some things for you.
Comment
-
Please check the file attached, minor change to subtract the correct multiplied values - looks ok to me then, have a good weekend.Originally posted by laocoon View PostBertrand, here you go.
The MACDUpDown file is the original file downloaded from this forum.
The MACDUpDownEuro file is the modified file where I included the relevant part of your MACDScale code, applied to the Euro FX (6E).
There are 2 issues:
1. The "diffArr" (Histogram) is declared as a private variable in the original MACDUpDown code and when I modify it to "public" the code works but then I get an error message regarding deserialisation when I restart Ninja.
2. The Histogram of my version (MACDUpDownEuro) plots very different values than the original MACDUpDown file. The values for the macd line and the Avg line are correct.
ThanksAttached Files
Comment
-
@Bertrand & mrlogik
I've been using the latest version published in this forum of the MACDUpDown indicator for quite some time now and it works perfectly, but it still isn't perfect because I have to create a different version for every market I trade (and adapt the multipliers in the code accordingly). There MUST be a way to avoid that since it has been done with many indicators (I'm attaching a version of the Ergodic indicator where this is the case, ie it oscillates between +10 and -10 for every market it is applied to). This makes things so much easier both visually, and also in terms of (strategy) development
I'd very much appreciate if you could point me in the right direction on how to achieve the same thing with the MACDUpDown indicator (I guess it would also benefit other members of this forum)
Thanks a lot.
PS: it is important that the original values of the standard Ninja MACD indicator (and thus of the MACDUpDown) AREN'T modified in the process, which was the case with the version submitted by mrlogik.Attached FilesLast edited by laocoon; 09-20-2010, 07:03 AM.
Comment
-
Bertrand,
Could I ask you to have a quick look at the code below, it is the Ergodic I posted yesterday, but this time not as an assembly. It is not clear to me which part of it is the "normalising" part. It would help me a lot if you could highlight it for me. I'm trying to understand the normalising process in order to be able to replicate it in the MACDUpDown indicator.
Thanks a lot.
(For space reasons, I'm only posting the relevant part of the code)
// Init user data series
closediff = new DataSeries(this);
absclosediff = new DataSeries(this);
wERG = new DataSeries(this);
wERGhist = new DataSeries(this);
wErgodic = new DataSeries(this);
this.BarsRequired = 1;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar == 0)
{
Values[0].Reset();
Values[1].Reset();
Values[2].Reset();
Values[3].Reset();
Values[4].Reset();
closediff.Reset();
absclosediff.Reset();
wERG.Reset();
wERGhist.Reset();
wErgodic.Reset();
return ;
}
else
{
closediff.Set(Close[0]-Close[1]);
absclosediff.Set(Math.Abs(Close[0]-Close[1]));
wERG.Set(WMA(WMA(absclosediff,fast),slow)[0] == 0 ? 0 : 100 * WMA(WMA(closediff,fast),slow)[0] / WMA(WMA(absclosediff,fast),slow)[0]);
wErgodic.Set(EMA(wERG,SignalLen)[0]);
Values[2].Set(50*(wErgodic[0]-wErgodic[1]));
Values[3].Set(0);
Values[4].Set(0);
if (Math.Abs(Values[2][0] - Values[2][1])>0.1)
{
if (Values[2][0]>= Values[2][1])
{
Values[3].Set(Values[2][0]);
}
else
{
Values[4].Set(Values[2][0]);
}
}
else
{
Values[4].Set(Values[4][1]);
Values[3].Set(Values[3][1]);
}
if (CurrentBar > SignalLen+fast+slow+1)
{
Values[1].Set(wErgodic[0]);
if (wErgodic[0] < wErgodic[1]) Values[0].Set(wErgodic[0]);
}
else Values[1].Set(wErgodic[0]);
}
Comment
-
Thanks for highlighting it. After comparing the code of the Ergodic and the MACDUpDown indicator, I'm afraid I won't be able to normalise the MACDUpDown according to the Ergodic normalising principle. The codes are just too different and require development skills I don't have.
Just a question here: why aren't all standard Ninja indicators (like the MACD) normalised in the first place? I'm happy to take the necessary time to dive into NinjaScript and to learn the basics of the development process (which I did), but I'm a bit frustrated when I have to devote a lot of time and effort for something that I feel should have been done by the original indicator developers. Normalised indicators make life a lot easier for all users, not just for me, so I feel it would benefit everyone if they would come normalised from the start.
Thanks
Comment
-
Thank you for the feedback - we provide the industry standard indicator implementations with our system ones, any custom normalizing logic needs to be applied afterwards then.
Have you looked into for example running an unbounded osc like the RSI on the MACD to provide the normalizing for you?
Comment
-
Thanks for your tip regarding the RSI. I haven't tried that yet because as I mentioned earlier in the thread I succeeded in normalising the output of the MACDUpDown. The only problem is that I have to adapt the multiplier for every market I trade, which means that I have many different versions of the MACDUpDown.
The only reason why this bothers me is because my custom strategy is calling the MACDUpDown and as every MACDUpDown has another name (MACDUpDownEuro, MACDUpDownNasdaq, etc) I have to create a new version of the strategy for every market, which is very inefficient.
If anyone feels generous and could help me solve this issue I'd very much appreciate it.
Comment
-
For this issue I would just make the multiplier a user defined input parameter of your custom MACD - http://www.ninjatrader.com/support/f...ead.php?t=5782
Comment
-
Bertrand,
That was a very helpful tip, thanks a lot. I modified my code accordingly and it works. The last thing I'd like to ask you is this: how can I "tell" the indicator which market it is applied to? Let me explain what I mean:
The multiplier to normalise the MACD for the Euro is 10000
The multiplier to normalise the MACD for the Yen is 1000000
Now, if I apply the MACD on a chart of the Euro, I obviously want the user defined input parameter to be 10000, whereas if I apply it on a chart of the Yen, the parameter should be 1000000.
How can I code the following: if market = Euro, then use multiplier of 10000 etc.
Thanks again for your help, it is much appreciated.
Comment
-
You're welcome, you can access the instrument on the chart with the Instrument class and then set the value as needed - http://www.ninjatrader-support.com/H...umentName.html
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
574 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
333 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment