Merhabalar,
Dilerseniz aşağıdaki stratejiyi inceleyip kullanabilirsiniz.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Matriks.Data.Symbol;
using Matriks.Engines;
using Matriks.Indicators;
using Matriks.Lean.Algotrader.AlgoBase;
using Matriks.Lean.Algotrader.Models;
using Matriks.Trader.Core;
using Matriks.Trader.Core.Fields;
namespace Matriks.Lean.Algotrader
{
public class ErtesiGunGonder : MatriksAlgo
{
[SymbolParameter("GARAN")]
public string Symbol;
[Parameter(SymbolPeriod.Min)]
public SymbolPeriod SymbolPeriod;
[Parameter(1)]
public decimal BuyOrderQuantity;
[Parameter(1)]
public decimal SellOrderQuantity;
[Parameter(10)]
public int ATRPeriod;
[Parameter(10)]
public int MovPeriod;
[Parameter(3)]
public decimal Coefficient;
[Parameter(MovMethod.E)]
public MovMethod MovMethod;
PMaxIndicator pmax;
public override void OnInit()
{
AddSymbol(Symbol, SymbolPeriod);
pmax = PMaxIndicators(Symbol, SymbolPeriod, ATRPeriod, MovPeriod, (decimal) Coefficient, MovMethod);
WorkWithPermanentSignal(true);
SendOrderSequential(true, Side.Buy);
SendOrderSequentialForShort(true, Side.All);
}
public override void OnDataUpdate(BarDataEventArgs barData)
{
var _dTime = barData.BarData.Dtime;
if (_dTime.Hour < 18)
{
if (LastOrderSideForShort.Obj == Side.Buy)
{
SendMarketOrder(Symbol, BuyOrderQuantity, OrderSide.Buy);
Debug("Alış emri gonderildi.");
}else if (LastOrderSideForShort.Obj == Side.Sell)
{
SendMarketOrder(Symbol, SellOrderQuantity, OrderSide.Sell);
Debug("Satış emri gonderildi.");
}
LastOrderSideForShort.Obj = Side.All;
}
if (CrossAbove(pmax.KLine, pmax.StLine))
{
if (_dTime.Hour >= 18)
{
LastOrderSideForShort.Obj = Side.Buy;
}else
{
SendMarketOrder(Symbol, BuyOrderQuantity, (OrderSide.Buy));
Debug("Alış emri gonderildi.");
}
}
if (CrossBelow(pmax.KLine, pmax))
{
if (_dTime.Hour >= 18)
{
LastOrderSideForShort.Obj = Side.Sell;
}else
{
SendMarketOrder(Symbol, SellOrderQuantity, (OrderSide.Sell));
Debug("Satış emri gonderildi.");
}
}
}
public override void OnOrderUpdate(IOrder order)
{
if (order.OrdStatus.Obj == OrdStatus.Filled)
{
SendOrderSequentialForShort(true, Side.All);
}
}
}
}
İyi çalışmalar.