Hi, I'm looking into the possibilities of Multicharts.NET and for a better understanding on how to program in it, I had a go at converting the TTM Squeeze indicator from an easylanguage-version I found on the net.
I've got the indicator almost working, but I encounter a strange issue when referring to the previous bar of the dataseries returned by the "LinearRegValue" function. I use it to determine the coloring in the Momentum Oscillator histogram, but as the previous value is not correct the wrong color is chosen from time to time.
You can see it in the picture below: the momentum is still rising, yet the color for falling momentum is used.
The current version of the indicator is attached below. If someone with more experience could have a look and check what I did wrong? The issue arises in the CalcBar-method in the "Part 2" section. Was the way I've implemented the LinRegValue function correct? Any other suggestions for improvement?
One other thing that is not clear to me is why different helper-functions have to be called in different ways. I.e. AvgTrueRange.AverageTrueRange(this, Length) is a static function, Bars.Close.StandardDeviationCustom(Length, 1) is a DataSeries-method, highestFc, lowestFc, xAverage and linRegValue are separate powerlanguage.net functions and all use different naming conventions for their parameters. Is there an overview of what functions are available and how to use them?
Issue with incorrect value of previous bar in data serie
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Issue with incorrect value of previous bar in data serie
Hello vincat,
In order to reference previous values you need to use Series variables. More information can be found here. Please find the fixed version of the code attached.
In order to reference previous values you need to use Series variables. More information can be found here. Please find the fixed version of the code attached.
- Attachments
-
- TTM_Squeeze_fix.pln
- (2.03 KiB) Downloaded 492 times
Re: Issue with incorrect value of previous bar in data serie
Hello Henri,
Thank you for the quick reply, the coloring looks ok now. Time to do the final polishing.
So if I understood the issue correctly, the function LinearRegValue() recalculates it's historical values on each new bar? I guess I'll need some extra experimenting to fully understand the internals.
Thank you for the quick reply, the coloring looks ok now. Time to do the final polishing.
So if I understood the issue correctly, the function LinearRegValue() recalculates it's historical values on each new bar? I guess I'll need some extra experimenting to fully understand the internals.
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Issue with incorrect value of previous bar in data serie
That is not correct. LinearRegValue is a simple function. It does not have historical values. In order to preserve the historical values of this function you need to assign them to a series variable. It will keep all of the assigned values.So if I understood the issue correctly, the function LinearRegValue() recalculates it's historical values on each new bar?