Anıl Özekşi tarafından oluşturulan bu sistemde fırsatçı trend diye adlandırdığı OTT indikatörü kullanılan formülü ile, klasik olarak IF'li sistemi birleştirilmiştir.
Sistem al-sat / açığa sat-açık pozisyon kapama işlemlerini yapar.
Hem BIST hem kriptoda kullanılabilir.
Vadeli semboller ve spot sembollerde de kullanabilirsiniz.
Ayarlanabilir kaldıraç oranı vardır.
Ayarlanabilir zaman kontrolü vardır.
NOT: Parametreler örnek olarak verilmiştir. Lütfen optimizasyon yapmadan çalıştırmayınız.
using System;
using System.Collections.Generic;
using System.Linq;
using Matriks.Data.Symbol;
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;
/*
Bu şablondaki açığa satış yapısı Viop ve Futures piyasalarına uygundur.
Stratejinin çift yönlü ilerlemesi istendiğinde AcigaSatisYapilsin seçeneğinin aktif edilmesi gerekir ( varsayılan aktif )
Akşam seansında da oluşan sinyallerle emir gönderilmesi için AksamSeansiniDahilEt seçeneğinin aktif edilmesi gerekir ( varsayılan pasif )
Kripto piyasası 7/24 açık olduğu için bu seçeneğin aktif ya da pasif seçilmesi birşey değiştirmez.
*** Stratejiye eklenen sentetik emirler tetiklendiğinde pozisyon sıfırlanıp ilk gelecek sinyale göre işleme girecektir.
*/
namespace Matriks.Lean.Algotrader
{
public class FirsatciTrendOriginal : MatriksAlgo
{
[SymbolParameter("GARAN")]
public string Symbol;
[Parameter(SymbolPeriod.Min5)]
public SymbolPeriod SymbolPeriod;
[Parameter(2)]
public int OttPeriod1;
[Parameter(1.4)]
public decimal OttOpt1;
[Parameter(MovMethod.VAR)]
public MovMethod OttMovMethod1;
[Parameter(true)]
public bool OttSupportLine1;
[Parameter(40)]
public int TottPeriod1;
[Parameter(1)]
public decimal TottOpt1;
[Parameter(0.001)]
public decimal TottTwinOttCoef1;
[Parameter(MovMethod.VAR)]
public MovMethod TottMovMethod1;
[Parameter(500)]
public int SottPeriodK1;
[Parameter(200)]
public int SottPeriodSlowK1;
[Parameter(2)]
public int SottOttPeriod1;
[Parameter(0.5)]
public decimal SottOttOpt1;
[Parameter(MovMethod.VAR)]
public MovMethod SottOttMethod1;
[Parameter(MovMethod.VAR)]
public MovMethod SottStosKMethod1;
[Parameter(2)]
public int HottlottPeriod1;
[Parameter(1.4)]
public decimal HottlottOpt1;
[Parameter(10)]
public int HottlottBarSayisi1;
[Parameter(MovMethod.VAR)]
public MovMethod HottlottMovMethod1;
[Parameter(5)]
public int HighesthighPeriod1;
[Parameter(2)]
public int OttPeriod2;
[Parameter(1.5)]
public decimal OttOpt2;
[Parameter(MovMethod.VAR)]
public MovMethod OttMovMethod2;
[Parameter(true)]
public bool OttSupportLine2;
[Parameter(2)]
public int OttPeriod3;
[Parameter(1.5)]
public decimal OttOpt3;
[Parameter(MovMethod.VAR)]
public MovMethod OttMovMethod3;
[Parameter(true)]
public bool OttSupportLine3;
[Parameter(50)]
public int TottPeriod2;
[Parameter(1)]
public decimal TottOpt2;
[Parameter(0.001)]
public decimal TottTwinOttCoef2;
[Parameter(MovMethod.VAR)]
public MovMethod TottMovMethod2;
[Parameter(200)]
public int SottPeriodK2;
[Parameter(200)]
public int SottPeriodSlowK2;
[Parameter(2)]
public int SottOttPeriod2;
[Parameter(0.5)]
public decimal SottOttOpt2;
[Parameter(MovMethod.VAR)]
public MovMethod SottOttMethod2;
[Parameter(MovMethod.VAR)]
public MovMethod SottStosKMethod2;
[Parameter(2)]
public int HottlottPeriod2;
[Parameter(1.4)]
public decimal HottlottOpt2;
[Parameter(10)]
public int HottlottBarSayisi2;
[Parameter(MovMethod.VAR)]
public MovMethod HottlottMovMethod2;
[Parameter(5)]
public int HighesthighPeriod2;
[Parameter(2)]
public int OttPeriod4;
[Parameter(2.6)]
public decimal OttOpt4;
[Parameter(MovMethod.VAR)]
public MovMethod OttMovMethod4;
[Parameter(true)]
public bool OttSupportLine4;
[Parameter(60)]
public int TottPeriod3;
[Parameter(1)]
public decimal TottOpt3;
[Parameter(0.001)]
public decimal TottTwinOttCoef3;
[Parameter(MovMethod.VAR)]
public MovMethod TottMovMethod3;
[Parameter(200)]
public int SottPeriodK3;
[Parameter(250)]
public int SottPeriodSlowK3;
[Parameter(2)]
public int SottOttPeriod3;
[Parameter(0.5)]
public decimal SottOttOpt3;
[Parameter(MovMethod.VAR)]
public MovMethod SottOttMethod3;
[Parameter(MovMethod.VAR)]
public MovMethod SottStosKMethod3;
[Parameter(2)]
public int HottlottPeriod3;
[Parameter(1.4)]
public decimal HottlottOpt3;
[Parameter(8)]
public int HottlottBarSayisi3;
[Parameter(MovMethod.VAR)]
public MovMethod HottlottMovMethod3;
[Parameter(5)]
public int LowestlowPeriod1;
[Parameter(60)]
public int TottPeriod4;
[Parameter(1.2)]
public decimal TottOpt4;
[Parameter(0.001)]
public decimal TottTwinOttCoef4;
[Parameter(MovMethod.VAR)]
public MovMethod TottMovMethod4;
[Parameter(200)]
public int SottPeriodK4;
[Parameter(250)]
public int SottPeriodSlowK4;
[Parameter(2)]
public int SottOttPeriod4;
[Parameter(0.2)]
public decimal SottOttOpt4;
[Parameter(MovMethod.VAR)]
public MovMethod SottOttMethod4;
[Parameter(MovMethod.VAR)]
public MovMethod SottStosKMethod4;
[Parameter(2)]
public int HottlottPeriod4;
[Parameter(1.4)]
public decimal HottlottOpt4;
[Parameter(11)]
public int HottlottBarSayisi4;
[Parameter(MovMethod.VAR)]
public MovMethod HottlottMovMethod4;
[Parameter(10)]
public int LowestlowPeriod2;
[Parameter(2)]
public int OttPeriod5;
[Parameter(2.6)]
public decimal OttOpt5;
[Parameter(MovMethod.VAR)]
public MovMethod OttMovMethod5;
[Parameter(true)]
public bool OttSupportLine5;
[Parameter(60)]
public int TottPeriod5;
[Parameter(1.2)]
public decimal TottOpt5;
[Parameter(0.001)]
public decimal TottTwinOttCoef5;
[Parameter(MovMethod.VAR)]
public MovMethod TottMovMethod5;
[Parameter(200)]
public int SottPeriodK5;
[Parameter(250)]
public int SottPeriodSlowK5;
[Parameter(2)]
public int SottOttPeriod5;
[Parameter(0.2)]
public decimal SottOttOpt5;
[Parameter(MovMethod.VAR)]
public MovMethod SottOttMethod5;
[Parameter(MovMethod.VAR)]
public MovMethod SottStosKMethod5;
[Parameter(2)]
public int HottlottPeriod5;
[Parameter(1.4)]
public decimal HottlottOpt5;
[Parameter(11)]
public int HottlottBarSayisi5;
[Parameter(MovMethod.VAR)]
public MovMethod HottlottMovMethod5;
[Parameter(10)]
public int LowestlowPeriod3;
[Parameter(2)]
public int OttPeriod6;
[Parameter(2.6)]
public decimal OttOpt6;
[Parameter(MovMethod.VAR)]
public MovMethod OttMovMethod6;
[Parameter(true)]
public bool OttSupportLine6;
[Parameter(60)]
public int TottPeriod6;
[Parameter(1.2)]
public decimal TottOpt6;
[Parameter(0.001)]
public decimal TottTwinOttCoef6;
[Parameter(MovMethod.VAR)]
public MovMethod TottMovMethod6;
[Parameter(200)]
public int SottPeriodK6;
[Parameter(250)]
public int SottPeriodSlowK6;
[Parameter(2)]
public int SottOttPeriod6;
[Parameter(0.2)]
public decimal SottOttOpt6;
[Parameter(MovMethod.VAR)]
public MovMethod SottOttMethod6;
[Parameter(MovMethod.VAR)]
public MovMethod SottStosKMethod6;
[Parameter(2)]
public int HottlottPeriod6;
[Parameter(1.4)]
public decimal HottlottOpt6;
[Parameter(11)]
public int HottlottBarSayisi6;
[Parameter(MovMethod.VAR)]
public MovMethod HottlottMovMethod6;
[Parameter(10)]
public int LowestlowPeriod4;
[Parameter(2)]
public int OttPeriod7;
[Parameter(2.6)]
public decimal OttOpt7;
[Parameter(MovMethod.VAR)]
public MovMethod OttMovMethod7;
[Parameter(true)]
public bool OttSupportLine7;
[Parameter(60)]
public int TottPeriod7;
[Parameter(1.2)]
public decimal TottOpt7;
[Parameter(0.001)]
public decimal TottTwinOttCoef7;
[Parameter(MovMethod.VAR)]
public MovMethod TottMovMethod7;
[Parameter(200)]
public int SottPeriodK7;
[Parameter(250)]
public int SottPeriodSlowK7;
[Parameter(2)]
public int SottOttPeriod7;
[Parameter(0.2)]
public decimal SottOttOpt7;
[Parameter(MovMethod.VAR)]
public MovMethod SottOttMethod7;
[Parameter(MovMethod.VAR)]
public MovMethod SottStosKMethod7;
[Parameter(2)]
public int HottlottPeriod7;
[Parameter(1.4)]
public decimal HottlottOpt7;
[Parameter(11)]
public int HottlottBarSayisi7;
[Parameter(MovMethod.VAR)]
public MovMethod HottlottMovMethod7;
[Parameter(5)]
public int HighesthighPeriod3;
[Parameter(60)]
public int TottPeriod8;
[Parameter(1.2)]
public decimal TottOpt8;
[Parameter(0.001)]
public decimal TottTwinOttCoef8;
[Parameter(MovMethod.VAR)]
public MovMethod TottMovMethod8;
[Parameter(200)]
public int SottPeriodK8;
[Parameter(250)]
public int SottPeriodSlowK8;
[Parameter(2)]
public int SottOttPeriod8;
[Parameter(0.2)]
public decimal SottOttOpt8;
[Parameter(MovMethod.VAR)]
public MovMethod SottOttMethod8;
[Parameter(MovMethod.VAR)]
public MovMethod SottStosKMethod8;
[Parameter(2)]
public int HottlottPeriod8;
[Parameter(1.4)]
public decimal HottlottOpt8;
[Parameter(11)]
public int HottlottBarSayisi8;
[Parameter(MovMethod.VAR)]
public MovMethod HottlottMovMethod8;
[Parameter(5)]
public int HighesthighPeriod4;
[Parameter(3)]
public int Kaldirac;
[Parameter(5)]
public decimal BuyOrderQuantity;
[Parameter(5)]
public decimal SellOrderQuantity;
[Parameter(true)]
public bool zamanK;
// Gerekli zaman aralığı
[Parameter("10:03:00")]
public string Baslangic;
[Parameter("17:58:00")]
public string Bitis;
public bool FX_ZamanindaMI(DateTime zaman)
{
var bas = TimeSpan.Parse(Baslangic);
var bit = TimeSpan.Parse(Bitis);
return (zaman.TimeOfDay >= bas && zaman.TimeOfDay <= bit);
}
OTT ott;
TOTT tott;
SOTT sott;
MatriksIndicator HottLott;
HighestHigh highestHigh;
OTT ott2;
TOTT tott2;
SOTT sott2;
MatriksIndicator HottLott2;
HighestHigh highestHigh2;
OTT ott3;
TOTT tott3;
SOTT sott3;
MatriksIndicator HottLott3;
LowestLow lowestLow;
TOTT tott4;
SOTT sott4;
MatriksIndicator HottLott4;
LowestLow lowestLow2;
OTT ott4;
OTT ott5;
OTT ott6;
TOTT tott5;
SOTT sott5;
MatriksIndicator HottLott5;
LowestLow lowestLow3;
TOTT tott6;
SOTT sott6;
MatriksIndicator HottLott6;
LowestLow lowestLow4;
OTT ott7;
TOTT tott7;
SOTT sott7;
MatriksIndicator HottLott7;
HighestHigh highestHigh3;
TOTT tott8;
SOTT sott8;
MatriksIndicator HottLott8;
HighestHigh highestHigh4;
public override void OnInit()
{
AddSymbol(Symbol, SymbolPeriod);
ott = OTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, OttPeriod1, OttOpt1, OttMovMethod1, OttSupportLine1);
tott = TOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, TottPeriod1, TottOpt1, TottTwinOttCoef1, TottMovMethod1);
sott = SOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, SottPeriodK1, SottPeriodSlowK1, SottOttPeriod1, SottOttOpt1, SottOttMethod1, SottStosKMethod1);
HottLott = new HottLott();
HottLott.SetIndicatorParameters("Period", HottlottPeriod1);
HottLott.SetIndicatorParameters("Opt", HottlottOpt1);
HottLott.SetIndicatorParameters("BarSayisi", HottlottBarSayisi1);
HottLott.SetIndicatorParameters("MovMethod", HottlottMovMethod1); RegisterUserIndicator(HottLott, Symbol, SymbolPeriod, OHLCType.Close, 5);
highestHigh = HighestHighIndicator(Symbol, SymbolPeriod, HighesthighPeriod1);
ott2 = OTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, OttPeriod2, OttOpt2, OttMovMethod2, OttSupportLine2);
tott2 = TOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, TottPeriod2, TottOpt2, TottTwinOttCoef2, TottMovMethod2);
sott2 = SOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, SottPeriodK2, SottPeriodSlowK2, SottOttPeriod2, SottOttOpt2, SottOttMethod2, SottStosKMethod2);
HottLott2 = new HottLott();
HottLott2.SetIndicatorParameters("Period", HottlottPeriod2);
HottLott2.SetIndicatorParameters("Opt", HottlottOpt2);
HottLott2.SetIndicatorParameters("BarSayisi", HottlottBarSayisi2);
HottLott2.SetIndicatorParameters("MovMethod", HottlottMovMethod2); RegisterUserIndicator(HottLott2, Symbol, SymbolPeriod, OHLCType.Close, 5);
highestHigh2 = HighestHighIndicator(Symbol, SymbolPeriod, HighesthighPeriod2);
ott3 = OTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, OttPeriod3, OttOpt3, OttMovMethod3, OttSupportLine3);
tott3 = TOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, TottPeriod3, TottOpt3, TottTwinOttCoef3, TottMovMethod3);
sott3 = SOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, SottPeriodK3, SottPeriodSlowK3, SottOttPeriod3, SottOttOpt3, SottOttMethod3, SottStosKMethod3);
HottLott3 = new HottLott();
HottLott3.SetIndicatorParameters("Period", HottlottPeriod3);
HottLott3.SetIndicatorParameters("Opt", HottlottOpt3);
HottLott3.SetIndicatorParameters("BarSayisi", HottlottBarSayisi3);
HottLott3.SetIndicatorParameters("MovMethod", HottlottMovMethod3); RegisterUserIndicator(HottLott3, Symbol, SymbolPeriod, OHLCType.Close, 5);
lowestLow = LowestLowIndicator(Symbol, SymbolPeriod, LowestlowPeriod1);
tott4 = TOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, TottPeriod4, TottOpt4, TottTwinOttCoef4, TottMovMethod4);
sott4 = SOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, SottPeriodK4, SottPeriodSlowK4, SottOttPeriod4, SottOttOpt4, SottOttMethod4, SottStosKMethod4);
HottLott4 = new HottLott();
HottLott4.SetIndicatorParameters("Period", HottlottPeriod4);
HottLott4.SetIndicatorParameters("Opt", HottlottOpt4);
HottLott4.SetIndicatorParameters("BarSayisi", HottlottBarSayisi4);
HottLott4.SetIndicatorParameters("MovMethod", HottlottMovMethod4); RegisterUserIndicator(HottLott4, Symbol, SymbolPeriod, OHLCType.Close, 5);
lowestLow2 = LowestLowIndicator(Symbol, SymbolPeriod, LowestlowPeriod2);
ott4 = OTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, OttPeriod4, OttOpt4, OttMovMethod4, OttSupportLine4);
ott5 = OTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, OttPeriod5, OttOpt5, OttMovMethod5, OttSupportLine5);
ott6 = OTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, OttPeriod6, OttOpt6, OttMovMethod6, OttSupportLine6);
tott5 = TOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, TottPeriod5, TottOpt5, TottTwinOttCoef5, TottMovMethod5);
sott5 = SOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, SottPeriodK5, SottPeriodSlowK5, SottOttPeriod5, SottOttOpt5, SottOttMethod5, SottStosKMethod5);
HottLott5 = new HottLott();
HottLott5.SetIndicatorParameters("Period", HottlottPeriod5);
HottLott5.SetIndicatorParameters("Opt", HottlottOpt5);
HottLott5.SetIndicatorParameters("BarSayisi", HottlottBarSayisi5);
HottLott5.SetIndicatorParameters("MovMethod", HottlottMovMethod5); RegisterUserIndicator(HottLott5, Symbol, SymbolPeriod, OHLCType.Close, 5);
lowestLow3 = LowestLowIndicator(Symbol, SymbolPeriod, LowestlowPeriod3);
tott6 = TOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, TottPeriod6, TottOpt6, TottTwinOttCoef6, TottMovMethod6);
sott6 = SOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, SottPeriodK6, SottPeriodSlowK6, SottOttPeriod6, SottOttOpt6, SottOttMethod6, SottStosKMethod6);
HottLott6 = new HottLott();
HottLott6.SetIndicatorParameters("Period", HottlottPeriod6);
HottLott6.SetIndicatorParameters("Opt", HottlottOpt6);
HottLott6.SetIndicatorParameters("BarSayisi", HottlottBarSayisi6);
HottLott6.SetIndicatorParameters("MovMethod", HottlottMovMethod6); RegisterUserIndicator(HottLott6, Symbol, SymbolPeriod, OHLCType.Close, 5);
lowestLow4 = LowestLowIndicator(Symbol, SymbolPeriod, LowestlowPeriod4);
ott7 = OTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, OttPeriod7, OttOpt7, OttMovMethod7, OttSupportLine7);
tott7 = TOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, TottPeriod7, TottOpt7, TottTwinOttCoef7, TottMovMethod7);
sott7 = SOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, SottPeriodK7, SottPeriodSlowK7, SottOttPeriod7, SottOttOpt7, SottOttMethod7, SottStosKMethod7);
HottLott7 = new HottLott();
HottLott7.SetIndicatorParameters("Period", HottlottPeriod7);
HottLott7.SetIndicatorParameters("Opt", HottlottOpt7);
HottLott7.SetIndicatorParameters("BarSayisi", HottlottBarSayisi7);
HottLott7.SetIndicatorParameters("MovMethod", HottlottMovMethod7); RegisterUserIndicator(HottLott7, Symbol, SymbolPeriod, OHLCType.Close, 5);
highestHigh3 = HighestHighIndicator(Symbol, SymbolPeriod, HighesthighPeriod3);
tott8 = TOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, TottPeriod8, TottOpt8, TottTwinOttCoef8, TottMovMethod8);
sott8 = SOTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, SottPeriodK8, SottPeriodSlowK8, SottOttPeriod8, SottOttOpt8, SottOttMethod8, SottStosKMethod8);
HottLott8 = new HottLott();
HottLott8.SetIndicatorParameters("Period", HottlottPeriod8);
HottLott8.SetIndicatorParameters("Opt", HottlottOpt8);
HottLott8.SetIndicatorParameters("BarSayisi", HottlottBarSayisi8);
HottLott8.SetIndicatorParameters("MovMethod", HottlottMovMethod8); RegisterUserIndicator(HottLott8, Symbol, SymbolPeriod, OHLCType.Close, 5);
highestHigh4 = HighestHighIndicator(Symbol, SymbolPeriod, HighesthighPeriod4);
// Gerekli - Kaldıraç
SetLeverage(Symbol, Kaldirac); // kaldıraç oranı
SetLeverageType(Symbol, true); // kaldıraç tipi - true isolated, false cross
// #Gerekli - Kaldıraç
// Gerekli açığa satış
WorkWithPermanentSignal(true);
SendOrderSequential(true, Side.Buy);
SendOrderSequentialForShort(true, Side.Sell);
// #Gerekli açığa satış
// Gerekli - Timestamp
SetTimerInterval(1);
// #Gerekli - Timestamp
}
public override void OnDataUpdate(BarDataEventArgs barData)
{
var zamanKontrolu = FX_ZamanindaMI(barData.BarData.Dtime);
var barData1 = GetBarData(Symbol, SymbolPeriod);
var ohlcData1 = GetSelectedValueFromBarData(barData1, OHLCType.High);
var ohlcData2 = GetSelectedValueFromBarData(barData1, OHLCType.Low);
if (zamanKontrolu && zamanK || zamanK == false)
{
if (ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex])
{
if (tott.Value[0][tott.CurrentIndex] > tott.Value[1][tott.CurrentIndex]
&& sott.Value[0][sott.CurrentIndex] > sott.Value[1][sott.CurrentIndex]
&& HottLott.Value[0][HottLott.CurrentIndex] < ohlcData1
&& highestHigh.Value[0][highestHigh.CurrentIndex - 1] < ohlcData1)
{
FX_Al(Symbol, BuyOrderQuantity);
}
}
else
{
if (ott2.Value[1][ott2.CurrentIndex] > (ott2.Value[0][ott2.CurrentIndex] + ott2.Value[0][ott2.CurrentIndex -100] - ott5.Value[0][ott5.CurrentIndex -100] + ott2.Value[0][ott2.CurrentIndex - 100]) / 2
&& tott2.Value[0][tott2.CurrentIndex] > tott2.Value[1][tott2.CurrentIndex]
&& sott2.Value[0][sott2.CurrentIndex] > sott2.Value[1][sott2.CurrentIndex]
&& HottLott2.Value[0][HottLott2.CurrentIndex] < ohlcData1
&& highestHigh2.Value[0][highestHigh2.CurrentIndex - 1] < ohlcData1)
{
FX_Al(Symbol, BuyOrderQuantity);
}
}
if (ott4.Value[1][ott4.CurrentIndex] > ott4.Value[0][ott4.CurrentIndex])
{
if (tott3.Value[0][tott3.CurrentIndex] < tott3.Value[2][tott3.CurrentIndex]
&& sott3.Value[0][sott3.CurrentIndex] < sott3.Value[1][sott3.CurrentIndex]
&& HottLott3.Value[1][HottLott3.CurrentIndex] > ohlcData2
&& lowestLow.Value[0][lowestLow.CurrentIndex - 1] > ohlcData2)
{
FX_Sat(Symbol, SellOrderQuantity);
}
}
else
{
if (tott4.Value[0][tott4.CurrentIndex] < tott4.Value[2][tott4.CurrentIndex]
&& sott4.Value[0][sott4.CurrentIndex] < sott4.Value[1][sott4.CurrentIndex]
&& HottLott4.Value[1][HottLott4.CurrentIndex] > ohlcData2
&& lowestLow2.Value[0][lowestLow2.CurrentIndex - 1] > ohlcData2)
{
FX_Sat(Symbol, SellOrderQuantity);
}
}
if (ott5.Value[1][ott5.CurrentIndex] < ott5.Value[0][ott5.CurrentIndex])
{
if (tott5.Value[0][tott5.CurrentIndex] < tott5.Value[2][tott5.CurrentIndex]
&& sott5.Value[0][sott5.CurrentIndex] < sott5.Value[1][sott5.CurrentIndex]
&& HottLott5.Value[1][HottLott5.CurrentIndex] > ohlcData2
&& lowestLow3.Value[0][lowestLow3.CurrentIndex - 1] > ohlcData2)
{
FX_AcigaSatis(Symbol, SellOrderQuantity);
}
}
else
{
if (ott5.Value[1][ott5.CurrentIndex] < (ott5.Value[0][ott5.CurrentIndex] + ott5.Value[0][ott5.CurrentIndex -100] - ott6.Value[0][ott6.CurrentIndex -100] + ott5.Value[0][ott5.CurrentIndex - 100]) / 2
&& tott6.Value[0][tott6.CurrentIndex] < tott6.Value[2][tott6.CurrentIndex]
&& sott6.Value[0][sott6.CurrentIndex] < sott6.Value[1][sott6.CurrentIndex]
&& HottLott6.Value[1][HottLott6.CurrentIndex] > ohlcData2
&& lowestLow4.Value[0][lowestLow4.CurrentIndex - 1] > ohlcData2)
{
FX_AcigaSatis(Symbol, SellOrderQuantity);
}
}
if (ott7.Value[1][ott7.CurrentIndex] < ott7.Value[0][ott7.CurrentIndex])
{
if (tott7.Value[0][tott7.CurrentIndex] > tott7.Value[1][tott7.CurrentIndex]
&& sott7.Value[0][sott7.CurrentIndex] > sott7.Value[1][sott7.CurrentIndex]
&& HottLott7.Value[0][HottLott7.CurrentIndex] < ohlcData1
&& highestHigh3.Value[0][highestHigh3.CurrentIndex - 1] < ohlcData1)
{
FX_AcikPozisyonKapat(Symbol, BuyOrderQuantity);
}
}
else
{
if (tott8.Value[0][tott8.CurrentIndex] > tott8.Value[1][tott8.CurrentIndex]
&& sott8.Value[0][sott8.CurrentIndex] > sott8.Value[1][sott8.CurrentIndex]
&& HottLott8.Value[0][HottLott8.CurrentIndex] < ohlcData1
&& highestHigh4.Value[0][highestHigh4.CurrentIndex - 1] < ohlcData1)
{
FX_AcikPozisyonKapat(Symbol, BuyOrderQuantity);
}
}
}
}
// Gerekli - Timestamp
public class OrderListTimestamp
{
public string ID;
public string Sembol;
public decimal Adet;
public decimal Fiyat;
public OrdType EmirTipi;
public OrderSide orderSide;
public string EmirYonu;
public DateTime TetiklenmeZamani;
public int Sayac;
public bool AktifMI;
}
Dictionary<string, OrderListTimestamp> timestampDict = new Dictionary<string, OrderListTimestamp>();
[Parameter(3)]
public int AyniEmirKacSeferGonderilsin;
[Parameter(10)]
public int KacSaniyeSonraTekrarGonderilsin;
string orderIDTimestamp = string.Empty;
// #Gerekli - Timestamp
public override void OnTimer()
{
// Gerekli - Timestamp
var tutt = timestampDict.Where(x => x.Value.AktifMI == true && DateTime.Now >= x.Value.TetiklenmeZamani);
if (tutt.Count() >0)
{
foreach (var deger in tutt)
{
LastOrderSide.Obj = deger.Value.orderSide == OrderSide.Buy? Side.Sell:Side.Buy;
if (deger.Value.EmirTipi.Obj == OrdType.Limit)
{
orderIDTimestamp = SendLimitOrder(deger.Value.Sembol, deger.Value.Adet, deger.Value.orderSide, deger.Value.Fiyat);
Debug(deger.Value.EmirYonu + " emri tekrar gönderildi.");
}else if (deger.Value.EmirTipi.Obj == OrdType.Market)
{
orderIDTimestamp = SendMarketOrder(deger.Value.Sembol, deger.Value.Adet, deger.Value.orderSide);
Debug(deger.Value.EmirYonu + " emri tekrar gönderildi.");
}
deger.Value.ID = orderIDTimestamp;
deger.Value.AktifMI = false;
timestampDict[orderIDTimestamp] = deger.Value;
timestampDict.Remove(deger.Key);
}
}
}
// #Gerekli - Timestamp
// Gerekli açığa satış
[Parameter(true)]
public bool AcigaSatisYapilsin;
[Parameter(false)]
public bool AksamSeansiniDahilEt;
public bool FX_Al(string sembol, decimal adet)
{
bool sonuc = false;
if (LastOrderSide.Obj != Side.Buy && LastOrderSideForShort.Obj != Side.Sell)
{
LastOrderSide.Obj = Side.All;
SendMarketOrder(sembol, adet, OrderSide.Buy, includeAfterSession:AksamSeansiniDahilEt);
Debug("Al [ " + adet + " adet ]");
sonuc = true;
}
return sonuc;
}
public bool FX_Sat(string sembol, decimal adet)
{
bool sonuc = false;
if (LastOrderSide.Obj != Side.Sell && LastOrderSideForShort.Obj != Side.Sell)
{
LastOrderSide.Obj = Side.All;
SendMarketOrder(sembol, adet, OrderSide.Sell, includeAfterSession:AksamSeansiniDahilEt);
Debug("Sat [ " + adet + " adet ]");
sonuc = true;
}
return sonuc;
}
public bool FX_AcigaSatis(string sembol, decimal adet)
{
bool sonuc = false;
if (LastOrderSideForShort.Obj != Side.Sell && LastOrderSide.Obj != Side.Buy && AcigaSatisYapilsin)
{
LastOrderSide.Obj = Side.All;
SendMarketOrder(sembol, adet, OrderSide.Sell, includeAfterSession:AksamSeansiniDahilEt);
Debug("Açığa Sat[ " + adet + " adet ]");
LastOrderSideForShort.Obj = Side.Sell;
sonuc = true;
}
return sonuc;
}
public bool FX_AcikPozisyonKapat(string sembol, decimal adet)
{
bool sonuc = false;
if (LastOrderSideForShort.Obj != Side.Buy && LastOrderSide.Obj != Side.Buy && AcigaSatisYapilsin)
{
LastOrderSide.Obj = Side.All;
SendMarketOrder(sembol, adet, OrderSide.Buy, includeAfterSession:AksamSeansiniDahilEt);
Debug("Açık Poz. Kapat [ " + adet + " adet ]");
LastOrderSideForShort.Obj = Side.Buy;
LastOrderSide.Obj = Side.Sell;
sonuc = true;
}
return sonuc;
}
public override void OnOrderUpdate(IOrder order)
{
// Gerekli - Timestamp
if (order.OrdStatus.Obj == OrdStatus.Filled)
{
if (timestampDict.ContainsKey(order.CliOrdID))
{
timestampDict.Remove(order.CliOrdID);
Debug("Timestamp hatasına takılan emriniz gerçekleşti.");
}
}
if (order.OrdStatus.Obj == OrdStatus.Rejected)
{
if (!timestampDict.ContainsKey(order.CliOrdID))
{
OrderListTimestamp orderList = new OrderListTimestamp();
orderList.ID = order.CliOrdID;
orderList.Sembol = order.Symbol;
orderList.Adet = order.OrderQty;
orderList.Fiyat = order.Price;
orderList.EmirTipi = order.OrdType;
orderList.TetiklenmeZamani = DateTime.Now;
orderList.Sayac = 0;
orderList.AktifMI = false;
if (order.Side.Obj == Side.Buy)
{
orderList.orderSide = OrderSide.Buy;
orderList.EmirYonu = "Alış";
}else
{
orderList.orderSide = OrderSide.Sell;
orderList.EmirYonu = "Satış";
}
timestampDict[order.CliOrdID] = orderList;
}
if (order.Text.Contains("Timestamp"))
{
if (timestampDict.ContainsKey(order.CliOrdID))
{
if (timestampDict[order.CliOrdID].Sayac < AyniEmirKacSeferGonderilsin)
{
timestampDict[order.CliOrdID].TetiklenmeZamani = DateTime.Now.AddSeconds(KacSaniyeSonraTekrarGonderilsin);
timestampDict[order.CliOrdID].Sayac++;
timestampDict[order.CliOrdID].AktifMI = true;
Debug("Emir Timestamp hatasından dolayı iptal oldu tekrar gönderilecek");
}else
{
timestampDict.Remove(order.CliOrdID);
Debug("Aynı emir üst üste " + AyniEmirKacSeferGonderilsin + " defa gönderildi.");
}
}
}
}
}
// #Gerekli - Timestamp
public override void OnSyntheticOrderTriggered(SyntheticAlgoOrder sOrder)
{
if (sOrder.EnableOrderSending)
{
if (AcigaSatisYapilsin)
{
SendOrderSequential(true, Side.Buy);
SendOrderSequentialForShort(true, Side.Sell);
}
Debug("Sentetik emir tetiklendi");
}
}
// #Gerekli açığa satış
}
}
merhaba,çok güzel olmuş ellerinize sağlık fakat parametleri hangı aralıklara arasında analiz yaptırmak lazım söyleyebilirseniz sevinirim
https://www.algokutuphanesi.com/Sistem/Detay/Matriks/FIRSAT%C3%87ITREND%C4%B0FL%C4%B0S%C4%B0STEMANILBy linkteki dosyanın optimizasyon parametrelerini kullanabilirsiniz.
vermiş olduğunuz linkteki optimizasyon parametrelerini de ekleyince devasa olasılıklar çıkıyor. Bir ilerleme gerçekleştirilemiyor. Değişken sayısı çok fazla. Bir yolu yöntemi yok mudur?
Aşiyan Hanım merhaba, Burada Açığa satta Minör trend yok... Bize gönderdiğinizde de yok bu formül normal olarak hatalı bize göre.
Merhaba, https://www.algokutuphanesi.com/Sistem/Detay/Matriks/FIRSAT%C3%87ITREND%C4%B0FL%C4%B0S%C4%B0STEMANILBy paylaştığım linkte bulunan formülle aynıdır. Bahsettiğiniz durum farklı ise mail yönlendirebilirsiniz.
merhaba; METASTOCK dilinde yazılan MOV(C,opt1,VAR)>(OTT(C,opt1,3)+REF(OTT(C,opt1,3)-(OTT(C,opt1,7)-OTT(C,opt1,3)),-100))/2 AND ile Matriks C# dilinde yazılımında matematiksel bir hata olabilir mi? if (ott5.Value[1][ott5.CurrentIndex] > (ott5.Value[0][ott5.CurrentIndex] + ott5.Value[0][ott5.CurrentIndex -100] - ott6.Value[0][ott6.CurrentIndex -100] + ott5.Value[0][ott5.CurrentIndex - 100]) / 2 /// FIRSAT.I trend formülünün tamamından 100 değerini çıkarmak ile her bir değerden çıkarmak arasında matematiksel hata oluşa bilir. teşekkürler.
Matematiksel anlamda bakıldığında Metastock dilinde 1 adet ott değerinden diğer 2 adet ott değerinin çıkarılması ve bu çıkarma işleminin 100 bar geriden yapılması ile C# diline çevrildiğinde her bir ott nin tek tek 100 bar gerideki değerini alarak işlem yapmasının sonucu değiştirmeyecektir. Bir nevi (a-b-c)x100 ifadesinin a x 100 - b x 100 - c x 100 e dönüştürülmesi aslında.
Bunun 5 dk.lık tahmini Optimizasyon aralıklarını nasıl bulabiliriz. Bunlar bizim için çok zor.
Eğer bu c# diline karşılık gelen metastock formülünü bilirsek sistemi anlamak daha kolay olur. Tam karşılığı gelen metastock formülünü paylaşabilmeniz mümkünmü?
Ayrıca matriks primeda çalıştırılan aynı parametreler ile matrikiq da farklı sonuçlar alıyorum nedeni nedir?