Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
170
Can I combine IGSplineSeries with IGRelativeStrengthIndexIndicator?
posted

Can I add IGRelativeStrengthIndexIndicator to a chart that has IGSplineSeries? I tried it already but it does not work. Only the IGRelativeStrengthIndexIndicator is displayed on the chart.

Parents
No Data
Reply
  • 26458
    Offline posted

    The relative strength indicator will change the range of the axis, typically to a 0-100 range. If your spline series data is above or below that range, you will not see it.
    Try using two separate Y axes, one for the spline series and one for the indicator.

    Here's a quick example of having a spline and the indicator on the same chart, but different Y axes. Note, that the data isn't very useful, as there are only a few data points. The indicator needs to have quite a bit more points to make sense. This is primarily to illustrate the approach.

        NSArray *data = @[@5, @6, @3];
        NSArray *openValues = @[@5, @16, @15,];
        NSArray *closeValues = @[@15, @6, @23];
        NSArray *highValues = @[@20, @20, @29];
        NSArray *lowValues = @[@1, @0, @5];  

        _chart = [[IGChartView alloc]initWithFrame:self.view.frame];

        _categoryHelper = [[IGCategorySeriesDataSourceHelper alloc]initWithValues:data];

        _ohlcHelper = [[IGOHLCSeriesDataSourceHelper alloc]initWithOpenValues:openValues highValues:highValues lowValues:lowValues andCloseValues:closeValues];

        [_chart addSeriesForType:[IGSplineSeries class] usingKey:@"series" withDataSource:_categoryHelper firstAxisKey:@"x" secondAxisKey:@"y"];

        [_chart addSeriesForType:[IGRelativeStrengthIndexIndicator class] usingKey:@"rsi" withDataSource:_ohlcHelper firstAxisKey:@"x" secondAxisKey:@"y2"];

        [self.view addSubview:_chart];

     

Children