public SerAuxTrend(IStreamReader reader, GraphRecordNumber id, ushort length) : base(reader, id, length) { // assert that the correct record type is instantiated Debug.Assert(this.Id == ID); // initialize class members from stream this.regt = (TrendlineType)reader.ReadByte(); this.ordUser = reader.ReadByte(); //read the nullable double value (ChartNumNillable) var b = reader.ReadBytes(4); if (b[2] == 0xFF && b[3] == 0xFF) { this.numIntercept = null; } else { this.numIntercept = System.BitConverter.ToDouble(b, 0); } this.fEquation = Utils.ByteToBool(reader.ReadByte()); this.fRSquared = Utils.ByteToBool(reader.ReadByte()); this.numForecast = reader.ReadDouble(); this.numBackcast = reader.ReadDouble(); // assert that the correct number of bytes has been read from the stream Debug.Assert(this.Offset + this.Length == this.Reader.BaseStream.Position); }
public void AssignProperties(DataItem item, double level, TrendlineType type, DataItem previousItem) { this.item = item; this.level = level; this.type = type; this.previousHit = previousItem; }
//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 SerAuxTrend(IStreamReader reader, RecordType id, ushort length) : base(reader, id, length) { // assert that the correct record type is instantiated Debug.Assert(this.Id == ID); // initialize class members from stream this.regt = (TrendlineType)reader.ReadByte(); this.ordUser = reader.ReadByte(); //read the nullable double value (ChartNumNillable) this.numIntercept = new ChartNumNillable(reader).value; this.fEquation = Utils.ByteToBool(reader.ReadByte()); this.fRSquared = Utils.ByteToBool(reader.ReadByte()); this.numForecast = reader.ReadDouble(); this.numBackcast = reader.ReadDouble(); // assert that the correct number of bytes has been read from the stream Debug.Assert(this.Offset + this.Length == this.Reader.BaseStream.Position); }
public void Compare(DataItem item, double level, TrendlineType type, DataItem previousItem) { /* Zresetuj obiekt przed rozpoczęciem nowych obliczeń. */ Reset(); AssignProperties(item, level, type, previousItem); this.priceOverBreak = CalculatePriceOverBreak(); /* Oblicz różnicę w dystansie. Jeżeli świeca leży daleko od linii trendu * jej punktacja wynosi 0 i funkcja od razu kończy działanie, żeby nie * marnować zasobów. * Świece leżące po złej stronie linii trendu otrzymują ocenę ujemną. * Świece leżące blisko linii trendu otrzymują ocenę dodatnią. */ var priceScore = EvaluateScore(); /* Najpierw sprawdza czy notowanie jest przełamaniem linii trendu * (czyli cena zamknięcia powyżej linii oporu lub poniżej linii wsparcia). * Jeżeli tak, obliczenia nie są kontynuowane.*/ AnalyzeBreak(item, level, type); if (IsBreak()) return; }
public double ExtremumEvaluation(TrendlineType type) { var value = 0d; if (type == TrendlineType.Support) { value = Math.Max(TroughByClose, TroughByLow); } else if (type == TrendlineType.Resistance) { value = Math.Max(PeakByClose, PeakByHigh); } return Math.Max(value, PriceGap); }
public double ProperValue(TrendlineType type) { if (type == TrendlineType.Resistance) { return High; } else { return Low; } }
public void Compare(DataItem item, double level, TrendlineType type, DataItem previousItem) { }
private void AnalyzeBreak(DataItem item, double level, TrendlineType type) { /* Sprawdź czy cena zamknięcia leży poniżej linii wsparcia lub powyżej linii oporu. */ if (type == TrendlineType.Resistance && item.Quotation.Close > level || type == TrendlineType.Support && item.Quotation.Close < level) { this.trendBreak = new TrendBreak { Item = item, TrendLevel = level }; } }
/* Covered with unit tests. */ public double GetHighOrLowPrice(TrendlineType type) { return (type == TrendlineType.Support) ? Quotation.Low : Quotation.High; }
public void setNewHit(DataItem item, double level, TrendlineType type) { TrendHit hit = new TrendHit(this, item, level, type, currentHit, currentBounce); TrendBounce bounce = new TrendBounce(this, hit); hit.BounceToNextHit = bounce; //Close current hit and bounce. if (currentHit != null) { currentHit.NextHit = hit; this.Hits.Add(currentHit); } if (currentBounce != null) { currentBounce.EndHit = hit; this.Bounces.Add(currentBounce); } currentHit = hit; currentBounce = bounce; //Calculate points. //hit.Calculate(); //bounce.Calculate(); }
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; }
public bool IsTrendlineBroken(double level, TrendlineType type) { if (type == TrendlineType.Resistance) { return Quotation.Close > level; } else if (type == TrendlineType.Support) { return Quotation.Close < level; } return false; }
public bool IsExtremum(TrendlineType type) { if (this.Price != null) { return this.Price.IsExtremum(type); } return false; }
/* Covered with unit tests. */ public double GetOpenOrClosePrice(TrendlineType type) { return (type == TrendlineType.Support) ? Math.Min(Quotation.Open, Quotation.Close) : Math.Max(Quotation.Open, Quotation.Close); }
public bool IsExtremum(TrendlineType type) { return type == TrendlineType.Resistance ? IsPeak() : IsTrough(); }
public bool IsMatch(TrendlineType type) { if (type == TrendlineType.Resistance) { return (PeakByClose > 0 || PeakByHigh > 0); } else if (type == TrendlineType.Support) { return (TroughByClose > 0 || TroughByLow > 0); } else { return true; } }
/* Covered with unit tests. */ public double GetClosestDistance(TrendlineType type, double level) { double closeDistance = Math.Abs(GetOpenOrClosePrice(type) - level); double exDistance = Math.Abs(GetHighOrLowPrice(type) - level); return Math.Min(closeDistance, exDistance); }