Login Page - Create Account

Support Board


Date/Time: Sun, 06 Oct 2024 09:57:07 +0000



Post From: Bill Williams Fractal study errors

[2014-12-24 02:02:46]
User56304 - Posts: 33
Here is the bulk of your code repair. However it does not address all the nuances of multiple tops/bottoms as can be seen here:

https://www.linnsoft.com/techind/fractals-swing-highs-swing-lows


Code snippet:


/***********************************************************************/
bool IsFractalBuySignal(SCFloatArrayRef InDataLow, SCFloatArrayRef InDataHigh, int index, int ArraySize)
{
  if (  
    ( ((index+2) <= (ArraySize-1)) &&
    InDataHigh[index] > InDataHigh[index + 1] && InDataHigh[index] > InDataHigh[index + 2] &&
    InDataHigh[index] > InDataHigh[index - 1] && InDataHigh[index] > InDataHigh[index - 2]
  )
    ||
    ( ((index+3) <= (ArraySize-1)) &&
    InDataHigh[index] > InDataHigh[index + 2] && InDataHigh[index] > InDataHigh[index + 3] &&
    InDataHigh[index] > InDataHigh[index - 1] && InDataHigh[index] > InDataHigh[index - 2] &&
    InDataHigh[index] == InDataHigh[index + 1]
  )
    ||
    ( ((index+4) <= (ArraySize-1)) &&
    InDataHigh[index] > InDataHigh[index + 3] && InDataHigh[index] > InDataHigh[index + 4] &&
    InDataHigh[index] > InDataHigh[index - 1] && InDataHigh[index] > InDataHigh[index - 2] &&
    InDataHigh[index] == InDataHigh[index + 1] && InDataHigh[index + 1] == InDataHigh[index + 2]
  )
    )
    return true;

  return false;
}

/***********************************************************************/
bool IsFractalSellSignal(SCFloatArrayRef InDataLow, int index, int ArraySize)
{
  if (
    ( ((index+2) <= (ArraySize-1)) &&
    InDataLow[index] < InDataLow[index + 1] && InDataLow[index] < InDataLow[index + 2] &&
    InDataLow[index] < InDataLow[index - 1] && InDataLow[index] < InDataLow[index - 2]
  )
    ||
    ( ((index+3) <= (ArraySize-1)) &&
    InDataLow[index] < InDataLow[index + 2] && InDataLow[index] < InDataLow[index + 3] &&
    InDataLow[index] < InDataLow[index - 1] && InDataLow[index] < InDataLow[index - 2] &&
    InDataLow[index] == InDataLow[index + 1]
  )
    ||
    ( ((index+4) <= (ArraySize-1)) &&
    InDataLow[index] < InDataLow[index + 3] && InDataLow[index] < InDataLow[index + 4] &&
    InDataLow[index] < InDataLow[index - 1] && InDataLow[index] < InDataLow[index - 2] &&
    InDataLow[index] == InDataLow[index + 1] && InDataLow[index + 1] == InDataLow[index + 2]
  )
    )
    return true;

  return false;
}