Support Board
Date/Time: Sat, 08 Feb 2025 00:18:23 +0000
Convert Ninja Custom UniRenko bar type to Sierra Charts
View Count: 1619
[2020-06-19 02:53:22] |
User701453 - Posts: 176 |
Anyone have the skill to assist with converting this ninja bar type to sierra?? using NinjaTrader.Cbi;
using NinjaTrader.Gui.Chart; using NinjaTrader.Gui.Design; using System; using System.ComponentModel; namespace NinjaTrader.Data { [NinjaTrader.Gui.Design.DisplayName("GT Uni Renko")] public class GTUniRenko : BarsType { private int barDirection; private double barMax; private double barMin; private double barOpen; private double fakeOpen; private bool maxExceeded; private bool minExceeded; private double offset; private double openOffset; private static bool registered = BarsType.Register(new GTUniRenko()); private double reversalOffset; private double tickSize; private int tmpCount; private double trendOffset; public GTUniRenko() : base(PeriodType.Custom5) //---------------------------------------------^^^^^^^ to customize... { this.tickSize = 0.01; } public override void Add(Bars bars, double open, double high, double low, double close, DateTime time, long volume, bool isRealtime) { this.offset = (bars.Period.Value + bars.Period.BasePeriodValue) * bars.Instrument.MasterInstrument.TickSize; if ((bars.Count < this.tmpCount) && (bars.Count > 0)) { this.barMax = bars.GetClose(bars.Count - 1) + this.offset; this.barMin = bars.GetClose(bars.Count - 1) - this.offset; } if ((bars.Count != 0) && !bars.IsNewSession(time, isRealtime)) { Bar bar2 = (Bar) bars.Get(bars.Count - 1); if ((this.barMax == 0.0) || (this.barMin == 0.0)) { this.trendOffset = bars.Period.Value * bars.Instrument.MasterInstrument.TickSize; this.reversalOffset = bars.Period.Value2 * bars.Instrument.MasterInstrument.TickSize; this.openOffset = Math.Ceiling((double) (bars.Period.BasePeriodValue * 1.0)) * bars.Instrument.MasterInstrument.TickSize; if (bars.Count == 1) { this.barMax = bar2.Open + this.trendOffset; this.barMin = bar2.Open - this.trendOffset; } else if (bars.GetClose(bars.Count - 2) > bars.GetOpen(bars.Count - 2)) { this.barMax = bars.GetClose(bars.Count - 2) + this.trendOffset; this.barMin = bars.GetClose(bars.Count - 2) - (this.trendOffset * 2.0); } else { this.barMax = bars.GetClose(bars.Count - 2) + (this.trendOffset * 2.0); this.barMin = bars.GetClose(bars.Count - 2) - this.trendOffset; } } this.maxExceeded = bars.Instrument.MasterInstrument.Compare(close, this.barMax) > 0; this.minExceeded = bars.Instrument.MasterInstrument.Compare(close, this.barMin) < 0; if (!this.maxExceeded && !this.minExceeded) { base.UpdateBar(bars, bar2.Open, (close > bar2.High) ? close : bar2.High, (close < bar2.Low) ? close : bar2.Low, close, time, volume, isRealtime); } else { double num2 = this.maxExceeded ? Math.Min(close, this.barMax) : (this.minExceeded ? Math.Max(close, this.barMin) : close); this.barDirection = this.maxExceeded ? 1 : (this.minExceeded ? -1 : 0); this.fakeOpen = num2 - (this.openOffset * this.barDirection); base.UpdateBar(bars, bar2.Open, this.maxExceeded ? num2 : bar2.High, this.minExceeded ? num2 : bar2.Low, num2, time, volume, isRealtime); this.barOpen = close; this.barMax = num2 + ((this.barDirection > 0) ? this.trendOffset : this.reversalOffset); this.barMin = num2 - ((this.barDirection > 0) ? this.reversalOffset : this.trendOffset); base.AddBar(bars, this.fakeOpen, this.maxExceeded ? num2 : this.fakeOpen, this.minExceeded ? num2 : this.fakeOpen, num2, time, volume, isRealtime); } } else { this.tickSize = bars.Instrument.MasterInstrument.TickSize; if (bars.Period.Value >= 1000000) { string str = bars.Period.Value.ToString("000000000"); int result = 0; int.TryParse(str.Substring(0, 3), out result); bars.Period.Value = result; result = 0; int.TryParse(str.Substring(3, 3), out result); bars.Period.Value2 = result; result = 0; int.TryParse(str.Substring(6, 3), out result); bars.Period.BasePeriodValue = result; } if (bars.Count != 0) { Bar bar = (Bar) bars.Get(bars.Count - 1); bars.RemoveLastBar(); base.AddBar(bars, bar.Close, bar.High, bar.Low, bar.Close, bar.Time, bar.Volume, isRealtime); } this.trendOffset = bars.Period.Value * bars.Instrument.MasterInstrument.TickSize; this.reversalOffset = bars.Period.Value2 * bars.Instrument.MasterInstrument.TickSize; this.openOffset = Math.Ceiling((double) (bars.Period.BasePeriodValue * 1.0)) * bars.Instrument.MasterInstrument.TickSize; this.barOpen = close; this.barMax = this.barOpen + (this.trendOffset * this.barDirection); this.barMin = this.barOpen - (this.trendOffset * this.barDirection); base.AddBar(bars, this.barOpen, this.barOpen, this.barOpen, this.barOpen, time, volume, isRealtime); } bars.LastPrice = close; this.tmpCount = bars.Count; } public override void ApplyDefaults(BarsData barsData) { barsData.Period.Value = 2; barsData.Period.Value2 = 4; barsData.Period.BasePeriodValue = 2; barsData.DaysBack = 2; } public override string ChartDataBoxDate(DateTime time) { return time.ToString(NinjaTrader.Cbi.Globals.CurrentCulture.DateTimeFormat.ShortDatePattern); } public override string ChartLabel(ChartControl chartControl, DateTime time) { return time.ToString(chartControl.LabelFormatTick, NinjaTrader.Cbi.Globals.CurrentCulture); } public override object Clone() { return new GTUniRenko(); } public override int GetInitialLookBackDays(Period period, int barsBack) { return 15; } public override double GetPercentComplete(Bars bars, DateTime now) { return 0.0; } public override PropertyDescriptorCollection GetProperties(PropertyDescriptor propertyDescriptor, Period period, Attribute[] attributes) { PropertyDescriptorCollection properties = base.GetProperties(propertyDescriptor, period, attributes); properties.Remove(properties.Find("BasePeriodType", true)); properties.Remove(properties.Find("PointAndFigurePriceType", true)); properties.Remove(properties.Find("ReversalType", true)); NinjaTrader.Gui.Design.DisplayNameAttribute.SetDisplayName(properties, "Value2", "\r\rTick \r\rReversal"); NinjaTrader.Gui.Design.DisplayNameAttribute.SetDisplayName(properties, "Value", "\r\rTick \r\r\rTrend"); NinjaTrader.Gui.Design.DisplayNameAttribute.SetDisplayName(properties, "BasePeriodValue", "\r\rTick \rOpen Offset"); return properties; } public override string ToString(Period period) { return string.Concat(new object[] { period.Value, " GTUniRenko", period.Value, "R", period.Value2 }); } public override PeriodType BuiltFrom { get { return PeriodType.Tick; } } public override int DefaultValue { get { return 4; } } public override string DisplayName { get { return "GTUniRenko"; } } public override bool IsIntraday { get { return true; } } } } |
[2020-06-19 18:35:20] |
|
The relevant documentation for this is here: ACSIL Interface - Custom Chart Bars Also it really is next to impossible to make any sense of that code and adapt it to Sierra Chart. That would be a monumental waste of time and effort. It is even beyond our abilities to do that. Sierra Chart already has Renko bars: Renko Bar Charts Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing Date Time Of Last Edit: 2020-06-19 18:36:31
|
To post a message in this thread, you need to log in with your Sierra Chart account: