using MOTT = Matriks.Lean.Algotrader.EmbeddedCustom93361378115283151371657180103745885921294081419.MOTT;
using Matriks.AlgoTrader;
using Matriks.Data.Identifiers;
using System.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using Matriks;
using Matriks.Data.Symbol;
using Matriks.Data.Tick;
using Matriks.Engines;
using Matriks.Indicators;
using Matriks.Symbols;
using Matriks.Trader.Core;
using Matriks.Trader.Core.Fields;
using Matriks.Lean.Algotrader.AlgoBase;
using Matriks.Lean.Algotrader.Models;
using Matriks.Lean.Algotrader.Trading;
using Matriks.AI;
using Matriks.AI.AiParameters;
using Matriks.AI.Data;
using Matriks.Trader.Core.TraderModels;
using Matriks.Enumeration;
using Matriks.IntermediaryInstitutionAnalysis.Enums;
namespace Matriks.Lean.Algotrader
{
public class MOTT4B_Stratejisi : MatriksAlgo
{
/*
MOTT_4B Kurgu
AL
Cross(MOV(C,opt1,VAR),OTT(HHV(H,opt2),2,opt3)) OR
Cross(MOV(C,opt1,VAR),(OTT(HHV(H,opt2),2,opt3)+(OTT(HHV(H,opt2),2,opt3)+OTT(LLV(L,opt2),2,opt3))/2)/2) OR
Cross(MOV(C,opt1,VAR),(OTT(HHV(H,opt2),2,opt3)+OTT(LLV(L,opt2),2,opt3))/2) OR
Cross(MOV(C,opt1,VAR),(OTT(LLV(L,opt2),2,opt3)+(OTT(HHV(H,opt2),2,opt3)+OTT(LLV(L,opt2),2,opt3))/2)/2)
SAT
Cross(OTT(HHV(H,opt2),2,opt3),MOV(C,opt1,VAR)) OR
Cross((OTT(HHV(H,opt2),2,opt3)+(OTT(HHV(H,opt2),2,opt3)+OTT(LLV(L,opt2),2,opt3))/2)/2,MOV(C,opt1,VAR)) OR
Cross((OTT(HHV(H,opt2),2,opt3)+OTT(LLV(L,opt2),2,opt3))/2,MOV(C,opt1,VAR)) OR
Cross((OTT(LLV(L,opt2),2,opt3)+(OTT(HHV(H,opt2),2,opt3)+OTT(LLV(L,opt2),2,opt3))/2)/2,MOV(C,opt1,VAR))
*/
//𝕿𝖗𝖆𝖓𝖘𝖑𝖆𝖙𝖊𝖉 𝓑𝔂 ⒶⓀⒾⓃ ℍü𝓃𝑒𝓇𝓁𝒾
[SymbolParameter("GARAN")]
public string Symbol;
[Parameter(SymbolPeriod.Day)]
public SymbolPeriod SymbolPeriod;
[Parameter(Side.Buy)]
public Side orderSide;
[Parameter(4)]
public int MovPeriod;
[Parameter(MovMethod.VAR)]
public MovMethod MovMovMethod;
[Parameter(80)]
public int MottX1;
[Parameter(1.4)]
public decimal MottX2;
[Parameter(0)]
public int MottOteleme;
[Parameter(1)]
public decimal OrderQuantity;
MOV mov;
MatriksIndicator MOTT;
public override void OnDataUpdate(BarDataEventArgs barData)
{
if (CrossAbove(mov, MOTT, 0, 0)
|| CrossAbove(mov, MOTT, 0, 1)
|| CrossAbove(mov, MOTT, 0, 2)
|| CrossAbove(mov, MOTT, 0, 3))
{
SendMarketOrder(Symbol, OrderQuantity, OrderSide.Buy, includeAfterSession:false);
}
if (CrossBelow(mov, MOTT, 0, 0)
|| CrossBelow(mov, MOTT, 0, 1)
|| CrossBelow(mov, MOTT, 0, 2)
|| CrossBelow(mov, MOTT, 0, 3))
{
SendMarketOrder(Symbol, OrderQuantity, OrderSide.Sell, includeAfterSession:false);
}
}
public override void OnInit()
{
mov = MOVIndicator(Symbol, SymbolPeriod, OHLCType.Close, MovPeriod, MovMovMethod);
MOTT = new MOTT();
MOTT.SetIndicatorParameters("X1", MottX1);
MOTT.SetIndicatorParameters("X2", MottX2);
MOTT.SetIndicatorParameters("Oteleme", MottOteleme); RegisterUserIndicator(MOTT, Symbol, SymbolPeriod, OHLCType.Close, 5);
SendOrderSequential(true, orderSide);
WorkWithPermanentSignal(true);
}
/// <summary>
/// Init islemleri tamamlaninca, bardatalar kullanmaya hazir hale gelince bu fonksiyon tetiklenir. Data uzerinde bir defa yapilacak islemler icin kullanilir
/// </summary>
public override void OnInitCompleted()
{
}
/// <summary>
/// SetTimerInterval fonksiyonu ile belirtilen sürede bir bu fonksiyon tetiklenir.
/// </summary>
public override void OnTimer()
{
}
/// <summary>
/// AddNewsSymbol ve AddNewsKeyword ile haberlere kayit olunmuşsa bu fonksiyon tetiklenir.
/// </summary>
/// <param name="newsId">Gelen haberin id'si</param>
/// <param name="relatedSymbols">Gelen haberin ilişkili sembolleri</param>
public override void OnNewsReceived(int newsId, List<string> relatedSymbols)
{
}
/// <summary>
/// Eklenen sembollerin bardata'ları ve indikatorler güncellendikçe bu fonksiyon tetiklenir.
/// </summary>
/// <param name="barData">Bardata ve hesaplanan gerçekleşen işleme ait detaylar</param>
/// <summary>
/// Gönderilen emirlerin son durumu değiştikçe bu fonksiyon tetiklenir.
/// </summary>
/// <param name="barData">Emrin son durumu</param>
public override void OnOrderUpdate(IOrder order)
{
}
/// <summary>
/// Strateji durdurulduğunda bu fonksiyon tetiklenir.
/// </summary>
public override void OnStopped()
{
}
}
public class EmbeddedCustom93361378115283151371657180103745885921294081419
{
//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("MOTT", IndicatorDrawingArea.OnDataSeries)]
//Indikatörün çizgilerinin isimleri
[IndicatorLineInformationAttribute(new []
{
"Line1(0,1)", "Line2", "Line3", "Line4", "Line5"
},
new []
{
"#FF87CEFA", "#FF87CEFA", "#FFFFF0F5",
"#FFFF00FF", "#FFFF00FF"
},
new []
{
false, false, false,
false, false
},
new []
{
0, 2, 2,
2, 0
}, new []
{
1, 1, 1,
1, 1
})]
public class MOTT : MatriksIndicator
{
[DefaultValue(80)]
public int X1
{
get; set;
}
[DefaultValue(1.4)]
public decimal X2
{
get; set;
}
[DefaultValue(3)]
public int Oteleme
{
get; set;
}
MOV mov, mov2, mov3;
OTT ott, ott2;
HighestHigh HHV;
LowestLow LLV;
public sealed override void OnInit()
{
ott = new OTT(2, X2, MovMethod.VAR, false);
ott2 = new OTT(2, X2, MovMethod.VAR, false);
HHV = new HighestHigh(X1);
LLV = new LowestLow(X1);
mov = new MOV(1, MovMethod.Simple);
mov2 = new MOV(1, MovMethod.Simple);
mov3 = new MOV(1, MovMethod.Simple);
}
public override void OnDataUpdate(int currentBar, decimal inputValue, DateTime barDateTime)
{
if (currentBar < Period)
{
SetLine(0, currentBar, 0);
SetLine(1, currentBar, 0);
SetLine(2, currentBar, 0);
SetLine(3, currentBar, 0);
SetLine(4, currentBar, 0);
return;
}
var L = Instrument.SymbolBarData.Low[currentBar];
var H = Instrument.SymbolBarData.High[currentBar];
HHV.Update(H, currentBar, barDateTime);
ott.Update(HHV.CurrentValue, currentBar, barDateTime);
LLV.Update(L, currentBar, barDateTime);
ott2.Update(LLV.CurrentValue, currentBar, barDateTime);
var line1 = (((ott.Value[0][ott.CurrentIndex]) + ((ott.Value[0][ott.CurrentIndex] + ott2.Value[0][ott2.CurrentIndex]) / 2m)) / 2m);
mov.Update(line1, currentBar, barDateTime);
var line2 = (ott.CurrentValue + ott2.CurrentValue) / 2m;
mov2.Update(line2, currentBar, barDateTime);
var line3 = (ott2.Value[0][ott2.CurrentIndex] + ((ott.Value[0][ott.CurrentIndex] + ott2.Value[0][ott2.CurrentIndex]) / 2m)) / 2m;
mov3.Update(line3, currentBar, barDateTime);
SetLine(currentBar, ott.Value[0][ott.CurrentIndex - Oteleme]);
SetLine(1, currentBar, mov.Value[0][mov.CurrentIndex - Oteleme]);
SetLine(2, currentBar, mov2.Value[0][mov2.CurrentIndex - Oteleme]);
SetLine(3, currentBar, mov3.Value[0][mov3.CurrentIndex - Oteleme]);
SetLine(4, currentBar, ott2.Value[0][ott2.CurrentIndex - Oteleme]);
}
}
}
}