SmaIndicator in Candleseries

I use the SMAIndicator. I read that simple moving averages use period and offset.

However, there is only the option to set a period, is there another way to set offset? 


Thanks.



1 Reply

HK Hariharasudhan Kanagaraj Syncfusion Team July 12, 2023 11:19 AM UTC

Hi Bar IIan,


In SfCartesianChart, you can render the Simple Moving Average Indicator (SMA) by simple adding it to the indicators collection property. To render the SMA Indicator there is no need to assign the offset and the offset property is not available in the SMA Indicator. However, the period property is available which determines the start point for the rendering of the technical indicators.


Shared the User Guide documentation and the Sample Browser link below regarding the SMA Indicator for your reference.


UG: https://help.syncfusion.com/flutter/cartesian-charts/technical-indicators#simple-moving-average-indicatorsma.

SB: https://flutter.syncfusion.com/#/cartesian-charts/technical-indicators/sma-indicator.


Kindly refer the below code snippet:

SfCartesianChart(

  primaryXAxis: DateTimeAxis(

    majorGridLines: const MajorGridLines(width: 0),

    dateFormat: DateFormat.MMM(),

    interval: 3,

    minimum: DateTime(2016),

    maximum: DateTime(2017),

  ),

  primaryYAxis: NumericAxis(

    minimum: 70,

    maximum: 130,

    interval: 20,

  ),

  indicators: <TechnicalIndicators<ChartSampleData, DateTime>>[

    SmaIndicator<ChartSampleData, DateTime>(

      seriesName: 'Candle',

      period: 14,

      valueField: 'high',

    ),

  ],

  series: <ChartSeries<ChartSampleData, DateTime>>[

    CandleSeries<ChartSampleData, DateTime>(

      enableSolidCandles: true,

      dataSource: getChartData(),

      xValueMapper: (ChartSampleData sales, _) => sales.x,

      lowValueMapper: (ChartSampleData sales, _) => sales.low,

      highValueMapper: (ChartSampleData sales, _) => sales.high,

      openValueMapper: (ChartSampleData sales, _) => sales.open,

      closeValueMapper: (ChartSampleData sales, _) => sales.close,

      name: 'Candle',

    ),

  ],

);


Snapshot:


Also attached the sample below for your reference.


Regards,
Hari Hara Sudhan. K.


Attachment: 183396_495884c5.zip

Loader.
Up arrow icon