Merhaba,
Son 100 barda kesişim olan sembollerin en son kaç bar önce kesiştiğini raporlayan explorer kodu aşağıdaki gibidir.
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.Lean.Algotrader.AlgoBase;
using Matriks.Lean.Algotrader.Models;
using Matriks.Indicators;
namespace Matriks.Lean.Algotrader
{
public class Son100Bar : Explorer
{
MOST most;
public override void OnInit()
{
most = MOSTIndicator(Symbol, SymbolPeriod, OHLCType.Close, 3, 2, MovMethod.Exponential);
AddColumns(5);
SetColumnText(0, "Kaç Bar Önce");
SetColumnText(1, "prev Most");
SetColumnText(2, "prev Mov");
SetColumnText(3, "Most");
SetColumnText(4, "Mov");
}
int _kacBarOnce = 0;
bool _islem = false;
decimal _prevMost = 0, _most = 0, _prevMov = 0, _mov = 0;
public override bool OnExplorer(List<BarDataEventArgs> bardatas)
{
var barDataModel = GetBarData();
var _count = barDataModel.Close.Count;
var index = bardatas.FirstOrDefault().BarDataIndex;
for (var i = 100; i >= 1; i--)
{
if (most.Value[0][index - (i + 1)] >most.Value[1][index - (i + 1)] && most.Value[0][index - i] <most.Value[1][index - i])
{
_kacBarOnce = i;
_islem = true;
_prevMost = most.Value[0][index - (i + 1)];
_prevMov = most.Value[1][index - (i + 1)];
_most = most.Value[0][index - i];
_mov = most.Value[1][index - i];
}
}
if(CrossAbove(most.ExMOV, most)){
_islem=true;
_kacBarOnce=0;
}
SetColumn(0, _kacBarOnce);
SetColumn(1, Math.Round(_prevMost, 2));
SetColumn(2, Math.Round(_prevMov, 2));
SetColumn(3, Math.Round(_most, 2));
SetColumn(4, Math.Round(_mov, 2));
if (_islem)
return true;
return false;
}
}
}