OTTO - Optimized Trend Tracker Oscillator
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;
/*
flength:=input("Kısa HO uzunlugu",1,500,10);
slength:=input("Uzun HO uzunlugu",1,500,25);
period:=input("OTT uzunlugu",1,500,2);
OPTc:=input("OTT Optimizasyon Katsayısı",0,50,0.6);
coco:=input("Düzeltme Katsayısı",10,1000000,1000);
KHA:=MOV(C,slength/2,VAR)/((MOV(C,slength,VAR)-MOV(C,slength*flength,VAR))+coco);
OTTO:=OTT(KHA,period,OPTc);
KHA;
OTTO
*/
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("OTTOKripex", IndicatorDrawingArea.NewWindow)]
//Indikatörün çizgilerinin isimleri
[IndicatorLineInformationAttribute(new []
{
"KHA (0,1,2,3)", "OTTO (4,5)"
})]
public class OTTOKripex : 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(10)]
public decimal FastHO
{
get; set;
}
[DefaultValue(25)]
public decimal SlowHO
{
get; set;
}
[DefaultValue(MovMethod.VAR)]
public MovMethod MovMethod
{
get; set;
}
[DefaultValue(1000)]
public decimal KatSayi
{
get; set;
}
[DefaultValue(2)]
public int OttPeriod
{
get; set;
}
[DefaultValue(0.6)]
public decimal Opt
{
get; set;
}
OTT ott;
MOV mov1, mov2, mov3;
public sealed override void OnInit()
{
var p1 = (int) Math.Ceiling((decimal)(SlowHO / 2));
var p2 = (int) SlowHO;
var p3 = (int)(SlowHO * FastHO);
mov1 = MOVIndicator(Symbol, SymbolPeriod, OHLCType.Close, p1, MovMethod);
mov2 = MOVIndicator(Symbol, SymbolPeriod, OHLCType.Close, p2, MovMethod);
mov3 = MOVIndicator(Symbol, SymbolPeriod, OHLCType.Close, p3, MovMethod);
ott = new OTT(OttPeriod, Opt, MovMethod, true);
}
public override void OnDataUpdate(int currentBar, decimal inputValue, DateTime barDateTime)
{
if (currentBar < Period)
{
SetLine(0, currentBar, 0);
SetLine(1, currentBar, 0);
return ;
}
var deger = mov1.CurrentValue / ((mov2.CurrentValue - mov3.CurrentValue) + KatSayi);
ott.Update(deger, currentBar, barDateTime);
SetLine(0, currentBar, deger);
SetLine(1, currentBar, ott.CurrentValue);
}
}
}