Merhaba,
Aşağıdaki örnek çalışmayı inceleyiniz lütfen.
İyi çalışmalar.
using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using Matriks.Data.Identifiers;
using Matriks.Data.Symbol;
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;
using System.Windows.Media;
namespace Matriks.Lean.Algotrader
{
[IndicatorInformation("BuySellIcon", IndicatorDrawingArea.OnDataSeries)]
[IndicatorLineInformation(new []
{
"OTT (0,1) "
})]
public class BuySellIcon : MatriksIndicator
{
[DefaultValue(16)]
public int Period
{
get; set;
}
[DefaultValue(0.1)]
public decimal Percentage
{
get; set;
}
[DefaultValue(MovMethod.Variable)]
public MovMethod Method
{
get; set;
}
OTT ott;
public sealed override void OnInit()
{
ott = OTTIndicator(Symbol, SymbolPeriod, OHLCType.Close, Period, Percentage, MovMethod.VAR, true);
PointTitle.Add(0, new Dictionary<int, IIndicatorIcons>());
}
public override void OnDataUpdate(int currentBar, decimal inputValue, DateTime barDateTime)
{
SetLine(0, currentBar, 0);
//Seçilen sembolün bardatasına Instrument.SymbolBarData şeklinde ulaşabiliriz.
var barDataModel = Instrument.SymbolBarData;
// Bar Boyama
PaintBar(currentBar, Colors.White.ToString());
if (ott.ottLine.CurrentValue < ott.ottSupportLine.CurrentValue)
{
PaintBar(currentBar, Colors.Blue.ToString());
}
if (ott.ottLine.CurrentValue > ott.ottSupportLine.CurrentValue)
{
PaintBar(currentBar, Colors.Yellow.ToString());
}
// OTT ikonları
if (CrossAbove(ott.ottSupportLine, ott.ottLine))
{
var iconkonum = barDataModel.Low[currentBar];
SetPointTitle(0, currentBar, "AL", IconLocation.BelowTheChart, iconkonum, true, "GREEN");
}
else if (CrossBelow(ott.ottSupportLine, ott.ottLine))
{
var iconkonum = barDataModel.High[currentBar];
SetPointTitle(0, currentBar, "SAT", IconLocation.AboveTheChart, iconkonum, true, "RED");
}
}
}
}