Merhaba,
Her sembol için indikatöre kayıt olamamışsınız.(sadece Symbol değişkenine kayıt olunmuş)
mov = MOVIndicator(Symbol, SymbolPeriod, OHLCType.Close, 5, MovMethod.Exponential);
Aşağıdaki örneği inceleyebilirsiniz.
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using Matriks.Data.Symbol;
using System.Windows.Media;
using Matriks.Engines;
using Matriks.Indicators;
using Matriks.Symbols;
using Matriks.AlgoTrader;
using Matriks.Trader.Core;
using Matriks.Trader.Core.Fields;
using Matriks.Trader.Core.TraderModels;
using Matriks.Lean.Algotrader.AlgoBase;
using Matriks.Lean.Algotrader.Models;
using Matriks.Lean.Algotrader.Trading;
namespace Matriks.Lean.Algotrader
{
public class CokluSembolMost : MatriksAlgo
{
[Parameter(SymbolPeriod.Min15)]
public SymbolPeriod SymbolPeriod;
[Parameter(3)]
public int Period;
[Parameter(2)]
public decimal Percentage;
public class SembolDetay
{
public string Sembol
{
get; set;
}
public decimal Adet
{
get; set;
}
public OrderSide LastOrderSideNesne
{
get; set;
}
}
List<SembolDetay> SembolDetaylari = new List<SembolDetay>();
Dictionary<string, MOST> dic = new Dictionary<string, MOST>();
MOST most;
public override void OnInit()
{
SembolDetaylari.Add(new SembolDetay()
{
Sembol = "GARAN", Adet = 15, LastOrderSideNesne = OrderSide.Buy
});
SembolDetaylari.Add(new SembolDetay()
{
Sembol = "AKBNK", Adet = 25, LastOrderSideNesne = OrderSide.Buy
});
SembolDetaylari.Add(new SembolDetay()
{
Sembol = "TTKOM", Adet = 5, LastOrderSideNesne = OrderSide.Buy
});
SembolDetaylari.Add(new SembolDetay()
{
Sembol = "THYAO", Adet = 12, LastOrderSideNesne = OrderSide.Buy
});
foreach (var symbol in SembolDetaylari)
{
AddSymbol(symbol.Sembol, SymbolPeriod);
most = MOSTIndicator(symbol.Sembol, SymbolPeriod, OHLCType.Close, Period, Percentage, MovMethod.Exponential);
dic.Add(symbol.Sembol, most);
}
WorkWithPermanentSignal(true);
SendOrderSequential(false);
}
public override void OnDataUpdate(BarDataCurrentValues barDataCurrentValues)
{
var barSembol = barDataCurrentValues.LastUpdate.SymbolName;
if (dic.ContainsKey(barSembol))
{
var sembolDetay = SembolDetaylari.FirstOrDefault(x => x.Sembol == barSembol);
if (sembolDetay != null)
{
var mostvalue = dic[barSembol];
if (CrossAbove(mostvalue.ExMOV, mostvalue) &&
sembolDetay.LastOrderSideNesne != OrderSide.Buy &&
sembolDetay.Adet != 0)
{
SendMarketOrder(barSembol, sembolDetay.Adet, (OrderSide.Buy));
sembolDetay.LastOrderSideNesne = OrderSide.Buy;
Debug("===================== ALIŞ =====================");
Debug("Sembol : " + barSembol);
Debug("Most.ExMov:" + Math.Round(mostvalue.ExMOV.CurrentValue, 4));
Debug("Most:" + Math.Round(mostvalue.CurrentValue, 4));
}
if (CrossBelow(mostvalue.ExMOV, mostvalue) &&
sembolDetay.LastOrderSideNesne != OrderSide.Sell &&
sembolDetay.Adet != 0)
{
SendMarketOrder(barSembol, sembolDetay.Adet, (OrderSide.Sell));
sembolDetay.LastOrderSideNesne = OrderSide.Sell;
Debug("===================== SATIŞ =====================");
Debug("Sembol : " + barSembol);
Debug("Most.ExMov:" + Math.Round(mostvalue.ExMOV.CurrentValue, 4));
Debug("Most:" + Math.Round(mostvalue.CurrentValue, 4));
}
}
}
}
}
}