Bu tür hareketli ortalama, ilk olarak 2010 yılında Bruno Pio tarafından geliştirilmiştir.
Yöntem, daha iyi pürüzsüzlük elde etmek için EMA basamaklarının doğrusal bir kombinasyonunu kullanır.
using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using Matriks.Data.Identifiers;
using Matriks.Data.Symbol;
using Matriks.Engines;
using Matriks.Indicators;
using Matriks.Symbols;
using Matriks.AlgoTrader;
using Matriks.Trader.Core;
using Matriks.Trader.Core.Fields;
using Matriks.Trader.Core.TraderModels;
using Matriks.Lean.Algotrader.AlgoBase;
using Matriks.Lean.Algotrader.Models;
using Matriks.Lean.Algotrader.Trading;
using System.Windows.Media;
/*
▂ ▃ ▅ ▆ █ KRİPEX █ ▆ ▅ ▃ ▂
//@version=3
// Copyright (c) 2010-present, Bruno Pio
// Copyright (c) 2019-present, Alex Orekhov (everget)
// Pentuple Exponential Moving Average script may be freely distributed under the MIT license.
study("Pentuple Exponential Moving Average", shorttitle="PEMA", overlay=true)
length = input(title="Length", type=integer, defval=20)
highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true)
src = input(title="Source", type=source, defval=close)
ema1 = ema(src, length)
ema2 = ema(ema1, length)
ema3 = ema(ema2, length)
ema4 = ema(ema3, length)
ema5 = ema(ema4, length)
ema6 = ema(ema5, length)
ema7 = ema(ema6, length)
ema8 = ema(ema7, length)
pema = 8 * ema1 - 28 * ema2 + 56 * ema3 - 70 * ema4 + 56 * ema5 - 28 * ema6 + 8 * ema7 - ema8
pemaColor = highlightMovements ? (pema > pema[1] ? green : red) : #6d1e7f
plot(pema, title="PEMA", linewidth=2, color=pemaColor, transp=0)
*/
namespace Matriks.Lean.Algotrader
{
//Ilk parametre indikatörün adı, sınıfın adıyla aynı olmalıdır.
//Ikinci parametre indikatörün Dataserisinin üzerine mi yeni pencereye mi ekleneceğini belirtir. Yeni pencere için ->IndicatorDrawingArea.NewWindow , Data Serisi için IndicatorDrawingArea.OnDataSeries
[IndicatorInformationAttribute("PEMAKripex", IndicatorDrawingArea.OnDataSeries)]
//Indikatörün çizgilerinin isimleri
[IndicatorLineInformationAttribute(
new []
{
"PEMA (0,1,2)"
},
new []
{
"#00F5FF"
},
new []
{
false
},
new []
{
0
},
new []
{
2
})]
public class PEMAKripex : MatriksIndicator
{
//Indicator opsiyon panelinde değerleri değiştirebildiğimiz parametreler. Int, Bool, Decimal ve Enum değerleri alabilir.Tüm değişken tiplerini DefaultValue ile tanımlarız.
[DefaultValue(20)]
public int Period
{
get; set;
}
[DefaultValue(true)]
public bool HighlightMovements
{
get; set;
}
[DefaultValue(MovMethod.Exponential)]
public MovMethod MovMethod
{
get; set;
}
MOV mov1, mov2, mov3, mov4, mov5, mov6, mov7, mov8;
public sealed override void OnInit()
{
mov1 = MOVIndicator(Symbol, SymbolPeriod, OHLCType.Close, Period, MovMethod);
mov2 = MOVIndicator(mov1, Period, MovMethod);
mov3 = MOVIndicator(mov2, Period, MovMethod);
mov4 = MOVIndicator(mov3, Period, MovMethod);
mov5 = MOVIndicator(mov4, Period, MovMethod);
mov6 = MOVIndicator(mov5, Period, MovMethod);
mov7 = MOVIndicator(mov6, Period, MovMethod);
mov8 = MOVIndicator(mov7, Period, MovMethod);
}
decimal pema;
public override void OnDataUpdate(int currentBar, decimal inputValue, DateTime barDateTime)
{
if (currentBar < Period)
{
SetLine(0, currentBar, 0);
return ;
}
pema = 8 * mov1.CurrentValue - 28 * mov2.CurrentValue + 56 * mov3.CurrentValue - 70 * mov4.CurrentValue + 56 * mov5.CurrentValue - 28 * mov6.CurrentValue + 8 * mov7.CurrentValue - mov8.CurrentValue;
SetLine(currentBar, pema);
if (HighlightMovements)
{
PaintPoint(currentBar, Value[0][currentBar] >Value[0][currentBar -1] ? Colors.Green.ToString() :Colors.Red.ToString(), 0);
}
}
}
}