Merhaba,
Aşağıdaki kodu inceleyip deneyebilirsiniz.
Explorer adının BolAtr olmasına dikkat ediniz.
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 BolAtr : Explorer
{
[Parameter(10)]
public int BollingerPeriod;
[Parameter(2)]
public decimal StSatma;
[Parameter(10)]
public int AtrPeriod;
BOLLINGER bollinger;
ATR atr;
public override void OnInit()
{
atr = ATRIndicator(Symbol, SymbolPeriod, OHLCType.Close, AtrPeriod);
bollinger = BollingerIndicator(Symbol, SymbolPeriod, OHLCType.Close, BollingerPeriod, StSatma, MovMethod.Simple);
AddColumns(3);
SetColumnText(0, "BBandTop");
SetColumnText(1, "BBand");
SetColumnText(2, "Atr");
}
public override bool OnExplorer(List<BarDataEventArgs> bardatas)
{
// BBandTop(C,10,S,2)-BBand(C,10,S,2)<=ATR(10)
var BBandTop=bollinger.Bollingerup.CurrentValue;
var BBand=bollinger.BollingerMid.CurrentValue;
var Atr=atr.CurrentValue;
SetColumn(0, Math.Round(bollinger.Bollingerup.CurrentValue, 4));
SetColumn(1, Math.Round(bollinger.BollingerMid.CurrentValue, 4));
SetColumn(2, Math.Round(atr.CurrentValue, 4));
if (BBandTop-BBand<=Atr)
return true;
return false;
}
}
}