示例#1
0
        protected override bool Create(MetroPanel panel)
        {
            _absoluteAlert = new AbsoluteAlert();
            // custom alert
            if (panel.Controls["cBoxType"].Text == Types[2])
            {
                if (!float.TryParse(panel.Controls["txtValue"].Text.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _absoluteAlert.Trigger))
                {
                    System.Windows.Forms.MessageBox.Show("Something is wrong in price section.");
                    return(false);
                }
                if (_absoluteAlert.Trigger > 100 || _absoluteAlert.Trigger < 0)
                {
                    System.Windows.Forms.MessageBox.Show("RSI value must be between 0 and 100");
                    return(false);
                }
                if (!int.TryParse(panel.Controls["txtLength"].Text.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _length))
                {
                    System.Windows.Forms.MessageBox.Show("Something is wrong in length section.");
                    return(false);
                }
                if (_length <= 0)
                {
                    System.Windows.Forms.MessageBox.Show("Length cannot be less than 1.");
                    return(false);
                }
                _type = 2;
                _absoluteAlert.Type = AbsoluteAlert.StringToCondition(panel.Controls["cBoxCondition"].Text);
                _source             = StringToSource(panel.Controls["cBoxSource"].Text);
            }
            else if (panel.Controls["cBoxType"].Text == Types[0])             // overbought
            {
                _absoluteAlert.Trigger = 70;
                _absoluteAlert.Type    = TriggerType.higherOrEqual;
                _type = 0;
            }
            else if (panel.Controls["cBoxType"].Text == Types[1])             // oversold
            {
                _absoluteAlert.Trigger = 30;
                _absoluteAlert.Type    = TriggerType.lowerOrEqual;
                _type = 1;
            }
            else
            {
                // combobox has different text other than expected
                throw new ArgumentException();
            }
            if (((MetroComboBox)panel.Controls["cBoxTimeframe"]).SelectedIndex == -1)
            {
                System.Windows.Forms.MessageBox.Show("Please select timeframe.");
                return(false);
            }

            timeframe = AbstractAPI.StringToTimeframe(panel.Controls["cBoxTimeframe"].Text);
            return(true);
        }
示例#2
0
 protected override bool Create(MetroPanel panel)
 {
     _absoluteAlert = new AbsoluteAlert();             // when editing alert last price is saved from previous one
     if (!float.TryParse(panel.Controls["txtValue"].Text.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _absoluteAlert.Trigger))
     {
         System.Windows.Forms.MessageBox.Show("Something is wrong in value section.");
         return(false);
     }
     _absoluteAlert.Type = AbsoluteAlert.StringToCondition(panel.Controls["cBoxCondition"].Text);
     return(true);
 }
示例#3
0
        protected override bool Create(MetroPanel panel)
        {
            _absoluteAlert = new AbsoluteAlert();
            // custom alert
            if (panel.Controls["cBoxType"].Text == _types[2])
            {
                if (!float.TryParse(panel.Controls["txtValue"].Text.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _absoluteAlert.Trigger))
                {
                    System.Windows.Forms.MessageBox.Show("Something is wrong in price section.");
                    return(false);
                }
                if (_absoluteAlert.Trigger > 100 || _absoluteAlert.Trigger < 0)
                {
                    System.Windows.Forms.MessageBox.Show("Stoch value must be between 0 and 100");
                    return(false);
                }
                if (!int.TryParse(panel.Controls["txtK"].Text.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _lengthK))
                {
                    System.Windows.Forms.MessageBox.Show("Something is wrong in length section.");
                    return(false);
                }
                if (!int.TryParse(panel.Controls["txtD"].Text.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _lengthD))
                {
                    System.Windows.Forms.MessageBox.Show("Something is wrong in length section.");
                    return(false);
                }
                //if (!int.TryParse(panel.Controls["txtSmooth"].Text.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _lengthSmooth))
                //{
                //	System.Windows.Forms.MessageBox.Show("Something is wrong in length section.");
                //	return false;
                //}
                if (_lengthD < 1 || _lengthK < 1 || _lengthSmooth < 1)
                {
                    System.Windows.Forms.MessageBox.Show("Custom values must be positive.");
                    return(false);
                }
                _absoluteAlert.Type = AbsoluteAlert.StringToCondition(panel.Controls["cBoxCondition"].Text);
                _type       = 2;
                _isDTrigger = ((MetroCheckBox)(panel.Controls["chcBoxTriggerType"])).Checked;
            }
            else if (panel.Controls["cBoxType"].Text == _types[0])             // overbought
            {
                _absoluteAlert.Trigger = 80;
                _absoluteAlert.Type    = TriggerType.higherOrEqual;
                _type = 0;
            }
            else if (panel.Controls["cBoxType"].Text == _types[1])             // oversold
            {
                _absoluteAlert.Trigger = 20;
                _absoluteAlert.Type    = TriggerType.lowerOrEqual;
                _type = 1;
            }
            else
            {
                // combobox has different text other than expected
                throw new ArgumentException();
            }
            if (((MetroComboBox)panel.Controls["cBoxTimeframe"]).SelectedIndex == -1)
            {
                System.Windows.Forms.MessageBox.Show("Please select timeframe.");
                return(false);
            }

            _isDTrigger = ((MetroCheckBox)panel.Controls["chcBoxTriggerType"]).Checked;
            timeframe   = AbstractAPI.StringToTimeframe(panel.Controls["cBoxTimeframe"].Text);

            return(true);
        }
示例#4
0
 protected override bool Create(MetroPanel panel)
 {
     _absoluteAlert1 = new AbsoluteAlert();
     _absoluteAlert2 = new AbsoluteAlert();
     if (panel.Controls["cBoxType"].Text == _types[4])
     {
         if (!int.TryParse(panel.Controls["txtSlowLength"].Text, out _slowLength))
         {
             System.Windows.Forms.MessageBox.Show("Something is wrong in slow length section.");
             return(false);
         }
         if (!int.TryParse(panel.Controls["txtFastLength"].Text, out _fastLength))
         {
             System.Windows.Forms.MessageBox.Show("Something is wrong in fast length section.");
             return(false);
         }
         if (_slowLength < 1 || _fastLength < 1)
         {
             System.Windows.Forms.MessageBox.Show("Length cannot be less than 1.");
             return(false);
         }
         _absoluteAlert1.Type = AbsoluteAlert.StringToCondition(panel.Controls["cBoxCondition"].Text);
         _absoluteAlert2.Type = AbsoluteAlert.StringToCondition(panel.Controls["cBoxCondition"].Text);
         if (((MetroComboBox)(panel.Controls["cBoxOn"])).SelectedIndex == -1)
         {
             System.Windows.Forms.MessageBox.Show("Please select on what to trigger.");
             return(false);
         }
         _onType = StringToOnType(panel.Controls["cBoxOn"].Text);
         if (!float.TryParse(panel.Controls["txtValue"].Text.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _absoluteAlert1.Trigger))
         {
             if (_absoluteAlert1.Type != TriggerType.crossing && (int)_onType > 2)
             {
                 System.Windows.Forms.MessageBox.Show("Something is wrong in value section.");
                 return(false);
             }
             _absoluteAlert1.Trigger = float.MinValue;
         }
         _type = 4;
         _absoluteAlert2.Trigger = _absoluteAlert1.Trigger;
     }
     else if (panel.Controls["cBoxType"].Text == "Buy signal")
     {
         _absoluteAlert1.Type    = TriggerType.crossing;
         _absoluteAlert1.Trigger = float.MinValue;
         _onType = OnType.MACD_Signal;
         _type   = 0;
     }
     else if (panel.Controls["cBoxType"].Text == "Sell signal")
     {
         _absoluteAlert1.Type    = TriggerType.crossing;
         _absoluteAlert1.Trigger = float.MinValue;
         _onType = OnType.MACD_Signal;
         _type   = 1;
     }
     else if (panel.Controls["cBoxType"].Text == "Positive")
     {
         _absoluteAlert1.Type    = TriggerType.higher;
         _absoluteAlert1.Trigger = 0;
         _onType = OnType.MACD;
         _type   = 2;
     }
     else if (panel.Controls["cBoxType"].Text == "Negative")
     {
         _absoluteAlert1.Type    = TriggerType.lower;
         _absoluteAlert1.Trigger = 0;
         _onType = OnType.MACD;
         _type   = 3;
     }
     else
     {
         // combobox has different text other than expected
         throw new ArgumentException();
     }
     if (((MetroComboBox)panel.Controls["cBoxTimeframe"]).SelectedIndex == -1)
     {
         System.Windows.Forms.MessageBox.Show("Please select timeframe.");
         return(false);
     }
     _slowLength = int.Parse(panel.Controls["txtSlowLength"].Text);
     _fastLength = int.Parse(panel.Controls["txtFastLength"].Text);
     timeframe   = AbstractAPI.StringToTimeframe(panel.Controls["cBoxTimeframe"].Text);
     return(true);
 }