Login Page - Create Account

Support Board


Date/Time: Thu, 06 Mar 2025 16:11:47 +0000



Post ACSIL Source Code

View Count: 515

[2022-02-02 12:12:26]
User551752 - Posts: 25
Can I post ACSIL source code on this board for other to see ?
[2022-02-02 14:49:17]
Sierra Chart Engineering - Posts: 104368
Yes of course. This is perfectly fine. Very good to do that.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2022-02-02 16:58:14]
User551752 - Posts: 25
This is the ACSIL source code of WaveTrend . Enjoy !



#include "sierrachart.h"

SCDLLName("WaveTrend")

/*==========================================================================*/
SCSFExport scsf_MovingAverageExponential(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Subgraph_EMA = sc.Subgraph[0];
  SCSubgraphRef Subgraph_EMA2 = sc.Subgraph[1];
  SCSubgraphRef Subgraph_HLC = sc.Subgraph[2];
  SCSubgraphRef Subgraph_Abs = sc.Subgraph[3];
  SCSubgraphRef Subgraph_CCI = sc.Subgraph[4];
  SCSubgraphRef Subgraph_EMA3 = sc.Subgraph[5];
  SCSubgraphRef Subgraph_SMA = sc.Subgraph[6];
  SCSubgraphRef Subgraph_CenterLine = sc.Subgraph[7];
  SCSubgraphRef Subgraph_TopLine = sc.Subgraph[8];
  SCSubgraphRef Subgraph_TopLine2 = sc.Subgraph[9];
  SCSubgraphRef Subgraph_BottomLine = sc.Subgraph[10];
  SCSubgraphRef Subgraph_BottomLine2 = sc.Subgraph[11];
  
  SCSubgraphRef Subgraph_Buy = sc.Subgraph[12];
  SCSubgraphRef Subgraph_Sell = sc.Subgraph[13];
  
  SCInputRef Input_Data = sc.Input[0];
  SCInputRef Input_Length = sc.Input[1];
  SCInputRef Input_Length2 = sc.Input[2];
  SCInputRef Input_Length3 = sc.Input[3];
  
  SCInputRef Input_CenterLineValue = sc.Input[4];

  SCInputRef Input_TopLineValue = sc.Input[6];
  SCInputRef Input_TopLine2Value = sc.Input[7];
  SCInputRef Input_BottomLineValue = sc.Input[8];
  SCInputRef Input_BottomLine2Value = sc.Input[9];
  
  
  if (sc.SetDefaults)
  {
    
    sc.GraphName = "WaveTrend";
    
    sc.GraphRegion = 1;
    sc.ValueFormat = 3;
    sc.AutoLoop = 1;

    Subgraph_CenterLine.Name = "Center Line";
    Subgraph_CenterLine.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_CenterLine.PrimaryColor = RGB(128, 128, 128);
    Subgraph_CenterLine.LineWidth = 1;
    Subgraph_CenterLine.DrawZeros = true;
    
    Subgraph_TopLine.Name = "Top Line";
    Subgraph_TopLine.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_TopLine.PrimaryColor = RGB(255, 0, 0);
    Subgraph_TopLine.LineWidth = 1;
    Subgraph_TopLine.DrawZeros = true;
    
    
    Subgraph_TopLine2.Name = "Top Line 2";
    Subgraph_TopLine2.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_TopLine2.PrimaryColor = RGB(255, 127, 0);
    Subgraph_TopLine2.LineWidth = 1;
    Subgraph_TopLine2.DrawZeros = true;
    
    Subgraph_BottomLine.Name = "Bottom Line";
    Subgraph_BottomLine.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_BottomLine.PrimaryColor = RGB(0, 255, 0);
    Subgraph_BottomLine.LineWidth = 1;
    Subgraph_BottomLine.DrawZeros = true;
    
    Subgraph_BottomLine2.Name = "Bottom Line 2";
    Subgraph_BottomLine2.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_BottomLine2.PrimaryColor = RGB(255, 127, 0);
    Subgraph_BottomLine2.LineWidth = 1;
    Subgraph_BottomLine2.DrawZeros = true;
    
    Input_CenterLineValue.Name = "Center Line 1 Value";
    Input_CenterLineValue.SetFloat(0);
    
    Input_TopLineValue.Name = "Top Line 1 Value";
    Input_TopLineValue.SetFloat(60);

    Input_TopLine2Value.Name = "Top Line 2 Value";
    Input_TopLine2Value.SetFloat(53);
    
    Input_BottomLineValue.Name = "Top Line 1 Value";
    Input_BottomLineValue.SetFloat(-60);

    Input_BottomLine2Value.Name = "Top Line 2 Value";
    Input_BottomLine2Value.SetFloat(-53);
      
    Subgraph_EMA3.Name = "EMA3";
    Subgraph_EMA3.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_EMA3.PrimaryColor = RGB(0,255,0);
    Subgraph_EMA3.DrawZeros = true;
    
    Subgraph_SMA.Name = "SMA";
    Subgraph_SMA.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_SMA.PrimaryColor = RGB(0,0,255);
    Subgraph_SMA.DrawZeros = true;
    
    Input_Data.Name = "Input Data";
    Input_Data.SetInputDataIndex(SC_HLC);

    Input_Length.Name = "Channel Length";
    Input_Length.SetInt(9);
    Input_Length.SetIntLimits(1, MAX_STUDY_LENGTH);
    
    Input_Length2.Name = "Average Length";
    Input_Length2.SetInt(15);
    Input_Length2.SetIntLimits(1, MAX_STUDY_LENGTH);
    
    Input_Length3.Name = "SMA Smooth Length";
    Input_Length3.SetInt(3);
    Input_Length3.SetIntLimits(1, MAX_STUDY_LENGTH);
    
    
    Subgraph_Buy.Name = "Buy";
    Subgraph_Buy.PrimaryColor = RGB(255, 127, 0);  
    Subgraph_Buy.DrawStyle = DRAWSTYLE_ARROW_UP;
    Subgraph_Buy.LineWidth = 2;  //Width Of Arrow

    Subgraph_Sell.Name = "Sell";
    Subgraph_Sell.DrawStyle = DRAWSTYLE_ARROW_DOWN;
    Subgraph_Sell.PrimaryColor = RGB(255, 0, 0);  
    Subgraph_Sell.LineWidth = 2; //Width Of Arrow
  
    return;
  }
  
  Subgraph_CenterLine[sc.Index] = Input_CenterLineValue.GetFloat();
  
  Subgraph_TopLine[sc.Index] = Input_TopLineValue.GetFloat();
  Subgraph_TopLine2[sc.Index] = Input_TopLine2Value.GetFloat();
  
  Subgraph_BottomLine[sc.Index] = Input_BottomLineValue.GetFloat();
  Subgraph_BottomLine2[sc.Index] = Input_BottomLine2Value.GetFloat();
  
  Subgraph_HLC[sc.Index] = (sc.High[sc.Index] + sc.Low[sc.Index] + sc.Close[sc.Index])/3;
  sc.DataStartIndex = Input_Length.GetInt() - 1;
  sc.ExponentialMovAvg(sc.BaseDataIn[Input_Data.GetInputDataIndex()], Subgraph_EMA, Input_Length.GetInt());
    
  Subgraph_Abs[sc.Index] = fabs(Subgraph_HLC[sc.Index] - Subgraph_EMA[sc.Index]);
  sc.ExponentialMovAvg(Subgraph_Abs, Subgraph_EMA2, Input_Length.GetInt());
  Subgraph_CCI[sc.Index] = (Subgraph_HLC[sc.Index] - Subgraph_EMA[sc.Index]) / (Subgraph_EMA2[sc.Index] * 0.015);
  sc.ExponentialMovAvg(Subgraph_CCI, Subgraph_EMA3, Input_Length2.GetInt());
  sc.SimpleMovAvg(Subgraph_EMA3, Subgraph_SMA , Input_Length3.GetInt());
  
  
    if (sc.CrossOver( Subgraph_EMA3, Subgraph_SMA, sc.Index) == CROSS_FROM_BOTTOM && Subgraph_EMA3[sc.Index] < 0)
    
    {
      Subgraph_Buy[sc.Index] = Subgraph_SMA[sc.Index];
      Subgraph_Sell[sc.Index] = 0;
    }

    else if (sc.CrossOver(Subgraph_EMA3, Subgraph_SMA, sc.Index) == CROSS_FROM_TOP && Subgraph_EMA3[sc.Index] > 0)
    
    {
    Subgraph_Sell[sc.Index] = Subgraph_SMA[sc.Index];
    Subgraph_Buy[sc.Index] = 0;
    }
    else
    {
    Subgraph_Buy[sc.Index] = 0;
    Subgraph_Sell[sc.Index] = 0;
    }

}

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account