Merhabalar,
Macd için pozitif ve negatif uyumsuzluk tarama kodları aşağıdadır.
İyi çalışmalar
Macd Pozitif Uyumsuzluk:
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 RsiPU : Explorer
{
[Parameter(26)]
public int LongPeriod;
[Parameter(12)]
public int ShortPeriod;
[Parameter(9)]
public int TriggerPeriod;
[Parameter(50)]
public int BarSayısı;
MACD macd;
public override void OnInit()
{
macd = MACDIndicator(Symbol, SymbolPeriod, OHLCType.Close, LongPeriod, ShortPeriod, TriggerPeriod);
AddColumns(5);
SetColumnText(0, "Bar Count");
SetColumnText(1, "Ref Low");
SetColumnText(2, "Close");
SetColumnText(3, "LLV(Macd)");
SetColumnText(4, "Macd");
}
public override bool OnExplorer(List<BarDataEventArgs> bardatas)
{
var bardata = GetBarData();
var BarDataIndex = bardatas.FirstOrDefault().BarDataIndex;
var LLV = LowestLow(macd, BarSayısı);
if (LLV < macd.CurrentValue)
{
for (int i = 1; i <= BarSayısı; i++)
{
int index = Ref(macd, i) == LLV? i:0;
if (index>1)
{
var refLow = bardata.Low[BarDataIndex - index];
var close = bardata.Close[BarDataIndex];
if (refLow >close)
{
SetColumn(0, index);
SetColumn(1, refLow);
SetColumn(2, close);
SetColumn(3, Math.Round(LLV, 2));
SetColumn(4, Math.Round(macd.CurrentValue, 2));
return true;
}
}
}
}
return false;
}
}
}
Macd Negatif Uyumsuzluk:
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 MacdNU : Explorer
{
[Parameter(26)]
public int LongPeriod;
[Parameter(12)]
public int ShortPeriod;
[Parameter(9)]
public int TriggerPeriod;
[Parameter(50)]
public int BarSayısı;
MACD macd;
public override void OnInit()
{
macd = MACDIndicator(Symbol, SymbolPeriod, OHLCType.Close, LongPeriod, ShortPeriod, TriggerPeriod);
AddColumns(5);
SetColumnText(0, "Bar Count");
SetColumnText(1, "Ref High");
SetColumnText(2, "Close");
SetColumnText(3, "HHV(Macd)");
SetColumnText(4, "Macd");
}
public override bool OnExplorer(List<BarDataEventArgs> bardatas)
{
var bardata = GetBarData();
var BarDataIndex = bardatas.FirstOrDefault().BarDataIndex;
var HHV = HighestHigh(macd, BarSayısı);
if (HHV > macd.Macd.CurrentValue)
{
for (int i = 1; i <= BarSayısı; i++)
{
int index = Ref(macd, i) == HHV? i:0;
if (index>1)
{
var refHigh = bardata.High[BarDataIndex - index];
var close = bardata.Close[BarDataIndex];
if (refHigh <close)
{
SetColumn(0, index);
SetColumn(1, refHigh);
SetColumn(2, close);
SetColumn(3, Math.Round(HHV, 2));
SetColumn(4, Math.Round(macd.Macd.CurrentValue, 2));
return true;
}
}
}
}
return false;
}
}
}