Merhabalar,
İstediğiniz strateji aşağıda mevcuttur.
Dilerseniz spot dilerseniz vadeli sembollerde kullanabilirsiniz.
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;
namespace Matriks.Lean.Algotrader
{
/*AL
if(MOV(C,opt1,VAR)>OTT(C,opt1,7),
MOV(C,opt1,VAR)>OTT(C,opt1,opt2) AND
STOSK(opt3,opt4,111,VAR)>STOSD(opt3,opt4,111,VAR) AND
H>REF(HHV(H,20),-1),
MOV(C,opt1,VAR)>OTT(C,opt1,3.5) AND
STOSK(opt3,opt4,111,VAR)>STOSD(opt3,opt4,111,VAR) AND
H>REF(HHV(H,20),-1))
SAT
if(MOV(C,opt1,VAR)>OTT(C,opt1,7),
MOV(C,opt1,VAR)<OTT(C,opt1,opt2) AND
STOSK(opt3,opt4,111,VAR)<STOSD(opt3,opt4,111,VAR) AND
L<REF(LLV(L,20),-1),
MOV(C,opt1,VAR)<OTT(C,opt1,opt2) AND
STOSK(opt3,opt4,111,VAR)<STOSD(opt3,opt4,111,VAR) AND
L<REF(LLV(L,20),-1))
*/
public class SablonV1 : MatriksAlgo
{
[SymbolParameter("FGARAN")]
public string Symbol;
[Parameter(SymbolPeriod.Min5)]
public SymbolPeriod SymbolPeriod;
[Parameter(5)]
public decimal BuyOrderQuantity;
[Parameter(5)]
public decimal SellOrderQuantity;
[Parameter(20)]
public int OttPeriod1;
[Parameter(6)]
public decimal OttOpt1;
[Parameter(MovMethod.VAR)]
public MovMethod OttMovMethod1;
[Parameter(true)]
public bool OttSupportLine1;
[Parameter(20)]
public int OttPeriod2;
[Parameter(0.7)]
public decimal OttOpt2;
[Parameter(200)]
public int StochasticslowPeriodK1;
[Parameter(111)]
public int StochasticslowPeriodD1;
[Parameter(400)]
public int StochasticslowPeriodSlowK1;
[Parameter(MovMethod.VAR)]
public MovMethod StochasticslowMovMethod1;
[Parameter(10)]
public int H1;
[Parameter(500)]
public int StochasticslowPeriodK2;
[Parameter(111)]
public int StochasticslowPeriodD2;
[Parameter(200)]
public int StochasticslowPeriodSlowK2;
[Parameter(10)]
public int H2;
[Parameter(40)]
public int OttPeriod5;
[Parameter(0.6)]
public decimal OttOpt5;
[Parameter(500)]
public int StochasticslowPeriodK3;
[Parameter(111)]
public int StochasticslowPeriodD3;
[Parameter(200)]
public int StochasticslowPeriodSlowK3;
[Parameter(10)]
public int L1;
[Parameter(10)]
public int L2;
[Parameter(3)]
public int KaldiracOrani;
OTT ott;
OTT ott2;
OTT ott3;
OTT ott4;
OTT ott5;
OTT ott6;
StochasticSlow stochasticSlow;
StochasticSlow stochasticSlow2;
StochasticSlow stochasticSlow3;
StochasticSlow stochasticSlow4;
HighestHigh HHV;
HighestHigh HHV1;
LowestLow LLV;
LowestLow LLV1;
public override void OnDataUpdate(BarDataEventArgs barData)
{
var barData1 = GetBarData(Symbol, SymbolPeriod);
var h = GetSelectedValueFromBarData(barData1, OHLCType.High);
var l = GetSelectedValueFromBarData(barData1, OHLCType.Low);
//AL KOŞULU
if (ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex]) // if(MOV(C,opt1,VAR)>OTT(C,opt1,7)
{
if (ott2.Value[1][ott2.CurrentIndex] > ott2.Value[0][ott2.CurrentIndex] // MOV(C,opt1,VAR)>OTT(C,opt1,opt2)
&& stochasticSlow.Value[0][stochasticSlow.CurrentIndex] > stochasticSlow.Value[1][stochasticSlow.CurrentIndex] //AND STOSK(opt3,opt4,111,VAR)>STOSD(opt3,opt4,111,VAR)
&& h>HHV.Value[0][HHV.CurrentIndex -1]) // AND H>REF(HHV(H,10),-1)
{
FX_Alis();
}
}
else
{
if (ott2.Value[1][ott2.CurrentIndex] > ott2.Value[0][ott2.CurrentIndex] // MOV(C, opt1, VAR) >OTT(C, opt1, 3.5) AND
&& stochasticSlow2.Value[0][stochasticSlow2.CurrentIndex] > stochasticSlow2.Value[1][stochasticSlow2.CurrentIndex] //STOSK(opt3, opt4, 111, VAR) >STOSD(opt3, opt4, 111, VAR) AND
&& h>HHV1.Value[0][HHV1.CurrentIndex -1]) //H>REF(HHV(H, 10), -1))
{
FX_Alis();
}
}
// SAT KOŞULU
if (ott.Value[1][ott.CurrentIndex] > ott.Value[0][ott.CurrentIndex]) //if(MOV(C,opt1,VAR)>OTT(C,opt1,7),
{
if (ott2.Value[1][ott2.CurrentIndex] < ott2.Value[0][ott2.CurrentIndex] //MOV(C,opt1,VAR)<OTT(C,opt1,opt2) AND
&& stochasticSlow2.Value[0][stochasticSlow2.CurrentIndex] <stochasticSlow2.Value[1][stochasticSlow2.CurrentIndex] //STOSK(opt3,opt4,111,VAR)<STOSD(opt3,opt4,111,VAR) AND
&& l<LLV.Value[0][LLV.CurrentIndex -1]) //L<REF(LLV(L,10),-1),
{
FX_Satis();
}
}
else
{
if (ott2.Value[1][ott2.CurrentIndex] < ott2.Value[0][ott2.CurrentIndex] //MOV(C,opt1,VAR)<OTT(C,opt1,opt2) AND
&& stochasticSlow2.Value[0][stochasticSlow2.CurrentIndex] < stochasticSlow2.Value[1][stochasticSlow2.CurrentIndex] //STOSK(opt3,opt4,111,VAR)<STOSD(opt3,opt4,111,VAR) AND
&& l<LLV1.Value[0][LLV1.CurrentIndex -1]) //L<REF(LLV(L,10),-1))
{
FX_Satis();
}
}
}
public override void OnInit()
{
AddSymbol(Symbol, SymbolPeriod);
ott = OTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, OttPeriod1, OttOpt1, OttMovMethod1, OttSupportLine1);
ott2 = OTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, OttPeriod2, OttOpt2, OttMovMethod1, OttSupportLine1);
stochasticSlow = StochasticSlowIndicator(Symbol, SymbolPeriod, OHLCType.Close, StochasticslowPeriodK1, StochasticslowPeriodD1, StochasticslowPeriodSlowK1, StochasticslowMovMethod1);
stochasticSlow2 = StochasticSlowIndicator(Symbol, SymbolPeriod, OHLCType.Close, StochasticslowPeriodK2, StochasticslowPeriodD2, StochasticslowPeriodSlowK2, StochasticslowMovMethod1);
HHV = HighestHighIndicator(Symbol, SymbolPeriod, H1);
HHV1 = HighestHighIndicator(Symbol, SymbolPeriod, H2);
LLV = LowestLowIndicator(Symbol, SymbolPeriod, L1);
LLV1 = LowestLowIndicator(Symbol, SymbolPeriod, L2);
// Gerekli
WorkWithPermanentSignal(true);
if (AcigaSatisYapilsin)
{
SendOrderSequential(true, Side.Buy);
SendOrderSequentialForShort(true, Side.All);
}else
{
SendOrderSequential(true, Side.Buy);
}
// #Gerekli
// kaldıraç oranı
SetLeverage(Symbol, KaldiracOrani);
// kaldıraç tipi – true isolated, false cross
SetLeverageType(Symbol, false);
// Gerekli
}
[Parameter(false)]
public bool AcigaSatisYapilsin;
[Parameter(false)]
public bool AksamSeansiniDahilEt;
List<string> orderIDList = new List<string>();
public void FX_Alis()
{
string _orderID = string.Empty; ;
decimal _quantity = 0;
if (LastOrderSide.Obj != Side.Buy)
{
if (LastOrderSide.Obj == Side.All || !AcigaSatisYapilsin)
{
_orderID = SendMarketOrder(Symbol, BuyOrderQuantity, OrderSide.Buy, includeAfterSession:AksamSeansiniDahilEt);
_quantity = BuyOrderQuantity;
}else
{
if (LastOrderSideForShort.Obj == Side.All)
{
_orderID = SendMarketOrder(Symbol, BuyOrderQuantity, OrderSide.Buy, includeAfterSession:AksamSeansiniDahilEt);
_quantity = BuyOrderQuantity;
}else
{
_orderID = SendMarketOrder(Symbol, BuyOrderQuantity * 2, OrderSide.Buy, includeAfterSession:AksamSeansiniDahilEt);
_quantity = BuyOrderQuantity * 2;
}
}
if (_orderID != string.Empty && _quantity != 0)
{
orderIDList.Add(_orderID);
Debug("Alış emri gönderildi.[ " + _quantity + " adet ]");
LastOrderSide.Obj = Side.Buy;
LastOrderSideForShort.Obj = Side.Buy;
}
}
}
public void FX_Satis()
{
string _orderID = string.Empty; ;
decimal _quantity = 0;
if (LastOrderSide.Obj != Side.Sell)
{
if (LastOrderSide.Obj == Side.All || !AcigaSatisYapilsin)
{
_orderID = SendMarketOrder(Symbol, SellOrderQuantity, OrderSide.Sell, includeAfterSession:AksamSeansiniDahilEt);
_quantity = SellOrderQuantity;
}else
{
if (LastOrderSideForShort.Obj == Side.All)
{
_orderID = SendMarketOrder(Symbol, SellOrderQuantity, OrderSide.Sell, includeAfterSession:AksamSeansiniDahilEt);
_quantity = SellOrderQuantity;
}else
{
_orderID = SendMarketOrder(Symbol, SellOrderQuantity * 2, OrderSide.Sell, includeAfterSession:AksamSeansiniDahilEt);
_quantity = SellOrderQuantity * 2;
}
}
if (_orderID != string.Empty && _quantity != 0)
{
orderIDList.Add(_orderID);
Debug("Satış emri gönderildi.[ " + _quantity + " adet ]");
LastOrderSide.Obj = Side.Sell;
LastOrderSideForShort.Obj = Side.Sell;
}
}
}
public override void OnOrderUpdate(IOrder order)
{
if (order.OrdStatus.Obj == OrdStatus.Filled)
{
// Senntetik emirler tanımlanıyor
// StopLoss(Symbol, SyntheticOrderPriceType.Percent, 1);
// TakeProfit(Symbol, SyntheticOrderPriceType.Percent, 1);
if (!orderIDList.Contains(order.CliOrdID) && AcigaSatisYapilsin)
{
LastOrderSideForShort.Obj = Side.All;
Debug("Sentetik emir tetiklendi");
}
}
}
// #Gerekli
}
}
İyi çalışmalar.