WAE Waddah Attar Explosion
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;
/*
Hassasiyet:=input("Hassasiyet",1,500,150);
KisaHO:=input("Kisa Har Ort",1,500,20);
UzunHO:=input("Uzun Har Ort",1,500,40);
Bandpd:=input("Bollinger Band Periodu",1,500,20);
BandSS:=input("BBand SSapma",0,5,2);
MACDx:=macd(UzunHO,KisaHO,9);
t1:=(MACDx-ref(macdx,-1))*Hassasiyet;
exline:=BBandtop(c,Bandpd,s,BandSS)-BBandbot(c,Bandpd,s,BandSS);
uptrend:=if(t1>=0,t1,0);
downtrend:=if(t1<0,-t1,0);
uptrend;
downtrend;
exline
Kıvanç Özbilgiç
https://drive.google.com/drive/folders/1b3Pt-U-RzVAHPRz-cZM6LX7e6wdmA4mX
*/
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("WaddahAttarExplosionKripex", IndicatorDrawingArea.NewWindow)]
//Indikatörün çizgilerinin isimleri
[IndicatorLineInformationAttribute(new []
{
"UpTrend(0)", "DownTrend", "Exline"
}, new []
{
"#00c87b", "#f70031", "#ffff00"
}, new []
{
false, false, false
}, new []
{
5, 5, 2
}, new []
{
1, 1, 2
}
)]
public class WaddahAttarExplosionKripex : 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(40)]
public int MacdUzunPeriod
{
get; set;
}
[DefaultValue(20)]
public int MacdKisaPeriod
{
get; set;
}
[DefaultValue(9)]
public int MacdTrigger
{
get; set;
}
[DefaultValue(20)]
public int BollingerPeriod
{
get; set;
}
[DefaultValue(2)]
public decimal BollingerSapma
{
get; set;
}
[DefaultValue(150)]
public decimal Hassasiyet
{
get; set;
}
BOLLINGER bollinger;
MACD macd;
public sealed override void OnInit()
{
bollinger = BollingerIndicator(Symbol, SymbolPeriod, OHLCType.Close, BollingerPeriod, BollingerSapma, MovMethod.Simple);
macd = MACDIndicator(Symbol, SymbolPeriod, OHLCType.Close, MacdUzunPeriod, MacdKisaPeriod, MacdTrigger);
}
decimal t1, exline, uptrend, downtrend;
public override void OnDataUpdate(int currentBar, decimal inputValue, DateTime barDateTime)
{
if (currentBar < MacdUzunPeriod)
{
SetLine(0, currentBar, 0);
SetLine(1, currentBar, 0);
SetLine(2, currentBar, 0);
return ;
}
t1 = (macd.Value[0][macd.CurrentIndex] - macd.Value[0][macd.CurrentIndex -1]) * Hassasiyet;
exline = bollinger.Value[0][bollinger.CurrentIndex] - bollinger.Value[2][bollinger.CurrentIndex];
uptrend = t1 >= 0? t1:0;
downtrend = t1<0? -1 * t1:0;
SetLine(0, currentBar, uptrend);
SetLine(1, currentBar, downtrend);
SetLine(2, currentBar, exline);
}
}
}