#include "sierrachart.h" SCDLLName("RangeIndicator") /*==========================================================================*/ SCSFExport scsf_RangeIndicator(SCStudyInterfaceRef sc) { SCSubgraphRef SR = sc.Subgraph[0]; SCSubgraphRef RI = sc.Subgraph[1]; SCSubgraphRef W = sc.Subgraph[10]; SCInputRef Period = sc.Input[0]; SCInputRef SmoothPeriod = sc.Input[1]; if (sc.SetDefaults) { sc.GraphName = "RangeIndicator"; sc.AutoLoop = true; sc.FreeDLL = 0; SR.Name = "Range"; RI.Name = "Average"; Period.Name = "Period"; Period.SetInt(14); Period.SetIntLimits(1, 999); SmoothPeriod.Name = "Smooth period"; SmoothPeriod.SetInt(3); SmoothPeriod.SetIntLimits(1, 999); return; } // Do data processing sc.DataStartIndex = Period.GetInt() + SmoothPeriod.GetInt(); if (sc.Index > Period.GetInt() + SmoothPeriod.GetInt()) { double TR; TR = max(sc.High[sc.Index], sc.Close[sc.Index-1]) - min(sc.Low[sc.Index], sc.Close[sc.Index-1]); W[sc.Index] = sc.Close[sc.Index] > sc.Close[sc.Index-1] ? TR/(sc.Close[sc.Index] - sc.Close[sc.Index-1]) : TR; sc.Highest(W, sc.Subgraph[20], Period.GetInt()); sc.Lowest(W, sc.Subgraph[21], Period.GetInt()); SR[sc.Index] = (W[sc.Index] - sc.Subgraph[21][sc.Index]) / (sc.Subgraph[20][sc.Index] - sc.Subgraph[21][sc.Index]); sc.MovingAverage(SR, RI, MOVAVGTYPE_EXPONENTIAL, SmoothPeriod.GetInt()); } }