Support Board
Date/Time: Sat, 28 Jun 2025 05:40:29 +0000
Post From: ACSIL - I do not understand how to plot a moving average
[2021-09-16 18:15:55] |
liquidsquid - Posts: 3 |
Hello, this might be a dumb question, however, I found it difficult to plot a moving average on a chart. I have a very simple study that calculates the diff between the last traded volume at the ask and at the bid. I am trying to make an SMA out of it, I can plot the diff (I have a DOM opened with the last volume studies), but I can't plot the SMA. #include "sierrachart.h" SCDLLName("SmaTest") SCSFExport scsf_SmaTest(SCStudyInterfaceRef sc) { SCSubgraphRef SubgraphSMA = sc.Subgraph[0]; 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 = false; Input_SMAPeriod.Name = "SMA Period"; Input_SMAPeriod.SetInt(10); } int Indicator = sc.GetRecentAskVolumeAtPrice(sc.Ask) - sc.GetRecentBidVolumeAtPrice(sc.Bid); IndicatorArray[IndicatorArray.GetArraySize()] = Indicator; sc.SimpleMovAvg( IndicatorArray, SubgraphSMA, Input_SMAPeriod.GetInt() ); } What am I doing wrong here? I tried to add things like sc.Subgraph[0][sc.Index] = SubgraphSMA; but this is not working. As far as I understand, the SMA is computed, but I can't see how I should plot it. Any help would be really appreciated! Thank you |