OutputAttribute "LineColor" change issue

Created at 27 May 2021, 16:06
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
ctrader.guru's avatar

ctrader.guru

Joined 19.07.2018

OutputAttribute "LineColor" change issue
27 May 2021, 16:06


Hi all,

I have a very strange problem, in the following code I intercept the value of the LineColor:

...



        private T GetAttributeFrom<T>(string propertyName)
        {
            var attrType = typeof(T);
            var property = this.GetType().GetProperty(propertyName);
            return (T)property.GetCustomAttributes(attrType, false).GetValue(0);
        }

        private void DrawBestandWorst()
        {


            if (_canDraw())
            {

                if (bestCurrency.LastValue != 0)
                {
                    
                    var myOutputBest = this.GetAttributeFrom<OutputAttribute>(bestCurrency.Currency);
                    ChartText myTextBest = IndicatorArea.DrawText("BestCurrency", "BEST » " + bestCurrency.Currency + " » " + bestCurrency.LastValue.ToString("N2"), Bars.OpenTimes.LastValue, bestCurrency.LastValue, Color.FromName(myOutputBest.LineColor));
                    myTextBest.IsInteractive = false;
                    myTextBest.FontSize = 12;
                    myTextBest.VerticalAlignment = VerticalAlignment.Center;
                    
                }

                if (worstCurrency.LastValue != 0)
                {

                    var myOutputWorst = this.GetAttributeFrom<OutputAttribute>(worstCurrency.Currency);
                    ChartText myTextWorst = IndicatorArea.DrawText("WorstCurrency", "WORST » " + worstCurrency.Currency + " » " + worstCurrency.LastValue.ToString("N2"), Bars.OpenTimes.LastValue, worstCurrency.LastValue, Color.FromName(myOutputWorst.LineColor));
                    myTextWorst.IsInteractive = false;
                    myTextWorst.FontSize = 12;
                    myTextWorst.VerticalAlignment = VerticalAlignment.Center;

                }
            }

        }


...

 

It works fine, but if I change the color in the indicator parameters this does not change, the LineColor value is not updated

Here original project 

 


@ctrader.guru
Replies

amusleh
27 May 2021, 18:36

Hi,

You can't use reflection to get the user selected value for the output attribute properties.

It will give you the default value that you set on on your code, that's how reflection works, and unfortunately right now there is no way to get the user selected values for output attribute properties programmatically.


@amusleh