29.07.2022
0
1
38
100

Wiiliams Vix Fix İndikatörü

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;

/*
▂ ▃ ▅ ▆ █ KRİPEX █ ▆ ▅ ▃ ▂ 

pd := input("LookBack Period Standard Deviation High",1,500,22);
bbl := input("Bolinger Band Length",1,500,20);
mult := input("Bollinger Band Standard Devaition",0,5,2);
lb := input("Look Back Period Percentile High",1,500,50);
ph := input("Highest Percentile - 0.90=90%, 0.95=95%, 0.99=99%",0,10,.85);
pl := input("Lowest Percentile - 1.10=90%, 1.05=95%, 1.01=99%",0,10,1.01);
wvf := ((hhv(c, pd)-l)/(hhv(c, pd)))*100;
rangeHigh := (hhv(wvf, lb)) * ph;
rangeLow := (llv(wvf, lb)) * pl;
kvf:=if(WVF>=RangeHigh or wvf>=bbandtop(wvf,bbl,s,mult), wvf,0);
wvf2:=if(WVF>=RangeHigh or wvf>=bbandtop(wvf,bbl,s,mult), 0,wvf);
kvf;
wvf2

Kıvanç Özbilgiç
https://drive.google.com/file/d/1Wsqrvgz5sSnNsC10Qd-iBEuwclbNDSJA/view
*/
namespace Matriks.Lean.Algotrader
{
	//Ilk parametre indikatörün adı, sınıfın adıyla aynı olmalıdır.
	//Ikinci parametre indikatörün Dataserisinin üzerine mi yeni pencereye mi ekleneceğini belirtir. Yeni pencere için ->IndicatorDrawingArea.NewWindow , Data Serisi için IndicatorDrawingArea.OnDataSeries
	[IndicatorInformationAttribute("WilliamsVixFix", IndicatorDrawingArea.NewWindow)]
	//Indikatörün çizgilerinin isimleri
	[IndicatorLineInformationAttribute(new []
		{
			"KVF (0,1,2,3)", "WVF (4,5)"
		}, new []
		{
			"#00CCFF", "#e600de"
		}, new []
		{
			false, false
		}, new []
		{
			5, 5
		}, new []
		{
			1, 1
		}
	)]

	public class WilliamsVixFix : MatriksIndicator
	{

		//Indicator opsiyon panelinde değerleri değiştirebildiğimiz parametreler. Int, Bool, Decimal ve Enum değerleri alabilir.Tüm değişken tiplerini DefaultValue ile tanımlarız. 
		[DefaultValue(22)]
		public int LookBackPeriodStandardDeviationHigh
		{
			get; set;
		}

		[DefaultValue(20)]
		public int BollingerBandLength
		{
			get; set;
		}

		[DefaultValue(0.2)]
		public decimal BollingerBandStandardDevaition
		{
			get; set;
		}

		[DefaultValue(50)]
		public int LookBackPeriodPercentileHigh
		{
			get; set;
		}

		// 0.90=90%, 0.95=95%, 0.99=99%
		[DefaultValue(0.85)]
		public decimal HighestPercentile
		{
			get; set;
		}

		// 1.10=90%, 1.05=95%, 1.01=99%
		[DefaultValue(1.01)]
		public decimal LowestPercentile
		{
			get; set;
		}

		BOLLINGER bollinger;

		LowestLow lowestLow;

		HighestHigh highestHigh;

		public sealed override void OnInit()
		{
			bollinger = new BOLLINGER(BollingerBandLength, BollingerBandStandardDevaition, MovMethod.Simple);

			lowestLow = new LowestLow(LookBackPeriodPercentileHigh);

			highestHigh = new HighestHigh(LookBackPeriodPercentileHigh);
		}

		public override void OnDataUpdate(int currentBar, decimal inputValue, DateTime barDateTime)
		{
			if (currentBar < LookBackPeriodPercentileHigh)
			{
				SetLine(0, currentBar, 0);
				SetLine(1, currentBar, 0);
				return ;
			}

			/*
			wvf := ((hhv(c, pd)-l)/(hhv(c, pd)))*100;
			
			rangeHigh := (hhv(wvf, lb)) * ph;
			rangeLow := (llv(wvf, lb)) * pl;
			
			kvf:=if(WVF>=RangeHigh or wvf>=bbandtop(wvf,bbl,s,mult), wvf,0);
			wvf2:=if(WVF>=RangeHigh or wvf>=bbandtop(wvf,bbl,s,mult), 0,wvf);
			kvf;
			wvf2
			*/

			var low = Instrument.SymbolBarData.Low[currentBar];
			var highest = HighestHigh(OHLCType.Close, LookBackPeriodStandardDeviationHigh);

			var wvf = ((highest - low) / highest * 100);

			highestHigh.Update(wvf, currentBar, barDateTime);
			var rangeHigh = highestHigh.CurrentValue * HighestPercentile;

			lowestLow.Update(wvf, currentBar, barDateTime);
			var rangeLow = lowestLow.CurrentValue * LowestPercentile;

			bollinger.Update(wvf, currentBar, barDateTime);

			var kvf = wvf >= rangeHigh || wvf >= bollinger.Bollingerup? wvf:0;
			var wvf2 = wvf >= rangeHigh || wvf >= bollinger.Bollingerup? 0:wvf;

			SetLine(0, currentBar, kvf);
			SetLine(1, currentBar, wvf2);

		}
	}
}

0 Yorum