- ago
Hi,
I'd like to normalize MACD between -1 and 1. Is there somewhere I can see some code to achieve this that I can use as the starting point, please? I couldn't see anything I could use in strategy block builder or here in the discussion forum.
Thanks
0
840
Solved
4 Replies

Reply

Bookmark

Sort
Glitch8
 ( 8.38% )
- ago
#1
Here is some code that does it ...

CODE:
//create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) {          MACD macd = MACD.Series(bars.Close, 12, 26);          int last = macd.Count - 1;          int count = macd.Count;          List<Double> normalized = macd.Values.Normalize(0, 1, macd.GetLowest(last, count), macd.GetHighest(last, count));          TimeSeries ts = new TimeSeries(macd.DateTimes);          ts.Values = normalized;          PlotTimeSeries(ts, "NormalizedMACD", "MACD", WLColor.Orange); }
0
Best Answer
- ago
#2
Awesome thanks Glitch. Really appreciate your help.
0
- ago
#3
CODE:
List<Double> normalized = macd.Values.Normalize(0, 1, macd.GetLowest(last, count), macd.GetHighest(last, count));
The poster wanted the range between -1 to 1, and the above code places the range between 0 to 1. But we get the idea. Thanks for the example.

I didn't realize the TimeSeries data type had a .Values.Normalize property. It doesn't appear to be in the WL app docs, although the .Values property is mentioned. Where is ".Normalize" documented? (I'm wondering how many other "secret properties" are floating around I don't know about besides .Normalize?)
0
Glitch8
 ( 8.38% )
- ago
#4
It's an extension method for List<double> that we have not had a chance to document yet.
1

Reply

Bookmark

Sort