Oscillator fixed height and dynamic levels.

Created at 10 Apr 2019, 16:11
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!
GA

gakazas

Joined 08.09.2018

Oscillator fixed height and dynamic levels.
10 Apr 2019, 16:11


Hi! I have 2 issues that I cannot aproach.

First is I want to set a fixed height for my Oscillator. The closest to what I need is 

IndicatorArea.SetYRange(-120, 20);

The problem with the above is that when I scroll the chart the the Oscillator automatically resizes and when I stop scrolling then it fixes itself back into place. I want it to stay fixed when scrolling aswell. I tried to place the above code both on  Calculate() and on  Initialize() with no luck. I also tried Autorescale = false as shown below but it had no effect.

[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None, AutoRescale = false)]

My second issue is that I have Levels in my indicator that I need to set after the initialization as they depend on user set parameters. So [Levels()] before the class doesn't help. I ended up doing this on Initialize():

IndicatorArea.DrawHorizontalLine("Oversold level", levelOs, "MediumOrchid", 1, LineStyle.DotsRare);
IndicatorArea.DrawHorizontalLine("Overbought level", levelOb, "MediumOrchid", 1, LineStyle.DotsRare);

which is not what I want, as the numbers of the levels don't appear at the right. Is there any way to do this?

Thanks for the help.


@gakazas
Replies

gakazas
10 Apr 2019, 16:16

I aproach the second issue with the following "hack", but there must be something better.

 

public class indicator: Indicator
{
        [Output("Limit 1", PlotType = PlotType.Line, LineColor = "00FFFFFF")]
        public IndicatorDataSeries Limit1 { get; set; }
        [Output("Limit 2", PlotType = PlotType.Line, LineColor = "00FFFFFF")]
        public IndicatorDataSeries Limit2 { get; set; }
}

public override void Calculate(int index)
{
            Limit1[index] = 20;
            Limit2[index] = -120;
}


 


@gakazas