示例#1
1
      public static void addAnnotations(UltraChart chart,  DateTime date_, DeMarkMarker mark, int i, double cellHeight, double[] arr, int openIndex_, int highIndex_, int lowIndex_, int closeIndex_)
    {
      if (mark.Disabled.HasValue) return;

      if (mark.Date == date_)
      {
        switch (mark.EventType)
        {
          case DeMarkEventType.BuySetupStart:
            {
              //var annotation = createAnnotation("BuySetup", i + 0.5d, arr[lowIndex_] - (2 * cellHeight),
              //  Color.LightGreen);
              //chart.Annotations.Add(annotation);
            }
            {
              var annotation = createHorizontalLineAnnotation(i + 0.5d, i + 50.5d, arr[highIndex_], Color.Red);
              chart.Annotations.Add(annotation);
            }
            break;
          case DeMarkEventType.BuySetupIndex:
            {
              var annotation = createAnnotation(mark.SeriesIndex.ToString(), i + 0.5d, arr[lowIndex_] - (cellHeight / 5d), mark.SeriesIndex == mark.SetupSeriesLength,
                Color.LimeGreen);
              chart.Annotations.Add(annotation);
            }
            break;
          case DeMarkEventType.ReducingCountDown:
            {
                var annotation = createAnnotation(mark.SeriesIndex.ToString(), i + 0.5d, arr[lowIndex_] - (cellHeight / 2.5d), mark.SeriesIndex == mark.CountDownLength,
                Color.Red);
              chart.Annotations.Add(annotation);
            }
            break;
          case DeMarkEventType.SellSetupStart:
            {
              //var annotatio = createAnnotation("SellSetup", i + 0.5d, arr[highIndex_] + (2 * cellHeight),
              //  Color.Red);
              //chart.Annotations.Add(annotatio);
            }
            {
              var annotation = createHorizontalLineAnnotation(i + 0.5d, i + 50.5d, arr[lowIndex_], Color.LimeGreen);
              chart.Annotations.Add(annotation);
            }
            break;
          case DeMarkEventType.SellSetupIndex:
            {
                var annotation = createAnnotation(mark.SeriesIndex.ToString(), i + 0.5d, arr[highIndex_] + (cellHeight / 5d), mark.SeriesIndex == mark.SetupSeriesLength,
                Color.LimeGreen);
              chart.Annotations.Add(annotation);
            }
            break;
          case DeMarkEventType.IncreasingCountDown:
            {
                var annotation = createAnnotation(mark.SeriesIndex.ToString(), i + 0.5d, arr[highIndex_] + (cellHeight / 2.5d), mark.SeriesIndex == mark.CountDownLength,
                Color.Red);
              chart.Annotations.Add(annotation);

            }
            break;
          //case DeMarkEventType.CountDownStop:
          //  {
          //      var annotation = createHorizontalLineAnnotation(i + 0.5d, i + 50.5d, arr[highIndex_], Color.BlanchedAlmond);
          //      chart.Annotations.Add(annotation);
          //  }
          //  break;          
          case DeMarkEventType.PerfectedSellSetup:
            {
                var annotation = createArrowAnnotation(i + 0.5d, arr[highIndex_] + (cellHeight / 1.39d), arr[highIndex_] + (cellHeight / 1.9d), Color.Red);
                chart.Annotations.Add(annotation);
            }
            break;
          case DeMarkEventType.PerfectedBuySetup:
                {
                    var annotation = createArrowAnnotation(i + 0.5d, arr[lowIndex_] - (cellHeight / 1.39d), arr[lowIndex_] - (cellHeight / 1.9d), Color.LimeGreen);
                chart.Annotations.Add(annotation);
            }
            break;

        }
      }

      if(mark.HasChildren)
        foreach (var m in mark.Children)
            addAnnotations(chart, date_, m, i, cellHeight, arr, openIndex_, highIndex_, lowIndex_, closeIndex_);
    }
示例#2
0
    public void AddChild(DeMarkMarker mark_)
    {
      if (mark_ == null) return;

      if (m_children == null) m_children = new List<DeMarkMarker>();

      m_children.Add(mark_);
    }
示例#3
0
    public static List<DeMarkMarker> GetSetups(ConstructGen<double> prices_, int openIndex_ = 0, int highIndex_ = 1, int lowIndex_ = 2,
  int closeIndex_ = 3, int targetSeriesLength = 9)
    {
      var closes = prices_.GetColumnValuesAsDDC(closeIndex_);
      var highs = prices_.GetColumnValuesAsDDC(highIndex_);
      var lows = prices_.GetColumnValuesAsDDC(lowIndex_);
      var ret = new List<DeMarkMarker>();
      int lowerSetupCount = 0;
      int higherSetupCount = 0;

      for (int i = 4; i < closes.Length; ++i)
      {
        {
            if (closes.Data[i] < closes.Data[i - 4])
            {
                /////Setup Cancellation////
                //if the setups do not reach the target, we cancel the setup
                if (higherSetupCount > 0 && higherSetupCount < targetSeriesLength)
                {
                    higherSetupCount = 0;
                    ret.RemoveAt(ret.Count - 1);
                }
                ++lowerSetupCount;
            }                
            else
            {
                /////Setup Cancellation////
                //if the setups do not reach the target, we cancel the setup
                if (lowerSetupCount > 0 && lowerSetupCount < targetSeriesLength)
                    ret.RemoveAt(ret.Count - 1);

                lowerSetupCount = 0;                
            }

            if (lowerSetupCount > 0)
            {
              if (lowerSetupCount == 1)
              {
                  // setups start.
                  var mark = new DeMarkMarker
                  {
                      Date = closes.Dates[i],
                      EventType = DeMarkEventType.BuySetupStart,
                      PriceIndex = i,
                      SeriesIndex = 1,
                      SetupSeriesLength = targetSeriesLength,
                  };

                  ret.Add(mark);
              }

              var recentSetupStart = ret.Last();
              recentSetupStart.AddChild(new DeMarkMarker
              {
                  Date = closes.Dates[i],
                  EventType = DeMarkEventType.BuySetupIndex,
                  PriceIndex = i,
                  SeriesIndex = lowerSetupCount,
                  SetupSeriesLength = targetSeriesLength,
              });

                if (lowerSetupCount == targetSeriesLength)
                {
                    lowerSetupCount = 0;

                    if ((lows.Data[i] <= lows.Data[i-2] && lows.Data[i] <= lows.Data[i-3]) ||
                        (lows.Data[i-1] <= lows.Data[i-2] && lows.Data[i] <= lows.Data[i-3]))
                        recentSetupStart.AddChild(new DeMarkMarker
                        {
                            Date = closes.Dates[i],
                            EventType = DeMarkEventType.PerfectedBuySetup,
                            PriceIndex = i,
                            SeriesIndex = lowerSetupCount,
                            SetupSeriesLength = targetSeriesLength,
                        });
                }
                
            }
        }
        {
            if (closes.Data[i] > closes.Data[i - 4])
            {
                if (lowerSetupCount > 0 && lowerSetupCount < targetSeriesLength)
                {
                    lowerSetupCount = 0;
                    ret.RemoveAt(ret.Count - 1);
                }
                ++higherSetupCount;
            }
            else
            {
                /////Setup Cancellation////
                //if the setups do not reach the target, we cancel the setup
                if (higherSetupCount > 0 && higherSetupCount < targetSeriesLength)
                    ret.RemoveAt(ret.Count - 1);
                higherSetupCount = 0;
            }

            if (higherSetupCount > 0)
          {
              if (higherSetupCount == 1)
              {
                  var mark = new DeMarkMarker
                  {
                      Date = closes.Dates[i],
                      EventType = DeMarkEventType.SellSetupStart,
                      PriceIndex = i,
                      SeriesIndex = 1,
                      SetupSeriesLength = targetSeriesLength,
                  };

                  ret.Add(mark);
              }

              var recentSetupStart = ret.Last();
             
                recentSetupStart.AddChild(new DeMarkMarker
              {
                Date = closes.Dates[i],
                EventType = DeMarkEventType.SellSetupIndex,
                PriceIndex = i,
                SeriesIndex = higherSetupCount,
                SetupSeriesLength = targetSeriesLength,
              });


              if (higherSetupCount == targetSeriesLength)
              {
                  higherSetupCount = 0;

                  if ((highs.Data[i] >= highs.Data[i - 2] && highs.Data[i] >= highs.Data[i - 3]) ||
                     (highs.Data[i - 1] >= highs.Data[i - 2] && highs.Data[i] >= highs.Data[i - 3]))
                      recentSetupStart.AddChild(new DeMarkMarker
                      {
                          Date = closes.Dates[i],
                          EventType = DeMarkEventType.PerfectedSellSetup,
                          PriceIndex = i,
                          SeriesIndex = lowerSetupCount,
                          SetupSeriesLength = targetSeriesLength,
                      });
              }
          }
        }
      }

      // if one setup immediately continues in the another one,
      // then disable the latter one

      if (ret.Count > 1)
        for (int i = 1; i < ret.Count; ++i)
        {
          if (ret[i].Disabled.HasValue == false && ret[i - 1].Disabled.HasValue == false && ret[i].EventType == ret[i - 1].EventType &&
              ret[i].PriceIndex == (ret[i - 1].PriceIndex + targetSeriesLength))
            ret[i].Disabled = ret[i - 1].Date;
        }

      return ret;
    }