function Initialize() { IndicatorName = "DeMarker"; PriceStudy = false; AddInput("Input", Inputs.Candle); AddSeries("DeMarker", DrawAs.Line, Color.Red, true); AddSeries("DeMax", DrawAs.Line, Color.Black, false); AddSeries("DeMin", DrawAs.Line, Color.Black, false); AddSeries("SMA_DeMax", DrawAs.Line, Color.Black, false); AddSeries("SMA_DeMin", DrawAs.Line, Color.Black, false); AddLevel(0.3, Color.White, "DeMarker"); AddLevel(0.7, Color.White, "DeMarker"); AddParameter("SMA_Period", 14); } function Evaluate() { //2023.06.30 dev by Maks if (SMA_Period < 1) { ShowMessage("SMA_Period < 1"); return; } if (CurrentIndex < 1) { DeMax[0] = 0.0; DeMin[0] = 0.0; SMA_DeMax[0] = 0.0; SMA_DeMin[0] = 0.0; return; } DeMax[0] = 0.0; if (Input.High[0] > Input.High[1]) DeMax[0] = Input.High[0] - Input.High[1]; DeMin[0] = 0.0; if (Input.Low[1] > Input.Low[0]) DeMin[0] = Input.Low[1] - Input.Low[0]; if (CurrentIndex <= SMA_Period) { SMA_DeMax[0] = SMA_DeMax[1] * (1.0 - 1.0/CurrentIndex) + DeMax[0]/CurrentIndex; SMA_DeMin[0] = SMA_DeMin[1] * (1.0 - 1.0/CurrentIndex) + DeMin[0]/CurrentIndex; } else { SMA_DeMax[0] = SMA_DeMax[1] - DeMax[SMA_Period]/SMA_Period + DeMax[0]/SMA_Period; SMA_DeMin[0] = SMA_DeMin[1] - DeMin[SMA_Period]/SMA_Period + DeMin[0]/SMA_Period; } if (SMA_DeMax + SMA_DeMin > 0) { DeMarker[0] = (double)(SMA_DeMax[0] / (SMA_DeMax[0] + SMA_DeMin[0])); } }