Profile Picture

Error message related to displaying "double" class variable value in a chart

Posted By tdonnelly 3 Years Ago

Error message related to displaying "double" class variable value in a...

Message
Posted Monday December 08 2014
Hi - in a trading system that ran fine previously, I've been displaying these two different SMA values in a chart: 

_fastSMA.ChartSettings.Color = Color.Red;
_slowSMA.ChartSettings.Color = Color.Blue;

Ok, so now I want to do the same thing for these two stop values below:

shortStop.ChartSettings.Color = Color.Orange;
longStop.ChartSettings.Color = Color.Green;

Please note that "shortStop" and "longStop" are both properly defined as class variables, and they function properly in the system in terms of calculating the correct stop values for short and long positions. The issue is just that I'm unable to display them in a chart. 

The error message I'm getting at compile time is "double does not contain a definition for chart settings, and no extension method 'ChartSettings' accepting a first argument of type 'double' could be found"
As I noted above, "shortStop" and "longStop" are defined as class variables, of the "double" type. So it appears that there's a type issue with displaying these two values in a chart. 

Can someone please explain what's going wrong, as well as how to fix it?

Many thanks. 


Posted Monday December 08 2014
A double is just a number.  You need a series to display it on a chart.  For your case, the simplest thing to do is probably define two class variables of type UserSeries, and each time you calculate the longStop or shortStop, set the current value of the corresponding series.  The series will have a ChartSettings property which you can use to control if and how they are displayed on the chart.

Thanks,
Daniel
Posted Wednesday December 10 2014
Thanks, Daniel. I defined and initialized the UserSeries class values, and then inserted them in the code (modifying them with the "Current" suffix) where needed. It worked great. 

It's good to know how to use this customized, user-defined, class -- I can see it being quite useful in the future. 

I think what confused me is that the SMA class worked fine on its own (in terms of being able to display it natively in a chart) -- and, of  course, a SMA value is at any one time a single value. But then looking more closely at its inheritance in the documentation, SMA appears to derive from a series-based class. 

Best,

Terence


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems