Support Board
Date/Time: Sat, 28 Jun 2025 05:50:02 +0000
Post From: ACSIL - I do not understand how to plot a moving average
[2021-09-17 05:41:08] |
liquidsquid - Posts: 3 |
I tried this too but it is not working which is weird... Here is my code, I added the indicator without the SMA #include "sierrachart.h" SCDLLName("SmaTest") SCSFExport scsf_SmaTest(SCStudyInterfaceRef sc) { SCSubgraphRef SubgraphSMA = sc.Subgraph[0]; SCSubgraphRef SubgraphVolume = sc.Subgraph[1]; SCInputRef Input_SMAPeriod = sc.Input[0]; SCFloatArray IndicatorArray; if (sc.SetDefaults) { sc.GraphName = "Sma plot test"; SubgraphSMA.Name = "SMA"; SubgraphSMA.DrawStyle = DRAWSTYLE_LINE; SubgraphSMA.DrawZeros = true; SubgraphVolume.Name = "Volume"; SubgraphVolume.DrawStyle = DRAWSTYLE_LINE; SubgraphVolume.DrawZeros = true; Input_SMAPeriod.Name = "SMA Period"; Input_SMAPeriod.SetInt(3); sc.AutoLoop = 1; } int Indicator = sc.GetRecentAskVolumeAtPrice(sc.Ask) - sc.GetRecentBidVolumeAtPrice(sc.Bid); IndicatorArray[IndicatorArray.GetArraySize()] = Indicator; sc.SimpleMovAvg( IndicatorArray, SubgraphSMA, Input_SMAPeriod.GetInt() ); sc.Subgraph[0][sc.Index] = SubgraphSMA[sc.Index]; sc.Subgraph[1][sc.Index] = Indicator; } Here is a screenshot of my indicator and as you can see, the SMA keeps returning a 0 value... http://www.sierrachart.com/image.php?Image=163185721132.png Date Time Of Last Edit: 2021-09-17 05:41:36
|