Profile Picture

RList Crossover

Posted By johan 2 Years Ago
Message
Posted Thursday June 04 2015
I have two Rlists where I need to test CrossOver of one over the other.  The SystemUtils.CrossOver need two Iseries as input.  Can you please assist in how I could achieve this.
Posted Sunday June 07 2015
I've added CrossOver and CrossUnder methods that take RList<double> for the next build.  For now, here's the code for the CrossOver method:


public static bool CrossOver(RList<double> Signal, RList<double> Base)
{
  int baseCount = Base.Count;
  int signalCount = Signal.Count;

  if (baseCount < 2 || signalCount < 2)
  {
   return false;
  }

  if (Signal.LookBack(0) <= Base.LookBack(0))
  {
   return false;
  }

  for (int lookBack = 1; lookBack < Signal.Count && lookBack < Base.Count; lookBack++)
  {

   double s = Signal.LookBack(lookBack);
   double b = Base.LookBack(lookBack);

   if (s > b)
   {
    //If there was a crossover, it did not happen on this bar
    return false;
   }
   else if (s < b)
   {
    //It was a crossover
    return true;
   }
  }

  //We reached the beginning of the series without getting a crossover
  return false;
}


Thanks,
Daniel
Posted Wednesday June 10 2015
Thanks Daniel.


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems