Login Page - Create Account

Support Board


Date/Time: Fri, 29 Mar 2024 06:16:20 +0000



Post From: SUPERTREND WITH HULL MOVING AVERAGE

[2015-02-11 13:18:37]
Carl71 - Posts: 125
What's wrong with that? I'have tried to replace SIMPLE with HULL in the formula but I am not able to create a .dll from .cpp
Can you give me this .dll?


_/*============================================================================
  SuperTrend Stop study function.
----------------------------------------------------------------------------*/
SCSFExport scsf_SuperTrendStop(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Stop = sc.Subgraph[0];
  
  SCSubgraphRef Median = sc.Subgraph[1];

  SCFloatArrayRef TrueRange = Stop.Arrays[0];
  SCFloatArrayRef AvgTrueRange = Stop.Arrays[1];
  SCFloatArrayRef Trend = Stop.Arrays[2];


  SCInputRef ATRMultiplier = sc.Input[0];
  SCInputRef ATRPeriod = sc.Input[1];
  SCInputRef MedianPeriod = sc.Input[2];

  // Set configuration variables
  if (sc.SetDefaults)
  {
    // Set the configuration and defaults
    sc.GraphName = "SuperHullTrend Stop";
    
    sc.StudyDescription = "";
    sc.DrawZeros = false;
    sc.GraphRegion = 0;
    sc.ValueFormat = sc.BaseGraphValueFormat;
    
    //During development set this flag to 1, so the DLL can be modified. When development is completed, set it to 0 to improve performance.
    sc.FreeDLL = 0;
    
    sc.AutoLoop = 1;
    
    Stop.Name = "Stop";
    Stop.DrawStyle = DRAWSTYLE_DASH;
    Stop.LineWidth = 2;
    Stop.PrimaryColor = COLOR_CYAN;
    Stop.SecondaryColor = COLOR_RED;
    Stop.SecondaryColorUsed = 1;

    ATRMultiplier.Name = "ATR Multiplier";
    ATRMultiplier.SetFloat(2);
    ATRMultiplier.SetFloatLimits(0.000001f,(float)MAX_STUDY_LENGTH);
    
    ATRPeriod.Name = "ATR Period";
    ATRPeriod.SetInt(3);
    ATRPeriod.SetIntLimits(1,MAX_STUDY_LENGTH);
    
    MedianPeriod.Name = "Median Period";
    MedianPeriod.SetInt(3);
    MedianPeriod.SetIntLimits(1,MAX_STUDY_LENGTH);

    return;
  }
  
  // Do data processing
  sc.MovingMedian(sc.HLAvg, Median, sc.Index, MedianPeriod.GetInt());
  sc.ATR(sc.BaseDataIn, TrueRange, AvgTrueRange, sc.Index, ATRPeriod.GetInt(), MOVAVGTYPE_HULL);

  if (sc.Index == 0)
  {
    sc.ValueFormat = sc.BaseGraphValueFormat;

    Stop[sc.Index] = sc.Close[sc.Index];
    Trend[sc.Index] = 1;
    return;
  }

  if (sc.FormattedEvaluate(sc.Close[sc.Index], sc.ValueFormat, GREATER_OPERATOR, Stop[sc.Index-1], sc.ValueFormat))
  {
    Trend[sc.Index] = 1;
    float NewStop = Median[sc.Index] - ATRMultiplier.GetFloat()*AvgTrueRange[sc.Index-1];
    if (Trend[sc.Index-1] < 0)
    {
      Stop[sc.Index] = NewStop;
    }
    else
    {
      Stop[sc.Index] = max(NewStop, Stop[sc.Index-1]);
    }
  }
  else if (sc.FormattedEvaluate(sc.Close[sc.Index], sc.ValueFormat, LESS_OPERATOR, Stop[sc.Index-1], sc.ValueFormat))
  {
    Trend[sc.Index] = -1;
    float NewStop = Median[sc.Index] + ATRMultiplier.GetFloat()*AvgTrueRange[sc.Index-1];
    if (Trend[sc.Index-1] > 0)
    {
      Stop[sc.Index] = NewStop;
    }
    else
    {
      Stop[sc.Index] = min(NewStop, Stop[sc.Index-1]);
    }
  }
  else
  {
    Trend[sc.Index] = Trend[sc.Index-1];
    Stop[sc.Index] = Stop[sc.Index-1];
  }

  Stop.DataColor[sc.Index] = Trend[sc.Index] > 0 ? Stop.PrimaryColor : Stop.SecondaryColor;

}

Date Time Of Last Edit: 2015-02-11 13:20:59