Merhabalar,
Dilerseniz aşağıdaki sistemi inceleyip test edebilirsiniz.
***STRATEJİLERİ TEST/DENEME ORTAMINDA SINAMADAN VE SİZİN İSTEDİĞİNİZ ŞEKİLDE ÇALIŞTIĞINA EMİN OLMADAN GERÇEK ORTAMDA HİÇBİR ZAMAN ÇALIŞTIRMAYINIZ ***
using System;
using System.Collections.Generic;
using System.Linq;
using Matriks;
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;
using Matriks.AI;
using Matriks.AI.AiParameters;
using Matriks.AI.Data;
using Matriks.Trader.Core.TraderModels;
namespace Matriks.Lean.Algotrader
{
public class Anıl_Ozeksi_Sistem_2_1 : MatriksAlgo
{
// Strateji çalıştırılırken kullanacağımız parametreler. Eğer sembolle ilgili bir parametre ise,
// "SymbolParameter" ile, değilse "Parameter" ile tanımlama yaparız. Parantez içindeki değerler default değerleridir.
[SymbolParameter("GARAN")]
public string Symbol;
[Parameter(SymbolPeriod.Min)]
public SymbolPeriod SymbolPeriod1;
[Parameter(1)]
public decimal OrderQuantity;
//LONG parametreleri
[Parameter(20)]
public int OttPeriod1;
[Parameter(7)]
public decimal OttOpt1;
[Parameter(MovMethod.VAR)]
public MovMethod OttMovMethod;
[Parameter(true)]
public bool OttSupportLine;
[Parameter(20)]
public int OttPeriod2;
[Parameter(0.7)]
public decimal OttOpt2;
[Parameter(200)]
public int StochasticslowPeriodK1;
[Parameter(400)]
public int StochasticslowPeriodSlowK1;
[Parameter(111)]
public int StochasticslowPeriodD1;
[Parameter(MovMethod.VAR)]
public MovMethod StochasticslowMovMethod;
[Parameter(21)]
public int HighesthighPeriod;
[Parameter(2)]
public int OttPeriod3;
[Parameter(0.41)]
public decimal OttOpt3;
[Parameter(10)]
public int HighesthighPeriod2;
[Parameter(20)]
public int OttPeriod4;
[Parameter(3.02)]
public decimal OttOpt4;
[Parameter(20)]
public int OttPeriod5;
[Parameter(1)]
public decimal OttOpt5;
[Parameter(500)]
public int StochasticslowPeriodK2;
[Parameter(200)]
public int StochasticslowPeriodSlowK2;
[Parameter(111)]
public int StochasticslowPeriodD2;
[Parameter(21)]
public int HighesthighPeriod3;
[Parameter(2)]
public int OttPeriod6;
[Parameter(0.41)]
public decimal OttOpt6;
[Parameter(20)]
public int HighesthighPeriod4;
//LONG kapama Parametreleri
[Parameter(20)]
public int OttPeriod7;
[Parameter(7.525)]
public decimal OttOpt7;
[Parameter(40)]
public int OttPeriod8;
[Parameter(0.7)]
public decimal OttOpt8;
[Parameter(500)]
public int StochasticslowPeriodK3;
[Parameter(300)]
public int StochasticslowPeriodSlowK3;
[Parameter(111)]
public int StochasticslowPeriodD3;
[Parameter(21)]
public int LowestLowPeriod;
[Parameter(2)]
public int OttPeriod9;
[Parameter(0.41)]
public decimal OttOpt9;
[Parameter(20)]
public int LowestLowPeriod2;
[Parameter(20)]
public int OttPeriod10;
[Parameter(1)]
public decimal OttOpt10;
[Parameter(500)]
public int StochasticslowPeriodK4;
[Parameter(200)]
public int StochasticslowPeriodSlowK4;
[Parameter(111)]
public int StochasticslowPeriodD4;
[Parameter(21)]
public int LowestLowPeriod3;
[Parameter(2)]
public int OttPeriod11;
[Parameter(0.41)]
public decimal OttOpt11;
[Parameter(20)]
public int LowestLowPeriod4;
[Parameter(20)]
public int TottPeriod1;
[Parameter(1)]
public decimal TottOpt1;
[Parameter(0.0008)]
public decimal TottTwinOttCoef1;
[Parameter(MovMethod.VAR)]
public MovMethod TottMovMethod1;
[Parameter(40)]
public int TottPeriod2;
[Parameter(0.7)]
public decimal TottOpt2;
[Parameter(0.001)]
public decimal TottTwinOttCoef2;
[Parameter(MovMethod.VAR)]
public MovMethod TottMovMethod2;
[Parameter(40)]
public int TottPeriod3;
[Parameter(0.6)]
public decimal TottOpt3;
[Parameter(0.0008)]
public decimal TottTwinOttCoef3;
[Parameter(40)]
public int TottPeriod4;
[Parameter(0.6)]
public decimal TottOpt4;
[Parameter(0.0008)]
public decimal TottTwinOttCoef4;
[Parameter(8)]
public decimal izsuren;
// Gerekli zaman aralığı
[Parameter("09:36: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);
}
// # Gerekli zaman aralığı
OTT ott;
OTT ott2;
OTT ott3;
OTT ott4;
OTT ott5;
OTT ott6;
OTT ott7;
OTT ott9;
OTT ott11;
HighestHigh highestHigh;
HighestHigh highestHigh2;
HighestHigh highestHigh3;
HighestHigh highestHigh4;
LowestLow lowestLow;
LowestLow lowestLow2;
LowestLow lowestLow3;
LowestLow lowestLow4;
StochasticSlow stochasticSlow;
StochasticSlow stochasticSlow2;
StochasticSlow stochasticSlow3;
StochasticSlow stochasticSlow4;
TOTT tott;
TOTT tott2;
TOTT tott3;
TOTT tott4;
public override void OnDataUpdate(BarDataEventArgs barData)
{
var zamanKontrolu = FX_ZamanindaMI(barData.BarData.Dtime);
var barData1 = GetBarData(Symbol, SymbolPeriod1);
var H = GetSelectedValueFromBarData(barData1, OHLCType.High);
var L = GetSelectedValueFromBarData(barData1, OHLCType.Low);
// LONG
if (ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex] && zamanKontrolu)
{
if (tott.Value[0][tott.CurrentIndex] > tott.Value[1][tott.CurrentIndex]
&& stochasticSlow.Value[0][stochasticSlow.CurrentIndex] > stochasticSlow.Value[1][stochasticSlow.CurrentIndex]
&& H > ott3.Value[0][ott3.CurrentIndex]
&& H > highestHigh2.Value[0][highestHigh2.CurrentIndex - 1]
&& zamanKontrolu)
{
SendMarketOrder(Symbol, OrderQuantity, OrderSide.Buy);
TrailingStopLoss(Symbol, SyntheticOrderPriceType.Percent,izsuren);
Debug("Alış Emri Gönderildi.");
}
}
else
{
if (ott4.Value[1][ott4.CurrentIndex] > ott4.Value[0][ott4.CurrentIndex] && tott2.Value[0][tott2.CurrentIndex] > tott2.Value[1][tott2.CurrentIndex]
&& stochasticSlow2.Value[0][stochasticSlow2.CurrentIndex] > stochasticSlow2.Value[1][stochasticSlow2.CurrentIndex]
&& H > ott6.Value[0][ott6.CurrentIndex]
&& H > highestHigh4.Value[0][highestHigh4.CurrentIndex - 1]
&& zamanKontrolu)
{
SendMarketOrder(Symbol, OrderQuantity, OrderSide.Buy);
TrailingStopLoss(Symbol, SyntheticOrderPriceType.Percent,izsuren);
Debug("Alış Emri Gönderildi.");
}
}
//LONG KAPAMA
if (ott7.Value[1][ott7.CurrentIndex] > ott7.Value[0][ott7.CurrentIndex] && zamanKontrolu)
{
if (tott3.Value[0][tott3.CurrentIndex] < tott3.Value[2][tott3.CurrentIndex]
&& stochasticSlow3.Value[0][stochasticSlow3.CurrentIndex] < stochasticSlow3.Value[1][stochasticSlow3.CurrentIndex]
&& L < ott9.Value[0][ott9.CurrentIndex]
&& L < lowestLow2.Value[0][lowestLow2.CurrentIndex - 1]
&& zamanKontrolu)
{
SendMarketOrder(Symbol, OrderQuantity, OrderSide.Sell);
TrailingStopLoss(Symbol, SyntheticOrderPriceType.Percent,izsuren);
Debug("Satış Emri Gönderildi.");
}
}
else
{
if (tott4.Value[0][tott4.CurrentIndex] < tott4.Value[2][tott4.CurrentIndex]
&& stochasticSlow4.Value[0][stochasticSlow4.CurrentIndex] < stochasticSlow4.Value[1][stochasticSlow4.CurrentIndex]
&& L < ott11.Value[0][ott11.CurrentIndex]
&& L < lowestLow4.Value[0][lowestLow4.CurrentIndex - 1]
&& zamanKontrolu)
{
SendMarketOrder(Symbol, OrderQuantity, OrderSide.Sell);
TrailingStopLoss(Symbol, SyntheticOrderPriceType.Percent,izsuren);
Debug("Satış Emri Gönderildi.");
}
}
}
public override void OnInit()
{
lowestLow = LowestLowIndicator(Symbol, SymbolPeriod1, LowestLowPeriod);
lowestLow2 = LowestLowIndicator(Symbol, SymbolPeriod1, LowestLowPeriod2);
lowestLow3 = LowestLowIndicator(Symbol, SymbolPeriod1, LowestLowPeriod3);
lowestLow4 = LowestLowIndicator(Symbol, SymbolPeriod1, LowestLowPeriod4);
highestHigh = HighestHighIndicator(Symbol, SymbolPeriod1, HighesthighPeriod);
highestHigh2 = HighestHighIndicator(Symbol, SymbolPeriod1, HighesthighPeriod2);
highestHigh3 = HighestHighIndicator(Symbol, SymbolPeriod1, HighesthighPeriod3);
highestHigh4 = HighestHighIndicator(Symbol, SymbolPeriod1, HighesthighPeriod4);
ott = OTTIndicator(Symbol, SymbolPeriod1, OHLCType.Close, OttPeriod1, OttOpt1, OttMovMethod, OttSupportLine);
ott2 = OTTIndicator(Symbol, SymbolPeriod1, OHLCType.Close, OttPeriod2, OttOpt2, OttMovMethod, OttSupportLine);
ott3 = OTTIndicator(highestHigh, OttPeriod3, OttOpt3, OttMovMethod, OttSupportLine);
ott4 = OTTIndicator(Symbol, SymbolPeriod1, OHLCType.Close, OttPeriod4, OttOpt4, OttMovMethod, OttSupportLine);
ott5 = OTTIndicator(Symbol, SymbolPeriod1, OHLCType.Close, OttPeriod5, OttOpt5, OttMovMethod, OttSupportLine);
ott6 = OTTIndicator(highestHigh3, OttPeriod6, OttOpt6, OttMovMethod, OttSupportLine);
ott7 = OTTIndicator(Symbol, SymbolPeriod1, OHLCType.Close, OttPeriod7, OttOpt7, OttMovMethod, OttSupportLine);
ott9 = OTTIndicator(lowestLow, OttPeriod9, OttOpt9, OttMovMethod, OttSupportLine);
ott11 = OTTIndicator(lowestLow3, OttPeriod11, OttOpt11, OttMovMethod, OttSupportLine);
stochasticSlow = StochasticSlowIndicator(Symbol, SymbolPeriod1, OHLCType.Close, StochasticslowPeriodK1, StochasticslowPeriodD1, StochasticslowPeriodSlowK1, StochasticslowMovMethod);
stochasticSlow2 = StochasticSlowIndicator(Symbol, SymbolPeriod1, OHLCType.Close, StochasticslowPeriodK2, StochasticslowPeriodD2, StochasticslowPeriodSlowK2, StochasticslowMovMethod);
stochasticSlow3 = StochasticSlowIndicator(Symbol, SymbolPeriod1, OHLCType.Close, StochasticslowPeriodK3, StochasticslowPeriodD3, StochasticslowPeriodSlowK3, StochasticslowMovMethod);
stochasticSlow4 = StochasticSlowIndicator(Symbol, SymbolPeriod1, OHLCType.Close, StochasticslowPeriodK4, StochasticslowPeriodD4, StochasticslowPeriodSlowK4, StochasticslowMovMethod);
tott = TOTTIndicator(Symbol, SymbolPeriod1, OHLCType.Close, TottPeriod1, TottOpt1, TottTwinOttCoef1, TottMovMethod1);
tott2 = TOTTIndicator(Symbol, SymbolPeriod1, OHLCType.Close, TottPeriod2, TottOpt2, TottTwinOttCoef2, TottMovMethod2);
tott3 = TOTTIndicator(Symbol, SymbolPeriod1, OHLCType.Close, TottPeriod3, TottOpt3, TottTwinOttCoef3, TottMovMethod2);
tott4 = TOTTIndicator(Symbol, SymbolPeriod1, OHLCType.Close, TottPeriod4, TottOpt4, TottTwinOttCoef4, TottMovMethod2);
SendOrderSequential(true, Side.Buy);
WorkWithPermanentSignal(true);
}
}
// ///AL
//if(MOV(C,20,VAR)>OTT(C,20,7.525),
//MOV(C,20,VAR)>OTT(C,20,0.7) AND
//STOSK(200,400,111,VAR)>STOSD(200,400,111,VAR) AND
//H>OTT (HHV(H,21),2,0.41) AND
//H>REF(HHV(H,10),-1),
//MOV(C,20,VAR)>OTT(C,20,3.02) AND
//MOV(C,20,VAR)>OTT(C,20,1) AND
//STOSK(500,200,111,VAR)>STOSD(500,200,111,VAR) AND
//H>OTT (HHV(H,21),2,0.41) AND
//H>REF(HHV(H,20),-1)) AND
//((HOUR()=10 AND MINUTE()>=05) OR HOUR()>=11) AND ((HOUR()=17 AND MINUTE()<=55) OR HOUR()<=16)
// //SAT
//if(MOV(C,20,VAR)>OTT(C,20,7.525),
//MOV(C,40,VAR)<OTT(C,40,0.7) AND
//STOSK(500,300,111,VAR)<STOSD(500,300,111,VAR) AND
//L<OTT(LLV(L,21),2,0.41) AND
//L<REF(LLV(L,20),-1),
//MOV(C,20,VAR)<OTT(C,20,1) AND
//STOSK(500,200,111,VAR)<STOSD(500,200,111,VAR) AND
//L<OTT(LLV(L,21),2,0.41) AND
//L<REF(LLV(L,20),-1)) AND
//((HOUR()=10 AND MINUTE()>=05) OR HOUR()>=11) AND ((HOUR()=17 AND MINUT