Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 14:37:13 +0000



Post From: Polarized Fractal Efficcency

[2014-02-09 08:10:07]
esMike - Posts: 69
I noticed SierraChart doesn't have the Fractal Efficcency indicator...

So I attempted to code one up. Can someone help verify this code is correct? The indicator is a bit abstract... The readings only seem to look right for a period of 10.

SCSFExport scsf_FractalEff(SCStudyGraphRef sc)
{
  SCSubgraphRef Eff = sc.Subgraph[0];

  SCSubgraphRef bullLine = sc.Subgraph[1];
  SCSubgraphRef bearLine = sc.Subgraph[2];

  SCInputRef Period = sc.Input[1];

  if (sc.SetDefaults)
  {
    sc.GraphName = "Fractal Efficcency";
    sc.StudyDescription = "Fractal Efficcency";

    sc.AutoLoop = 1;
    sc.FreeDLL = 0;

    sc.GraphRegion = 1;

    Eff.Name = "Eff";
    Eff.DrawStyle = DRAWSTYLE_BAR;
    Eff.LineWidth = 13;
    Eff.PrimaryColor = RGB(110,190,110);
    Eff.SecondaryColor = RGB(190,110,110);
    Eff.AutoColoring = AUTOCOLOR_POSNEG;
    Eff.LineLabel = LL_DISPLAY_VALUE | LL_VALUE_ALIGN_VALUES_SCALE | LL_VALUE_ALIGN_CENTER;
    Eff.DrawZeros = 1;
    Eff.SecondaryColorUsed = 1;

    bullLine.Name = "Bull Line";
    bullLine.DrawStyle = DRAWSTYLE_LINE;
    bullLine.PrimaryColor = RGB(130,130,130);

    bearLine.Name = "Bear Line";
    bearLine.DrawStyle = DRAWSTYLE_LINE;
    bearLine.PrimaryColor = RGB(130,130,130);

    Period.Name = "Period (2-48)";
    Period.SetInt(10);
    Period.SetIntLimits(2,48);

    return;
  }

  int periodInt = Period.GetInt();

  float PFE = 0;
  float C2C = 0;
  float Counter = 0;
  float FracEff = 0;
PFE = sqrt(powf((sc.Close[sc.Index] - sc.Close[sc.Index-periodInt-1]),2) + 100);

for (Counter = 1; Counter < periodInt; Counter++) {
C2C += sqrt(powf((sc.Close[-Counter + 1 + sc.Index] - sc.Close[-Counter + sc.Index]), 2) + 1);
}

  if (sc.Close[sc.Index] - sc.Close[sc.Index-periodInt-1] > 0){
    FracEff = (PFE / C2C) * 100;
  } else {
    FracEff = -(PFE / C2C) * 100;
  }

  Eff[sc.Index] = FracEff;


  bullLine[sc.Index] = 50;
  bearLine[sc.Index] = -50;
}

Original code it was modified from...

http://forum.esignal.com/showthread.php?28812-PFE-Polarized-Fractal-Efficiency
Date Time Of Last Edit: 2014-02-09 08:10:56