Signal Smoothing feature for MACD

Hi I saw the docs and don't seem to see this feature available in the MACD Widget. Did I miss anything or can you tell me how I can implement it? thanks!


1 Reply

LP Lokesh Palani Syncfusion Team December 13, 2023 02:04 PM UTC

Hi,


We have validated your query and achieved your requirement by adding an additional axis in the SfCartesianChart using the axes property. This allows you to display the MacdIndicator by mapping the indicator's name in the yAxisName property. In this case, we have used HiloOpenCloseSeries to map the seriesName in the name property.


The MacdIndicator has shortPeriod and longPeriod options for defining the motion of the indicator. Additionally, you can choose to draw a line, histogram, or both using the macdType property.


To assist you further, we have shared a code snippet, screenshot, sample browser link, user guide documentation link and sample for your reference. You can modify the sample according to your needs. If you need any further assistance, please let us know.



SB link,

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


UG link,

https://help.syncfusion.com/flutter/cartesian-charts/technical-indicators#moving-average-convergence-divergence-macd


Code Snippet:


SfCartesianChart(

          primaryXAxis: DateTimeAxis(),

          primaryYAxis: NumericAxis(),

          axes: <ChartAxis>[

            NumericAxis(

              majorGridLines: const MajorGridLines(width: 0),

              axisLine: const AxisLine(width: 0),

              opposedPosition: true,

              name: 'yAxes',

              interval: 2,

            )

          ],

          indicators: <TechnicalIndicators<ChartSampleData, DateTime>>[

            MacdIndicator<ChartSampleData, DateTime>(

              period: 14,

              longPeriod: 5,

              shortPeriod: 2,

              signalLineWidth: 2,

              macdType: MacdType.line,

              seriesName: 'HiloOpenClose',

              yAxisName: 'yAxes',

            ),

          ],

          series: <ChartSeries<ChartSampleData, DateTime>>[

            HiloOpenCloseSeries<ChartSampleData, DateTime>(

              dataSource: _chartData,

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

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

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

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

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

              name: 'HiloOpenClose',

            ),

          ],

        )


Screenshot:




Regards,

Lokesh P.


Attachment: chart_185805_macd_indicator_66fcd5e7.zip

Loader.
Up arrow icon