コード例 #1
0
ファイル: SerAuxTrend.cs プロジェクト: ztahlis/b2xtranslator
        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);
        }
コード例 #2
0
ファイル: PriceTrendComparer.cs プロジェクト: mielk/waluty
 public void AssignProperties(DataItem item, double level, TrendlineType type, DataItem previousItem)
 {
     this.item = item;
     this.level = level;
     this.type = type;
     this.previousHit = previousItem;
 }
コード例 #3
0
ファイル: TrendHit.cs プロジェクト: mielk/waluty
 //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;
 }
コード例 #4
0
ファイル: SerAuxTrend.cs プロジェクト: ztahlis/b2xtranslator
        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);
        }
コード例 #5
0
ファイル: PriceTrendComparer.cs プロジェクト: mielk/waluty
        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;
        }
コード例 #6
0
ファイル: Price.cs プロジェクト: mielk/waluty
        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);
        }
コード例 #7
0
ファイル: Quotation.cs プロジェクト: mielk/waluty
 public double ProperValue(TrendlineType type)
 {
     if (type == TrendlineType.Resistance)
     {
         return High;
     }
     else
     {
         return Low;
     }
 }
コード例 #8
0
 public void Compare(DataItem item, double level, TrendlineType type, DataItem previousItem)
 {
 }
コード例 #9
0
ファイル: PriceTrendComparer.cs プロジェクト: mielk/waluty
 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
         };
     }
 }
コード例 #10
0
ファイル: DataItem.cs プロジェクト: mielk/waluty
 /* Covered with unit tests. */
 public double GetHighOrLowPrice(TrendlineType type)
 {
     return (type == TrendlineType.Support) ? Quotation.Low : Quotation.High;
 }
コード例 #11
0
ファイル: Trendline.cs プロジェクト: mielk/waluty
        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();
        }
コード例 #12
0
ファイル: TrendHit.cs プロジェクト: mielk/waluty
 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;
 }
コード例 #13
0
ファイル: DataItem.cs プロジェクト: mielk/waluty
        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;
        }
コード例 #14
0
ファイル: DataItem.cs プロジェクト: mielk/waluty
        public bool IsExtremum(TrendlineType type)
        {
            if (this.Price != null)
            {
                return this.Price.IsExtremum(type);
            }

            return false;
        }
コード例 #15
0
ファイル: DataItem.cs プロジェクト: mielk/waluty
 /* 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);
 }
コード例 #16
0
ファイル: Price.cs プロジェクト: mielk/waluty
 public bool IsExtremum(TrendlineType type)
 {
     return type == TrendlineType.Resistance ? IsPeak() : IsTrough();
 }
コード例 #17
0
ファイル: Price.cs プロジェクト: mielk/waluty
 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;
     }
 }
コード例 #18
0
ファイル: DataItem.cs プロジェクト: mielk/waluty
 /* 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);
 }