public static Trendline FromDto(TrendlineDto dto) { var trendline = new Trendline { Id = dto.TrendlineId, AssetId = dto.AssetId, TimeframeId = dto.TimeframeId, Slope = dto.Angle, ShowOnChart = dto.ShowOnChart, Value = dto.Value, BaseExtremumGroupId = dto.BaseExtremumGroupId, BaseDateIndex = dto.BaseDateIndex, BaseLevel = dto.BaseLevel, CounterExtremumGroupId = dto.CounterExtremumGroupId, CounterDateIndex = dto.CounterDateIndex, CounterLevel = dto.CounterLevel, StartIndex = dto.StartDateIndex, EndIndex = dto.EndDateIndex, IsOpenFromLeft = dto.IsOpenFromLeft, IsOpenFromRight = dto.IsOpenFromRight, TrendRanges = new List <TrendRange>() }; return(trendline); }
//public TrendHit() //{ // Guid = System.Guid.NewGuid(); //} //public TrendHit(Trendline trendline) : this() //{ // this.Trendline = trendline; //} public TrendHit(Trendline trendline, DataItem item, double crossPoint, TrendlineType type) { Guid = System.Guid.NewGuid(); this.Trendline = trendline; this.Item = item; this.CrossLevel = crossPoint; this.Type = type; }
public void Analyze(Trendline trendline, DataItem[] items, DataItem startItem) { var _startItem = (startItem == null ? trendline.InitialPoint.dataItem : startItem); var _startIndex = _startItem.Index; var currentHit = trendline.LastHit(); var currentBounce = trendline.LastBounce(); for (var i = _startIndex; i < items.Length; i++) { DataItem item = items[i]; TrendlineType type = trendline.CurrentType; bool isExtremum = item.Price.IsExtremum(type); double level = trendline.GetLevel(i); ////Get points for this dataItem. //var points = item.Price.calculateTrendlineQuotationPoints(trendline); if (isExtremum && trendline.IsMinimumForHit(item) && (currentHit == null || i - currentHit.Item.Index > 1)) { //Hit. trendline.setNewHit(item, level, type); currentHit = trendline.currentHit; currentBounce = trendline.currentBounce; } else { bool isBreakClose = ((item.Quotation.Close - trendline.GetLevel(i)) * trendline.CurrentType.GetFactor() > 0); double ptBreakExtremum = calculatePointForBreakExtremum(trendline, item); if (isBreakClose) { trendline.setNewBreak(item); } currentBounce.AddExtremumBreak(ptBreakExtremum); currentBounce.AddQuotation(trendline, item); } } }
private TrendBreak getTrendBreakIfExists(Trendline trendline, DataItem item) { return null; }
private double calculatePointForBreakExtremum(Trendline trendline, DataItem item) { return 0; }
public double calculateTrendlineQuotationPoints(Trendline trendline) { return 0; }
public TrendBounce(Trendline trendline, TrendHit startHit) { this.Trendline = trendline; this.StartHit = startHit; this.breaks = new List<TrendBreak>(); }
public TrendBounce(Trendline trendline) { this.Trendline = trendline; this.breaks = new List<TrendBreak>(); }
private double calculatePointForQuotation(Trendline trendline, DataItem item) { return 0; }
public void AddQuotation(Trendline trendline, DataItem item) { this.length++; this.pointsForQuotations += calculatePointForQuotation(trendline, item); }
private void addOptimalTrendline(Trendline trendline) { this.optimalTrendlines.Add(trendline.HitsHashCode, trendline); }
public List<Trendline> GetTrendlineVariantsForExtremaPair(ExtremumGroup extremum, ExtremumGroup subextremum, DataItem[] items) { List<Trendline> trendlines = new List<Trendline>(); /* * Jeżeli ekstrema przekazane do tej funkcji są odwrotne (czyli jedno jest wierzchołkiem, a drugie dołkiem), * żeby mogły być procesowane pomiędzy nimi musi być co najmniej jedno inne ekstremum. */ if (extremum.isOpposite(subextremum)) { var midextremum = extremaGroups.Where(e => e.master.Price != null && e.master.Date > extremum.master.Date && e.master.Date < subextremum.master.Date && e.type.IsPeak() == extremum.type.IsPeak()).ToArray(); if (midextremum.Length == 0) { return trendlines; } } double extremumLower = extremum.getLower(); double extremumHigher = extremum.getHigher(); double extremumStep = extremum.getStep(); double subextremumLower = subextremum.getLower(); double subextremumHigher = subextremum.getHigher(); double subextremumStep = subextremum.getStep(); for (var a = extremumLower; a <= extremumHigher + (extremumStep / 2); a += extremumStep) { for (var b = subextremumLower; b <= subextremumHigher + (subextremumStep / 2); b += subextremumStep) { var trendline = new Trendline(this.AssetTimeframe, new ValuePoint(extremum.getStartItem(), a), new ValuePoint(subextremum.getEndItem(), b)); trendlines.Add(trendline); } } return trendlines; }
public TrendHit(Trendline trendline, DataItem item, double crossPoint, TrendlineType type, TrendHit prevHit, TrendBounce prevBounce) : this(trendline, item, crossPoint, type) { this.PreviousHit = prevHit; this.BounceFromPreviousHit = prevBounce; }