Beispiel #1
0
 private void add(levlel el)
 {
     if (el.Value == 0)
     {
         return;
     }
     if (updateLevelData(el))
     {
         return;
     }
     LevleData.Add(el);
     LevleData.Sort((a, b) => decimal.Compare(a.Value, b.Value));
     if (LevleData.Count > 6)
     {
         decimal avg = (LevleData[LevleData.Count - 1].Value + LevleData[0].Value) / 2;
         if (el.Value > avg)
         {
             LevleData.RemoveAt(0);
         }
         if (el.Value < avg)
         {
             LevleData.RemoveAt(LevleData.Count - 1);
         }
     }
     Save();
 }
Beispiel #2
0
        private void ProcessValue(List <Candle> candles, int i)
        {
            int j = --i;

            if (j > 2)
            {
                if (Values[j] <= Values[j - 1] &&
                    Values[j - 2] <= Values[j - 1] &&
                    Values[j] != Values[j - 2]
                    )
                {
                    levlel el = new levlel();
                    el.levlSide = Side.Sell;
                    el.Value    = Values[j - 1];
                    add(el);
                }

                if (Values[j] >= Values[j - 1] &&
                    Values[j - 2] >= Values[j - 1] &&
                    Values[j] != Values[j - 2]
                    )
                {
                    levlel el = new levlel();
                    el.levlSide = Side.Buy;
                    el.Value    = Values[j - 1];
                    add(el);
                }
            }

            //   DeleteCorrection();
        }
Beispiel #3
0
        public List <levlel> LevleData;// = new List<levlel>();
        /// <summary>
        /// Индикатор АТР
        /// </summary>
        //   public Atr Atr;

        private bool updateLevelData(levlel lvl)
        {
            levlel findlvl = LevleData.Find(x => x.Value + (linewidth * x.Value) > lvl.Value && x.Value - (linewidth * x.Value) < lvl.Value);

            if (findlvl != null)
            {
                findlvl.levlSide = lvl.levlSide;
                findlvl.Value    = lvl.Value;
                return(true);
            }
            return(false);
        }
Beispiel #4
0
 public void PaintLevleData(List <OsTrader.Panels.Tab.BotTabSimple> _tabs)
 {
     if (lines == null)
     {
         lines = new List <Elements.LineHorisontal>();
     }
     for (int i = 0; i < LevleData.Count; i++)
     {
         Elements.LineHorisontal line = lines.Find(x => x.Value == LevleData[i].Value);
         if (line != null)
         {
         }
         else
         {
             line = new Elements.LineHorisontal("line" + LevleData[i].Value.ToString(), "Prime", false)
             {
                 Color = Color.Yellow,
                 Value = LevleData[i].Value,
             };
             lines.Add(line);
             for (int ind = 0; ind < _tabs.Count; ind++)
             {
                 _tabs[ind].SetChartElement(line);
             }
         }
     }
     for (int i = 0; i < lines.Count; i++)
     {
         levlel lvl = LevleData.Find(x => x.Value == lines[i].Value);
         if (lvl == null)
         {
             for (int ind = 0; ind < _tabs.Count; ind++)
             {
                 _tabs[ind].DeleteChartElement(lines[i]);
             }
             lines.RemoveAt(i);
         }
         else
         {
             lines[i].Refresh();
         }
     }
 }