public void StartSound()
 {
     playing++;
     if (playing > 0)
     {
         if (SoundPlayer != null)
         {
             SoundPlayer.ContinuePlaying();
             SoundPlayer.SetVolume(1);
         }
         if (SoundIndicator != null)
             SoundIndicator.Stop();
         SoundIndicator = IndicatorManager.ShowAudioIndicator(this.gameObject, float.MaxValue, 0.5f);
     }
 }
 public void StartBell()
 {
     //Debug.Log("startBell called");
     playing++;
     if (playing >= 0)
     {
         if (bellPlayer != null)
         {
             bellPlayer.ContinuePlaying();
             bellPlayer.SetVolume(1);
         }
         if (bellIndicator != null)
             bellIndicator.Stop();
         bellIndicator = IndicatorManager.ShowAudioIndicator(this.gameObject, float.MaxValue, 0.5f);
     }
 }
Example #3
0
        /// <summary>
        /// 添加指标公式
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public BaseIndicator ChangeIndicator(String text)
        {
            indicatorName = text;
            BaseIndicator indicator = AddIndicator(text);

            if (div2Indicator != null)
            {
                DeleteIndicator(div2Indicator);
                switch (text)
                {
                case "ASI":
                    (indicator as IndicatorAccumulationSwingIndex).SetParam(COLUMN_OPEN, COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, 6, macdDiv);
                    break;

                case "ADTM":
                    (indicator as IndicatorADTM).SetParam(COLUMN_OPEN, COLUMN_HIGH, COLUMN_LOW, 23, 8, macdDiv);
                    break;

                case "ATR":
                    (indicator as IndicatorAverageTrueRange).SetParam(COLUMN_HIGH, COLUMN_LOW, 14, macdDiv);
                    break;

                case "BBI":
                    (indicator as IndicatorBullandBearIndex).SetParam(COLUMN_CLOSE, 3, 6, 12, 24, macdDiv);
                    break;

                case "BIAS":
                    (indicator as IndicatorBIAS).SetParam(COLUMN_CLOSE, 6, macdDiv);
                    break;

                case "BOLL":
                    (indicator as IndicatorBollingerBands).SetParam(COLUMN_CLOSE, 20, 2, macdDiv);
                    break;

                case "CCI":
                    (indicator as IndicatorCommodityChannelIndex).SetParam(COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, 14, macdDiv);
                    break;

                case "CHAIKIN":
                    (indicator as IndicatorChaikinOscillator).SetParam(COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, COLUMN_VOLUME, 10, 20, 6, macdDiv);
                    break;

                case "DDI":
                    (indicator as IndicatorDirectionDeviationIndex).SetParam(COLUMN_HIGH, COLUMN_LOW, 13, 30, 10, 5, macdDiv);
                    break;

                case "DMA":
                    (indicator as IndicatorDifferentOfMovingAverage).SetParam(COLUMN_CLOSE, 10, 50, 10, macdDiv);
                    break;

                case "DMI":
                    (indicator as IndicatorDirectionalMovementIndex).SetParam(COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, 14, 6, macdDiv);
                    break;

                case "DPO":
                    (indicator as IndicatorDetrendedPriceOscillator).SetParam(COLUMN_CLOSE, 20, 11, 6, macdDiv);
                    break;

                case "EMA":
                    (indicator as IndicatorExponentialMovingAverage).SetParam(COLUMN_CLOSE, 5, macdDiv);
                    break;

                case "KDJ":
                    (indicator as IndicatorStochasticOscillator).SetParam(COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, 9, 3, 3, macdDiv);
                    break;

                case "LWR":
                    (indicator as IndicatorLWR).SetParam(COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, 9, 3, 3, macdDiv);
                    break;

                case "MACD":
                    (indicator as IndicatorMACD).SetParam(COLUMN_CLOSE, 12, 26, 9, macdDiv);
                    break;

                case "MASS":
                    (indicator as IndicatorMassIndex).SetParam(COLUMN_HIGH, COLUMN_LOW, 25, 9, macdDiv);
                    break;

                case "MTM":
                    (indicator as IndicatorMomentumIndex).SetParam(COLUMN_CLOSE, 12, 6, macdDiv);
                    break;

                case "NVI":
                    (indicator as IndicatorNegativeVolumeIndex).SetParam(COLUMN_VOLUME, COLUMN_CLOSE, 72, macdDiv);
                    break;

                case "OBV":
                    (indicator as IndicatorOnBalanceVolume).SetParam(COLUMN_CLOSE, COLUMN_VOLUME, macdDiv);
                    break;

                case "OSC":
                    (indicator as IndicatorOscillator).SetParam(COLUMN_CLOSE, 10, 6, macdDiv);
                    break;

                case "PBX":
                    (indicator as IndicatorPBX).SetParam(COLUMN_CLOSE, 4, macdDiv);
                    break;

                case "PSY":
                    (indicator as IndicatorPsychologicalLine).SetParam(COLUMN_CLOSE, 12, macdDiv);
                    break;

                case "PVI":
                    (indicator as IndicatorPositiveVolumeIndex).SetParam(COLUMN_VOLUME, COLUMN_CLOSE, 72, macdDiv);
                    break;

                case "ROC":
                    (indicator as IndicatorRateOfChange).SetParam(COLUMN_CLOSE, 12, 6, macdDiv);
                    break;

                case "RSI":
                    (indicator as IndicatorRelativeStrengthIndex).SetParam(COLUMN_CLOSE, 6, macdDiv);
                    break;

                case "SAR":
                    (indicator as IndicatorStopAndReveres).SetParam(COLUMN_HIGH, COLUMN_LOW, 4, 2, 20, macdDiv);
                    break;

                case "SD":
                    (indicator as IndicatorStandardDeviation).SetParam(COLUMN_CLOSE, 14, 2, macdDiv);
                    break;

                case "SLOWKD":
                    (indicator as IndicatorSlowStochasticOscillator).SetParam(COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, 9, 3, 3, 3, macdDiv);
                    break;

                case "MA":
                    (indicator as IndicatorMovingAverage).SetParam(COLUMN_CLOSE, macdDiv);
                    break;

                case "SMA":
                    (indicator as IndicatorSimpleMovingAverage).SetParam(COLUMN_CLOSE, 5, 1, macdDiv);
                    break;

                case "TRIX":
                    (indicator as IndicatorTripleExponentiallySmoothedMovingAverage).SetParam(COLUMN_CLOSE, 12, 12, macdDiv);
                    break;

                case "VR":
                    (indicator as IndicatorVolumeRatio).SetParam(COLUMN_CLOSE, COLUMN_VOLUME, 26, 6, macdDiv);
                    break;

                case "WR":
                    (indicator as IndicatorWilliamsAndRate).SetParam(COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, 10, macdDiv);
                    break;

                case "WVAD":
                    (indicator as IndicatorWVAD).SetParam(COLUMN_VOLUME, COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, COLUMN_OPEN, 24, 6, macdDiv);
                    break;
                }
                indicators.Remove(indicator);
                div2Indicator = indicator;
                indicators.Add(div2Indicator);
                div2Indicator.OnCalculate(0);
                RefreshGraph();
            }
            if (!Program.BlackOrWhite)
            {
                List <BaseShape> shapes = indicator.GetShapeList();
                for (int i = 0; i < shapes.Count; i++)
                {
                    BaseShape bShape = shapes[i] as BaseShape;
                    if (bShape is BarShape)
                    {
                        (bShape as BarShape).DownColor = Color.Black;
                        (bShape as BarShape).UpColor   = Color.Black;
                    }
                    else if (bShape is LineShape)
                    {
                        (bShape as LineShape).LineColor = Color.Black;
                    }
                }
            }
            return(indicator);
        }