Merhabalar,
Aşağıdaki sistemi inceleyebilirsiniz.
***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.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
{
public class OTS : MatriksAlgo
{
[SymbolParameter("FGARAN")]
public string Symbol;
[Parameter(SymbolPeriod.Min5)]
public SymbolPeriod SymbolPeriod;
[Parameter(5)]
public decimal BuyOrderQuantity;
[Parameter(5)]
public decimal SellOrderQuantity;
[Parameter(40)]
public int X1;
[Parameter(1)]
public decimal X2;
[Parameter(0.001d)]
public decimal X3;
[Parameter(MovMethod.VAR)]
public MovMethod MovMethod;
[Parameter(3)]
public int KaldiracOrani;
OTT ott;
MOV mov;
public override void OnDataUpdate(BarDataEventArgs barData)
{
decimal l1, l2, l3;
l1 = mov.CurrentValue;
l2 = ott.CurrentValue * (1 + X3);
l3 = ott.CurrentValue * (1 - X3);
if (CrossAbove(mov, l2))
{
FX_Alis();
}
if (CrossBelow(mov, l3))
{
FX_Satis();
}
}
public override void OnInit()
{
AddSymbol(Symbol, SymbolPeriod);
mov = MOVIndicator(Symbol, SymbolPeriod, OHLCType.Close, X1, MovMethod);
ott = OTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, X1, X2, MovMethod, true);
// 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.