Ejemplo n.º 1
0
        public static decimal GetNearestLevel(decimal midPrice, MarketLevels mktLevels)
        {
            decimal referenceLevel = 0m;
            var     diff           = decimal.MaxValue;

            if (Math.Abs(midPrice - mktLevels.R3) < diff)
            {
                diff           = Math.Abs(midPrice - mktLevels.R3);
                referenceLevel = mktLevels.R3;
            }
            if (Math.Abs(midPrice - mktLevels.R2) < diff)
            {
                diff           = Math.Abs(midPrice - mktLevels.R2);
                referenceLevel = mktLevels.R2;
            }
            if (Math.Abs(midPrice - mktLevels.R1) < diff)
            {
                diff           = Math.Abs(midPrice - mktLevels.R1);
                referenceLevel = mktLevels.R1;
            }
            if (Math.Abs(midPrice - mktLevels.Pivot) < diff)
            {
                diff           = Math.Abs(midPrice - mktLevels.Pivot);
                referenceLevel = mktLevels.Pivot;
            }
            if (Math.Abs(midPrice - mktLevels.S1) < diff)
            {
                diff           = Math.Abs(midPrice - mktLevels.S1);
                referenceLevel = mktLevels.S1;
            }
            if (Math.Abs(midPrice - mktLevels.S2) < diff)
            {
                diff           = Math.Abs(midPrice - mktLevels.S2);
                referenceLevel = mktLevels.S2;
            }
            if (Math.Abs(midPrice - mktLevels.S3) < diff)
            {
                diff           = Math.Abs(midPrice - mktLevels.S3);
                referenceLevel = mktLevels.S3;
            }
            return(referenceLevel);
        }
Ejemplo n.º 2
0
 public MarketLevels(MarketLevels cpy)
     : this(cpy.AssetId, cpy.Low, cpy.High, cpy.CloseBid,
                                         cpy.CloseOffer)
 {
 }
Ejemplo n.º 3
0
 public MarketLevels(MarketLevels cpy) : this(cpy.AssetId, cpy.Low, cpy.High, cpy.CloseBid,
                                              cpy.CloseOffer)
 {
 }
Ejemplo n.º 4
0
 public static decimal GetNearestLevel(decimal midPrice, MarketLevels mktLevels)
 {
     decimal referenceLevel = 0m;
     var diff = decimal.MaxValue;
     if (Math.Abs(midPrice - mktLevels.R3) < diff)
     {
         diff = Math.Abs(midPrice - mktLevels.R3);
         referenceLevel = mktLevels.R3;
     }
     if (Math.Abs(midPrice - mktLevels.R2) < diff)
     {
         diff = Math.Abs(midPrice - mktLevels.R2);
         referenceLevel = mktLevels.R2;
     }
     if (Math.Abs(midPrice - mktLevels.R1) < diff)
     {
         diff = Math.Abs(midPrice - mktLevels.R1);
         referenceLevel = mktLevels.R1;
     }
     if (Math.Abs(midPrice - mktLevels.Pivot) < diff)
     {
         diff = Math.Abs(midPrice - mktLevels.Pivot);
         referenceLevel = mktLevels.Pivot;
     }
     if (Math.Abs(midPrice - mktLevels.S1) < diff)
     {
         diff = Math.Abs(midPrice - mktLevels.S1);
         referenceLevel = mktLevels.S1;
     }
     if (Math.Abs(midPrice - mktLevels.S2) < diff)
     {
         diff = Math.Abs(midPrice - mktLevels.S2);
         referenceLevel = mktLevels.S2;
     }
     if (Math.Abs(midPrice - mktLevels.S3) < diff)
     {
         diff = Math.Abs(midPrice - mktLevels.S3);
         referenceLevel = mktLevels.S3;
     }
     return referenceLevel;
 }