コード例 #1
0
ファイル: ADX.cs プロジェクト: ForTrade/CSharp
 public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
 {
     if (index >= 2 * length)
     {
         double num = 0.0;
         double result;
         if (style == IndicatorStyle.QuantStudio)
         {
             for (int i = index; i > index - length; i--)
             {
                 num += DX.Value(input, i, length, IndicatorStyle.QuantStudio);
             }
             result = num / (double)length;
         }
         else
         {
             for (int j = 2 * length; j > length; j--)
             {
                 num += DX.Value(input, j, length, style);
             }
             num /= (double)length;
             for (int k = 2 * length + 1; k <= index; k++)
             {
                 num = (num * (double)(length - 1) + DX.Value(input, k, length, style)) / (double)length;
             }
             result = num;
         }
         return(result);
     }
     return(double.NaN);
 }
コード例 #2
0
 public RSI(ISeries input, int length, BarData barData = BarData.Close, IndicatorStyle style = IndicatorStyle.QuantStudio):base(input)
 {
     this.length = length;
     this.barData = barData;
     this.style = style;
     Init();
 }
コード例 #3
0
 //TODO: rewrite
 public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
 {
     if (index >= 2 * length)
     {
         double num = 0.0;
         double result;
         if (style == IndicatorStyle.QuantStudio)
         {
             for (int i = index; i > index - length; i--)
             {
                 num += DX.Value(input, i, length, IndicatorStyle.QuantStudio);
             }
             result = num / (double)length;
         }
         else
         {
             for (int j = 2 * length; j > length; j--)
             {
                 num += DX.Value(input, j, length, style);
             }
             num /= (double)length;
             for (int k = 2 * length + 1; k <= index; k++)
             {
                 num = (num * (double)(length - 1) + DX.Value(input, k, length, style)) / (double)length;
             }
             result = num;
         }
         return result;
     }
     return double.NaN;
 }
コード例 #4
0
ファイル: ATR.cs プロジェクト: vcoda/fastquant.dll
 public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
 {
     if (index >= length)
     {
         double sum = 0;
         double result;
         if (style == IndicatorStyle.QuantStudio)
         {
             for (var i = index; i > index - length; i--)
             {
                 sum += TR.Value(input, i);
             }
             result = sum / length;
         }
         else
         {
             for (int j = length; j > 0; j--)
             {
                 sum += TR.Value(input, j) / length;
             }
             sum /= length;
             for (var k = length + 1; k <= index; k++)
             {
                 sum = (sum * (length - 1) + TR.Value(input, k)) / length;
             }
             result = sum;
         }
         return(result);
     }
     return(double.NaN);
 }
コード例 #5
0
ファイル: RSI.cs プロジェクト: ForTrade/CSharp
 public RSI(ISeries input, int length, BarData barData = BarData.Close, IndicatorStyle style = IndicatorStyle.QuantStudio) : base(input)
 {
     this.length  = length;
     this.barData = barData;
     this.style   = style;
     this.Init();
 }
コード例 #6
0
    private void DisplayStyle(IndicatorStyle style)
    {
        Color  styleColor = GetColorFrom(style);
        string styleText  = GetTextFrom(style);

        border.GetComponent <Image>().color = styleColor;
        label.GetComponent <Image>().color  = styleColor;
        labelText.text = styleText;
    }
コード例 #7
0
    private Color GetColorFrom(IndicatorStyle style)
    {
        Color color;
        IndicatorStyleAttribute attribute = (IndicatorStyleAttribute)style.GetAttr();

        ColorUtility.TryParseHtmlString(attribute.ColorCode, out color);

        return(color);
    }
コード例 #8
0
ファイル: ADXR.cs プロジェクト: ForTrade/CSharp
 public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
 {
     if (index >= 3 * length - 1)
     {
         double num  = ADX.Value(input, index, length, style);
         double num2 = ADX.Value(input, index - length + 1, length, style);
         return((num + num2) / 2.0);
     }
     return(double.NaN);
 }
コード例 #9
0
ファイル: ADXR.cs プロジェクト: ForTrade/CSharp
		public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
		{
			if (index >= 3 * length - 1)
			{
				double num = ADX.Value(input, index, length, style);
				double num2 = ADX.Value(input, index - length + 1, length, style);
				return (num + num2) / 2.0;
			}
			return double.NaN;
		}
コード例 #10
0
ファイル: DX.cs プロジェクト: vcoda/fastquant.dll
 public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
 {
     if (index >= length)
     {
         var p = PDI.Value(input, index, length, style);
         var n = MDI.Value(input, index, length, style);
         return(p + n != 0.0 ? 100.0 * Math.Abs(p - n) / (p + n) : 0);
     }
     return(double.NaN);
 }
コード例 #11
0
        //public static void AddHighlights(ScintillaControl sci, int posText, string textToHigh, System.Drawing.Color color)
        //{
        //        //Int32 start = sci.MBSafePosition(posText);
        //        Int32 start = posText;
        //        Int32 end = start + sci.MBSafeTextLength(textToHigh);
        //        Int32 position = start;
        //        Int32 mask = 1 << sci.StyleBits;
        //        sci.SetIndicStyle(0, (Int32)IndicatorStyle.Plain);
        //        sci.SetIndicFore(0, DataConverter.ColorToInt32(color));
        //        sci.StartStyling(position, mask);
        //        sci.SetStyling(end - start, mask);
        //}
        public static void AddHighlights(ScintillaControl sci, Int32 posText, Int32 length, System.Drawing.Color color, IndicatorStyle indicator)
        {
            if (length == 0) return;

            Int32 mask = 1 << sci.StyleBits;

            sci.SetIndicStyle(0, (Int32)indicator);
            sci.SetIndicFore(0, DataConverter.ColorToInt32(color));

            sci.StartStyling(posText, mask);
            sci.SetStyling(length, mask);
        }
コード例 #12
0
        public TitlePageIndicator(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
        {
            //Load defaults from resources
            var   res = Resources;
            int   defaultFooterColor                     = res.GetColor(Resource.Color.default_title_indicator_footer_color);
            float defaultFooterLineHeight                = res.GetDimension(Resource.Dimension.default_title_indicator_footer_line_height);
            int   defaultFooterIndicatorStyle            = res.GetInteger(Resource.Integer.default_title_indicator_footer_indicator_style);
            float defaultFooterIndicatorHeight           = res.GetDimension(Resource.Dimension.default_title_indicator_footer_indicator_height);
            float defaultFooterIndicatorUnderlinePadding = res.GetDimension(Resource.Dimension.default_title_indicator_footer_indicator_underline_padding);
            float defaultFooterPadding                   = res.GetDimension(Resource.Dimension.default_title_indicator_footer_padding);
            int   defaultSelectedColor                   = res.GetColor(Resource.Color.default_title_indicator_selected_color);
            bool  defaultSelectedBold                    = res.GetBoolean(Resource.Boolean.default_title_indicator_selected_bold);
            int   defaultTextColor    = res.GetColor(Resource.Color.default_title_indicator_text_color);
            float defaultTextSize     = res.GetDimension(Resource.Dimension.default_title_indicator_text_size);
            float defaultTitlePadding = res.GetDimension(Resource.Dimension.default_title_indicator_title_padding);
            float defaultClipPadding  = res.GetDimension(Resource.Dimension.default_title_indicator_clip_padding);
            float defaultTopPadding   = res.GetDimension(Resource.Dimension.default_title_indicator_top_padding);

            //Retrieve styles attributes
            var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.TitlePageIndicator, defStyle, Resource.Style.Widget_TitlePageIndicator);

            //Retrieve the colors to be used for this view and apply them.
            mFooterLineHeight                = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight);
            mFooterIndicatorStyle            = (IndicatorStyle)a.GetInteger(Resource.Styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle);
            mFooterIndicatorHeight           = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight);
            mFooterIndicatorUnderlinePadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding);
            mFooterPadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
            mTopPadding    = a.GetDimension(Resource.Styleable.TitlePageIndicator_topPadding, defaultTopPadding);
            mTitlePadding  = a.GetDimension(Resource.Styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
            mClipPadding   = a.GetDimension(Resource.Styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
            mColorSelected = a.GetColor(Resource.Styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
            mColorText     = a.GetColor(Resource.Styleable.TitlePageIndicator_textColor, defaultTextColor);
            mBoldText      = a.GetBoolean(Resource.Styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);

            float textSize    = a.GetDimension(Resource.Styleable.TitlePageIndicator_textSize, defaultTextSize);
            Color footerColor = a.GetColor(Resource.Styleable.TitlePageIndicator_footerColor, defaultFooterColor);

            mPaintText.TextSize  = textSize;
            mPaintText.AntiAlias = true;
            mPaintFooterLine.SetStyle(Android.Graphics.Paint.Style.FillAndStroke);
            mPaintFooterLine.StrokeWidth = mFooterLineHeight;
            mPaintFooterLine.Color       = footerColor;
            mPaintFooterIndicator.SetStyle(Android.Graphics.Paint.Style.FillAndStroke);
            mPaintFooterIndicator.Color = footerColor;

            a.Recycle();

            var configuration = ViewConfiguration.Get(context);

            mTouchSlop = ViewConfigurationCompat.GetScaledPagingTouchSlop(configuration);
        }
コード例 #13
0
        /// <summary>
        /// Finds the color of the highest priority style and returns it.
        /// </summary>
        /// <param name="displayContext">The display context.</param>
        private void SetHighestColor(IDisplayContext displayContext)
        {
            // Go through all the indicators and look for a style.
            Theme          theme        = displayContext.Theme;
            IndicatorStyle highestStyle = null;

            for (int index = 0;
                 index < indicators.Count;
                 index++)
            {
                // Try to get a style for this indicator. If we don't have
                // one, then just skip it.
                ILineIndicator indicator = indicators[index];

                if (!theme.IndicatorStyles.ContainsKey(indicator.LineIndicatorStyle))
                {
                    // No style, nothing to render.
                    continue;
                }

                // Get the style for this indicator.
                IndicatorStyle style = theme.IndicatorStyles[indicator.LineIndicatorStyle];

                if (highestStyle == null ||
                    highestStyle.Priority < style.Priority)
                {
                    highestStyle = style;
                }
            }

            // If we don't have a style at the bottom, we aren't visible.
            Visible = highestStyle != null;

            if (highestStyle != null)
            {
                colors = new[]
                {
                    highestStyle.Color
                };
                ratios = new[]
                {
                    1.0
                };
            }
            else
            {
                colors = null;
                ratios = null;
            }
        }
コード例 #14
0
        internal static EIndicatorStyle Convert(IndicatorStyle indicatorStyle)
        {
            switch (indicatorStyle)
            {
            case IndicatorStyle.SmartQuant:
                return(EIndicatorStyle.QuantStudio);

            case IndicatorStyle.MetaStock:
                return(EIndicatorStyle.MetaStock);

            default:
                throw new NotImplementedException("Indicator style is not supported : " + indicatorStyle);
            }
        }
コード例 #15
0
ファイル: DX.cs プロジェクト: ForTrade/CSharp
 public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
 {
     if (index >= length)
     {
         double num    = PDI.Value(input, index, length, style);
         double num2   = MDI.Value(input, index, length, style);
         double result = 0.0;
         if (num + num2 != 0.0)
         {
             result = 100.0 * Math.Abs(num - num2) / (num + num2);
         }
         return(result);
     }
     return(double.NaN);
 }
コード例 #16
0
ファイル: EnumConverter.cs プロジェクト: zhuzhenping/FreeOQ
        internal static FreeQuant.Indicators.EIndicatorStyle Convert(IndicatorStyle indicatorStyle)
        {
            switch (indicatorStyle)
            {
            case IndicatorStyle.SmartQuant:
                return(FreeQuant.Indicators.EIndicatorStyle.SmartQuant);

            case IndicatorStyle.MetaStock:
                return(FreeQuant.Indicators.EIndicatorStyle.MetaStock);

            case IndicatorStyle.QuantStudio:
                return(FreeQuant.Indicators.EIndicatorStyle.QuantStudio);

            case IndicatorStyle.FreeQuant:
                return(FreeQuant.Indicators.EIndicatorStyle.FreeQuant);

            default:
                throw new NotSupportedException(string.Format("IndicatorStyle is not supported - {0}", indicatorStyle));
            }
        }
コード例 #17
0
ファイル: MDI.cs プロジェクト: ssh352/omniquant-server
 public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
 {
     if (style == IndicatorStyle.QuantStudio)
     {
         var mdm = 0.0;
         var tr  = 0.0;
         if (index >= length)
         {
             for (var i = index; i > index - length; i--)
             {
                 tr  += TR.Value(input, i);
                 mdm += MDM.Value(input, i);
             }
             return(mdm / tr * 100);
         }
         return(double.NaN);
     }
     else
     {
         double mdm = 0.0;
         double tr  = 0.0;
         if (index >= length)
         {
             for (var j = length; j >= 1; j--)
             {
                 tr  += TR.Value(input, j);
                 mdm += MDM.Value(input, j);
             }
             for (var k = length + 1; k <= index; k++)
             {
                 mdm = mdm - mdm / length + MDM.Value(input, k);
                 tr  = tr - tr / length + TR.Value(input, k);
             }
             return(mdm / tr * 100);
         }
         return(double.NaN);
     }
 }
コード例 #18
0
 public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
 {
     if (style == IndicatorStyle.QuantStudio)
     {
         double num  = 0.0;
         double num2 = 0.0;
         if (index >= length)
         {
             for (int i = index; i > index - length; i--)
             {
                 num2 += TR.Value(input, i);
                 num  += PDM.Value(input, i);
             }
             return(num / num2 * 100.0);
         }
         return(double.NaN);
     }
     else
     {
         double num3 = 0.0;
         double num4 = 0.0;
         if (index >= length)
         {
             for (int j = length; j >= 1; j--)
             {
                 num4 += TR.Value(input, j);
                 num3 += PDM.Value(input, j);
             }
             for (int k = length + 1; k <= index; k++)
             {
                 num3 = num3 - num3 / (double)length + PDM.Value(input, k);
                 num4 = num4 - num4 / (double)length + TR.Value(input, k);
             }
             return(num3 / num4 * 100.0);
         }
         return(double.NaN);
     }
 }
コード例 #19
0
ファイル: Indicator.cs プロジェクト: dbbotkin/PrimeComm
		public void ResetStyle()
		{
			Style = getDefaultStyle();
		}
コード例 #20
0
 public PDI(ISeries input, int length, IndicatorStyle style = IndicatorStyle.QuantStudio) : base(input)
 {
     this.length = length;
     this.style  = style;
     this.Init();
 }
コード例 #21
0
ファイル: EnumConverter.cs プロジェクト: heber/FreeOQ
		internal static FreeQuant.Indicators.EIndicatorStyle Convert(IndicatorStyle indicatorStyle)
		{
			switch (indicatorStyle)
			{
				case IndicatorStyle.SmartQuant:
					return FreeQuant.Indicators.EIndicatorStyle.SmartQuant;
				case IndicatorStyle.MetaStock:
					return FreeQuant.Indicators.EIndicatorStyle.MetaStock;
				case IndicatorStyle.QuantStudio:
					return FreeQuant.Indicators.EIndicatorStyle.QuantStudio;
				case IndicatorStyle.FreeQuant:
					return FreeQuant.Indicators.EIndicatorStyle.FreeQuant;
				default:
					throw new NotSupportedException(string.Format("IndicatorStyle is not supported - {0}", indicatorStyle));
			}
		}
コード例 #22
0
 public void ResetStyle()
 {
     Style = getDefaultStyle();
 }
コード例 #23
0
ファイル: Indicator.cs プロジェクト: borisblizzard/arcreator
 public void ResetStyle()
 {
     this.Style = this.GetDefaultStyle();
 }
コード例 #24
0
 //TODO: rewrite it!
 public static double Value(ISeries input, int index, int length, BarData barData = BarData.Close, IndicatorStyle style = IndicatorStyle.QuantStudio)
 {
     double num = 0.0;
     double num2 = 0.0;
     if (index >= length)
     {
         if (style == IndicatorStyle.QuantStudio)
         {
             double num3 = input[index - length, barData];
             for (int i = index - length + 1; i <= index; i++)
             {
                 double num4 = input[i, barData];
                 if (num4 > num3)
                 {
                     num += num4 - num3;
                 }
                 else
                 {
                     num2 += num3 - num4;
                 }
                 num3 = num4;
             }
         }
         else
         {
             double num3 = input[0, barData];
             for (int j = 1; j <= length; j++)
             {
                 double num4 = input[j, barData];
                 if (num4 > num3)
                 {
                     num += num4 - num3;
                 }
                 else
                 {
                     num2 += num3 - num4;
                 }
                 num3 = num4;
             }
             num /= (double)length;
             num2 /= (double)length;
             num3 = input[length, barData];
             for (int k = length + 1; k <= index; k++)
             {
                 num *= (double)(length - 1);
                 num2 *= (double)(length - 1);
                 double num4 = input[k, barData];
                 if (num4 > num3)
                 {
                     num += num4 - num3;
                 }
                 else
                 {
                     num2 += num3 - num4;
                 }
                 num3 = num4;
                 num /= (double)length;
                 num2 /= (double)length;
             }
         }
         return 100.0 - 100.0 / (1.0 + num / num2);
     }
     return double.NaN;
 }
コード例 #25
0
 public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
 {
     if (index >= length)
     {
         var p = PDI.Value(input, index, length, style);
         var n = MDI.Value(input, index, length, style);
         return p + n != 0.0 ? 100.0*Math.Abs(p - n)/(p + n) : 0;
     }
     return double.NaN;
 }
コード例 #26
0
 public DX(ISeries input, int length, IndicatorStyle style = IndicatorStyle.QuantStudio) : base(input)
 {
     this.length = length;
     this.style = style;
     Init();
 }
コード例 #27
0
ファイル: DX.cs プロジェクト: ForTrade/CSharp
		public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
		{
			if (index >= length)
			{
				double num = PDI.Value(input, index, length, style);
				double num2 = MDI.Value(input, index, length, style);
				double result = 0.0;
				if (num + num2 != 0.0)
				{
					result = 100.0 * Math.Abs(num - num2) / (num + num2);
				}
				return result;
			}
			return double.NaN;
		}
コード例 #28
0
 public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
 {
     if (style == IndicatorStyle.QuantStudio)
     {
         var pdm = 0.0;
         var tr = 0.0;
         if (index >= length)
         {
             for (int i = index; i > index - length; i--)
             {
                 tr += TR.Value(input, i);
                 pdm += PDM.Value(input, i);
             }
             return pdm/tr*100.0;
         }
         return double.NaN;
     }
     else
     {
         var pdm = 0.0;
         var tr = 0.0;
         if (index >= length)
         {
             for (var j = length; j >= 1; j--)
             {
                 tr += TR.Value(input, j);
                 pdm += PDM.Value(input, j);
             }
             for (var k = length + 1; k <= index; k++)
             {
                 pdm = pdm - pdm / length + PDM.Value(input, k);
                 tr = tr - tr / length + TR.Value(input, k);
             }
             return pdm/tr*100.0;
         }
         return double.NaN;
     }
 }
コード例 #29
0
ファイル: SnippetManager.cs プロジェクト: dbbotkin/PrimeComm
 private void ResetActiveSnippetIndicatorStyle()
 {
     _activeSnippetIndicatorStyle = IndicatorStyle.RoundBox;
 }
コード例 #30
0
ファイル: MDI.cs プロジェクト: ForTrade/CSharp
		public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
		{
			if (style == IndicatorStyle.QuantStudio)
			{
				double num = 0.0;
				double num2 = 0.0;
				if (index >= length)
				{
					for (int i = index; i > index - length; i--)
					{
						num2 += TR.Value(input, i);
						num += MDM.Value(input, i);
					}
					return num / num2 * 100.0;
				}
				return double.NaN;
			}
			else
			{
				double num3 = 0.0;
				double num4 = 0.0;
				if (index >= length)
				{
					for (int j = length; j >= 1; j--)
					{
						num4 += TR.Value(input, j);
						num3 += MDM.Value(input, j);
					}
					for (int k = length + 1; k <= index; k++)
					{
						num3 = num3 - num3 / (double)length + MDM.Value(input, k);
						num4 = num4 - num4 / (double)length + TR.Value(input, k);
					}
					return num3 / num4 * 100.0;
				}
				return double.NaN;
			}
		}
コード例 #31
0
 public void SetFooterIndicatorStyle(IndicatorStyle indicatorStyle)
 {
     mFooterIndicatorStyle = indicatorStyle;
     Invalidate();
 }
コード例 #32
0
 private void ResetActiveSnippetIndicatorStyle()
 {
     _activeSnippetIndicatorStyle = IndicatorStyle.RoundBox;
 }
コード例 #33
0
 public void SetFooterIndicatorStyle(IndicatorStyle indicatorStyle)
 {
     mFooterIndicatorStyle = indicatorStyle;
     Invalidate();
 }
コード例 #34
0
 private void ResetInactiveSnippetIndicatorStyle()
 {
     _inactiveSnippetIndicatorStyle = IndicatorStyle.Box;
 }
コード例 #35
0
        /// <summary>
        /// Sets the color ratios based on the indicators.
        /// </summary>
        /// <param name="displayContext">The display context.</param>
        private void SetColorRatios(IDisplayContext displayContext)
        {
            // Create a dictionary of the individual styles and their counts.
            Theme  theme  = displayContext.Theme;
            var    styles = new Dictionary <string, IndicatorStyle>();
            var    counts = new Dictionary <string, int>();
            double total  = 0;

            foreach (ILineIndicator indicator in indicators)
            {
                // Make sure this indicator has a style.
                string styleName = indicator.LineIndicatorStyle;

                if (!theme.IndicatorStyles.ContainsKey(styleName))
                {
                    continue;
                }

                // Check to see if we already have the style.
                if (!styles.ContainsKey(styleName))
                {
                    IndicatorStyle style = theme.IndicatorStyles[styleName];
                    styles[styleName] = style;
                }

                // Increment the counter for this style.
                if (counts.ContainsKey(styleName))
                {
                    counts[styleName]++;
                }
                else
                {
                    counts[styleName] = 1;
                }

                total++;
            }

            // Get a list of sorted styles, ordered by priority.
            var sortedStyles = new List <IndicatorStyle>();

            sortedStyles.AddRange(styles.Values);
            sortedStyles.Sort();

            // Go through the styles and build up the ratios and colors.
            colors = new Color[sortedStyles.Count];
            ratios = new double[sortedStyles.Count];

            for (int index = 0;
                 index < sortedStyles.Count;
                 index++)
            {
                IndicatorStyle style = sortedStyles[index];

                colors[index] = style.Color;
                ratios[index] = counts[style.Name] / total;
            }

            // This line is visible.
            Visible = true;
        }
コード例 #36
0
        public TitlePageIndicator(Context context, IAttributeSet attrs, int defStyle)
            : base(context, attrs, defStyle)
        {
            if (IsInEditMode)
            {
                return;
            }

            var res = Resources;

            //Load defaults from resources
            var defaultFooterColor          = res.GetColor(Resource.Color.default_title_indicator_footer_color);
            var defaultFooterLineHeight     = res.GetDimension(Resource.Dimension.default_title_indicator_footer_line_height);
            var defaultFooterIndicatorStyle =
                res.GetInteger(Resource.Integer.default_title_indicator_footer_indicator_style);
            var defaultFooterIndicatorHeight =
                res.GetDimension(Resource.Dimension.default_title_indicator_footer_indicator_height);
            var defaultFooterIndicatorUnderlinePadding =
                res.GetDimension(Resource.Dimension.default_title_indicator_footer_indicator_underline_padding);
            var defaultFooterPadding = res.GetDimension(Resource.Dimension.default_title_indicator_footer_padding);
            var defaultLinePosition  = res.GetInteger(Resource.Integer.default_title_indicator_line_position);
            var defaultSelectedColor = res.GetColor(Resource.Color.default_title_indicator_selected_color);
            var defaultSelectedBold  = res.GetBoolean(Resource.Boolean.default_title_indicator_selected_bold);
            var defaultTextColor     = res.GetColor(Resource.Color.default_title_indicator_text_color);
            var defaultTextSize      = res.GetDimension(Resource.Dimension.default_title_indicator_text_size);
            var defaultTitlePadding  = res.GetDimension(Resource.Dimension.default_title_indicator_title_padding);
            var defaultClipPadding   = res.GetDimension(Resource.Dimension.default_title_indicator_clip_padding);
            var defaultTopPadding    = res.GetDimension(Resource.Dimension.default_title_indicator_top_padding);

            var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.TitlePageIndicator, defStyle, 0);

            _footerLineHeight = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerLineHeight,
                                               defaultFooterLineHeight);
            _footerIndicatorStyle =
                (IndicatorStyle)a.GetInteger(Resource.Styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle);
            _footerIndicatorHeight = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerIndicatorHeight,
                                                    defaultFooterIndicatorHeight);
            _footerIndicatorUnderlinePadding =
                a.GetDimension(Resource.Styleable.TitlePageIndicator_footerIndicatorUnderlinePadding,
                               defaultFooterIndicatorUnderlinePadding);
            _footerPadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
            _linePosition  =
                (LinePosition)a.GetInteger(Resource.Styleable.TitlePageIndicator_linePosition, defaultLinePosition);
            _topPadding    = a.GetDimension(Resource.Styleable.TitlePageIndicator_topPadding, defaultTopPadding);
            _titlePadding  = a.GetDimension(Resource.Styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
            _clipPadding   = a.GetDimension(Resource.Styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
            _colorSelected = a.GetColor(Resource.Styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
            _colorText     = a.GetColor(Resource.Styleable.TitlePageIndicator_android_textColor, defaultTextColor);
            _boldText      = a.GetBoolean(Resource.Styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);

            var textSize    = a.GetDimension(Resource.Styleable.TitlePageIndicator_android_textSize, defaultTextSize);
            var footerColor = a.GetColor(Resource.Styleable.TitlePageIndicator_footerColor, defaultFooterColor);

            _paintText.TextSize = textSize;
            _paintFooterLine.SetStyle(Paint.Style.FillAndStroke);
            _paintFooterLine.StrokeWidth = _footerLineHeight;
            _paintFooterLine.Color       = footerColor;
            _paintFooterIndicator.SetStyle(Paint.Style.FillAndStroke);
            _paintFooterIndicator.Color = footerColor;

            var background = a.GetDrawable(Resource.Styleable.TitlePageIndicator_android_background);

            if (null != background)
            {
                SetBackgroundDrawable(background);
            }

            a.Recycle();

            var configuration = ViewConfiguration.Get(context);

            _touchSlop = ViewConfigurationCompat.GetScaledPagingTouchSlop(configuration);
        }
コード例 #37
0
        public TitlePageIndicator(Context context, IAttributeSet attrs, int defStyle)
            : base(context, attrs, defStyle)
        {

            if (IsInEditMode) return;

            //Load defaults from resources
            Android.Content.Res.Resources res = this.Resources;
            Color defaultFooterColor = res.GetColor(R.Color.default_title_indicator_footer_color);
            float defaultFooterLineHeight = res.GetDimension(R.Dimension.default_title_indicator_footer_line_height);
            int defaultFooterIndicatorStyle = res.GetInteger(R.Integer.default_title_indicator_footer_indicator_style);
            float defaultFooterIndicatorHeight = res.GetDimension(R.Dimension.default_title_indicator_footer_indicator_height);
            float defaultFooterIndicatorUnderlinePadding = res.GetDimension(R.Dimension.default_title_indicator_footer_indicator_underline_padding);
            float defaultFooterPadding = res.GetDimension(R.Dimension.default_title_indicator_footer_padding);
            int defaultLinePosition = res.GetInteger(R.Integer.default_title_indicator_line_position);
            Color defaultSelectedColor = res.GetColor(R.Color.default_title_indicator_selected_color);
            bool defaultSelectedBold = res.GetBoolean(R.Boolean.default_title_indicator_selected_bold);
            Color defaultTextColor = res.GetColor(R.Color.default_title_indicator_text_color);
            float defaultTextSize = res.GetDimension(R.Dimension.default_title_indicator_text_size);
            float defaultTitlePadding = res.GetDimension(R.Dimension.default_title_indicator_title_padding);
            float defaultClipPadding = res.GetDimension(R.Dimension.default_title_indicator_clip_padding);
            float defaultTopPadding = res.GetDimension(R.Dimension.default_title_indicator_top_padding);

            //Retrieve styles attributes
            TypedArray a = context.ObtainStyledAttributes(attrs, R.Styleable.TitlePageIndicator, defStyle, 0);

            //Retrieve the colors to be used for this view and apply them.
            mFooterLineHeight = a.GetDimension(R.Styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight);
            mFooterIndicatorStyle = (IndicatorStyle)(a.GetInteger(R.Styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle));
            mFooterIndicatorHeight = a.GetDimension(R.Styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight);
            mFooterIndicatorUnderlinePadding = a.GetDimension(R.Styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding);
            mFooterPadding = a.GetDimension(R.Styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
            mLinePosition = (LinePosition)(a.GetInteger(R.Styleable.TitlePageIndicator_linePosition, defaultLinePosition));
            mTopPadding = a.GetDimension(R.Styleable.TitlePageIndicator_topPadding, defaultTopPadding);
            mTitlePadding = a.GetDimension(R.Styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
            mClipPadding = a.GetDimension(R.Styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
            mColorSelected = a.GetColor(R.Styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
            mColorText = a.GetColor(R.Styleable.TitlePageIndicator_android_textColor, defaultTextColor);
            mBoldText = a.GetBoolean(R.Styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);

            float textSize = a.GetDimension(R.Styleable.TitlePageIndicator_android_textSize, defaultTextSize);
            Color footerColor = a.GetColor(R.Styleable.TitlePageIndicator_footerColor, defaultFooterColor);
            mPaintText.TextSize = textSize;
            mPaintText.AntiAlias = true;
            mPaintFooterLine.SetStyle(Paint.Style.FillAndStroke);
            mPaintFooterLine.StrokeWidth = mFooterLineHeight;
            mPaintFooterLine.Color = footerColor;
            mPaintFooterIndicator.SetStyle(Paint.Style.FillAndStroke);
            mPaintFooterIndicator.Color = footerColor;

            Drawable background = a.GetDrawable(R.Styleable.TitlePageIndicator_android_background);
            if (background != null)
            {
                SetBackgroundDrawable(background);
            }

            a.Recycle();

            ViewConfiguration configuration = ViewConfiguration.Get(context);
            mTouchSlop = ViewConfigurationCompat.GetScaledPagingTouchSlop(configuration);
        }
コード例 #38
0
		internal static EIndicatorStyle Convert(IndicatorStyle indicatorStyle)
		{
			switch (indicatorStyle)
			{
			case IndicatorStyle.SmartQuant:
				return EIndicatorStyle.QuantStudio;
			case IndicatorStyle.MetaStock:
				return EIndicatorStyle.MetaStock;
			default:
				throw new NotImplementedException("Indicator style is not supported : " + indicatorStyle);
			}
		}
コード例 #39
0
        public TitlePageIndicator(Context context, IAttributeSet attrs, int defStyle)
            : base(context, attrs, defStyle)
        {
            //Load defaults from resources
            var res = Resources;
            int defaultFooterColor = res.GetColor(Resource.Color.default_title_indicator_footer_color);
            float defaultFooterLineHeight = res.GetDimension(Resource.Dimension.default_title_indicator_footer_line_height);
            int defaultFooterIndicatorStyle = res.GetInteger(Resource.Integer.default_title_indicator_footer_indicator_style);
            float defaultFooterIndicatorHeight = res.GetDimension(Resource.Dimension.default_title_indicator_footer_indicator_height);
            float defaultFooterIndicatorUnderlinePadding = res.GetDimension(Resource.Dimension.default_title_indicator_footer_indicator_underline_padding);
            float defaultFooterPadding = res.GetDimension(Resource.Dimension.default_title_indicator_footer_padding);
            int defaultSelectedColor = res.GetColor(Resource.Color.default_title_indicator_selected_color);
            bool defaultSelectedBold = res.GetBoolean(Resource.Boolean.default_title_indicator_selected_bold);
            int defaultTextColor = res.GetColor(Resource.Color.default_title_indicator_text_color);
            float defaultTextSize = res.GetDimension(Resource.Dimension.default_title_indicator_text_size);
            float defaultTitlePadding = res.GetDimension(Resource.Dimension.default_title_indicator_title_padding);
            float defaultClipPadding = res.GetDimension(Resource.Dimension.default_title_indicator_clip_padding);
            float defaultTopPadding = res.GetDimension(Resource.Dimension.default_title_indicator_top_padding);

            //Retrieve styles attributes
            var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.TitlePageIndicator, defStyle, Resource.Style.Widget_TitlePageIndicator);

            //Retrieve the colors to be used for this view and apply them.
            mFooterLineHeight = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight);
            mFooterIndicatorStyle = (IndicatorStyle) a.GetInteger(Resource.Styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle);
            mFooterIndicatorHeight = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight);
            mFooterIndicatorUnderlinePadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding);
            mFooterPadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
            mTopPadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_topPadding, defaultTopPadding);
            mTitlePadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
            mClipPadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
            mColorSelected = a.GetColor(Resource.Styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
            mColorText = a.GetColor(Resource.Styleable.TitlePageIndicator_textColor, defaultTextColor);
            mBoldText = a.GetBoolean(Resource.Styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);

            float textSize = a.GetDimension(Resource.Styleable.TitlePageIndicator_textSize, defaultTextSize);
            int footerColor = a.GetColor(Resource.Styleable.TitlePageIndicator_footerColor, defaultFooterColor);
            mPaintText.TextSize = textSize;
            mPaintText.AntiAlias = true;
            mPaintFooterLine.SetStyle(Android.Graphics.Paint.Style.FillAndStroke);
            mPaintFooterLine.StrokeWidth = mFooterLineHeight;
            mPaintFooterLine.Color = footerColor;
            mPaintFooterIndicator.SetStyle(Android.Graphics.Paint.Style.FillAndStroke);
            mPaintFooterIndicator.Color = footerColor;

            a.Recycle();

            var configuration = ViewConfiguration.Get(context);
            mTouchSlop = ViewConfigurationCompat.GetScaledPagingTouchSlop(configuration);
        }
コード例 #40
0
        public TitlePageIndicator(Context context, IAttributeSet attrs, int defStyle)
            : base(context, attrs, defStyle)
        {
            if(IsInEditMode) return;

            var res = Resources;

            //Load defaults from resources
            var defaultFooterColor = res.GetColor(Resource.Color.default_title_indicator_footer_color);
            var defaultFooterLineHeight = res.GetDimension(Resource.Dimension.default_title_indicator_footer_line_height);
            var defaultFooterIndicatorStyle =
                res.GetInteger(Resource.Integer.default_title_indicator_footer_indicator_style);
            var defaultFooterIndicatorHeight =
                res.GetDimension(Resource.Dimension.default_title_indicator_footer_indicator_height);
            var defaultFooterIndicatorUnderlinePadding =
                res.GetDimension(Resource.Dimension.default_title_indicator_footer_indicator_underline_padding);
            var defaultFooterPadding = res.GetDimension(Resource.Dimension.default_title_indicator_footer_padding);
            var defaultLinePosition = res.GetInteger(Resource.Integer.default_title_indicator_line_position);
            var defaultSelectedColor = res.GetColor(Resource.Color.default_title_indicator_selected_color);
            var defaultSelectedBold = res.GetBoolean(Resource.Boolean.default_title_indicator_selected_bold);
            var defaultTextColor = res.GetColor(Resource.Color.default_title_indicator_text_color);
            var defaultTextSize = res.GetDimension(Resource.Dimension.default_title_indicator_text_size);
            var defaultTitlePadding = res.GetDimension(Resource.Dimension.default_title_indicator_title_padding);
            var defaultClipPadding = res.GetDimension(Resource.Dimension.default_title_indicator_clip_padding);
            var defaultTopPadding = res.GetDimension(Resource.Dimension.default_title_indicator_top_padding);

            var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.TitlePageIndicator, defStyle, 0);

            _footerLineHeight = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerLineHeight,
                                               defaultFooterLineHeight);
            _footerIndicatorStyle =
                (IndicatorStyle)a.GetInteger(Resource.Styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle);
            _footerIndicatorHeight = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerIndicatorHeight,
                                                    defaultFooterIndicatorHeight);
            _footerIndicatorUnderlinePadding =
                a.GetDimension(Resource.Styleable.TitlePageIndicator_footerIndicatorUnderlinePadding,
                               defaultFooterIndicatorUnderlinePadding);
            _footerPadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
            _linePosition =
                (LinePosition)a.GetInteger(Resource.Styleable.TitlePageIndicator_linePosition, defaultLinePosition);
            _topPadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_topPadding, defaultTopPadding);
            _titlePadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
            _clipPadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
            _colorSelected = a.GetColor(Resource.Styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
            _colorText = a.GetColor(Resource.Styleable.TitlePageIndicator_android_textColor, defaultTextColor);
            _boldText = a.GetBoolean(Resource.Styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);

            var textSize = a.GetDimension(Resource.Styleable.TitlePageIndicator_android_textSize, defaultTextSize);
            var footerColor = a.GetColor(Resource.Styleable.TitlePageIndicator_footerColor, defaultFooterColor);
            _paintText.TextSize = textSize;
            _paintFooterLine.SetStyle(Paint.Style.FillAndStroke);
            _paintFooterLine.StrokeWidth = _footerLineHeight;
            _paintFooterLine.Color = footerColor;
            _paintFooterIndicator.SetStyle(Paint.Style.FillAndStroke);
            _paintFooterIndicator.Color = footerColor;

            var background = a.GetDrawable(Resource.Styleable.TitlePageIndicator_android_background);
            if(null != background)
                Background = background;

            a.Recycle();

            var configuration = ViewConfiguration.Get(context);
            _touchSlop = ViewConfigurationCompat.GetScaledPagingTouchSlop(configuration);
        }
コード例 #41
0
ファイル: ATR.cs プロジェクト: fastquant/fastquant.dll
 public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
 {
     if (index >= length)
     {
         double sum = 0;
         double result;
         if (style == IndicatorStyle.QuantStudio)
         {
             for (var i = index; i > index - length; i--)
                 sum += TR.Value(input, i);
             result = sum / length;
         }
         else
         {
             for (int j = length; j > 0; j--)
                 sum += TR.Value(input, j)/length;
             sum /= length;
             for (var k = length + 1; k <= index; k++)
                 sum = (sum* (length - 1) + TR.Value(input, k))/length;
             result = sum;
         }
         return result;
     }
     return double.NaN;
 }
コード例 #42
0
ファイル: RSI.cs プロジェクト: ForTrade/CSharp
        public static double Value(ISeries input, int index, int length, BarData barData = BarData.Close, IndicatorStyle style = IndicatorStyle.QuantStudio)
        {
            double num  = 0.0;
            double num2 = 0.0;

            if (index >= length)
            {
                if (style == IndicatorStyle.QuantStudio)
                {
                    double num3 = input[index - length, barData];
                    for (int i = index - length + 1; i <= index; i++)
                    {
                        double num4 = input[i, barData];
                        if (num4 > num3)
                        {
                            num += num4 - num3;
                        }
                        else
                        {
                            num2 += num3 - num4;
                        }
                        num3 = num4;
                    }
                }
                else
                {
                    double num3 = input[0, barData];
                    for (int j = 1; j <= length; j++)
                    {
                        double num4 = input[j, barData];
                        if (num4 > num3)
                        {
                            num += num4 - num3;
                        }
                        else
                        {
                            num2 += num3 - num4;
                        }
                        num3 = num4;
                    }
                    num  /= (double)length;
                    num2 /= (double)length;
                    num3  = input[length, barData];
                    for (int k = length + 1; k <= index; k++)
                    {
                        num  *= (double)(length - 1);
                        num2 *= (double)(length - 1);
                        double num4 = input[k, barData];
                        if (num4 > num3)
                        {
                            num += num4 - num3;
                        }
                        else
                        {
                            num2 += num3 - num4;
                        }
                        num3  = num4;
                        num  /= (double)length;
                        num2 /= (double)length;
                    }
                }
                return(100.0 - 100.0 / (1.0 + num / num2));
            }
            return(double.NaN);
        }
コード例 #43
0
    private string GetTextFrom(IndicatorStyle style)
    {
        IndicatorStyleAttribute attribute = (IndicatorStyleAttribute)style.GetAttr();

        return(attribute.Text);
    }
コード例 #44
0
ファイル: SnippetManager.cs プロジェクト: dbbotkin/PrimeComm
 private void ResetInactiveSnippetIndicatorStyle()
 {
     _inactiveSnippetIndicatorStyle = IndicatorStyle.Box;
 }
コード例 #45
0
ファイル: Indicator.cs プロジェクト: jtheisen/ScintillaNET26
 /// <summary>
 ///     Resets all indicator display properties to their respective defaults.
 /// </summary>
 public void Reset()
 {
     Alpha = 30;
     Color = GetDefaultColor();
     DrawMode = IndicatorDrawMode.Overlay;
     OutlineAlpha = 50;
     Style = GetDefaultStyle();
 }