#include "sierrachart.h"
SCSFExport scsf_CopyOfBaseGraph(SCStudyInterfaceRef sc)
{
SCSubgraphRef Subgraph_Open = sc.Subgraph[0];
SCSubgraphRef Subgraph_High = sc.Subgraph[1];
SCSubgraphRef Subgraph_Low = sc.Subgraph[2];
SCSubgraphRef Subgraph_Last = sc.Subgraph[3];
SCSubgraphRef Subgraph_Volume = sc.Subgraph[4];
SCSubgraphRef Subgraph_OpenInterest = sc.Subgraph[5];
SCSubgraphRef Subgraph_OHLCAvg = sc.Subgraph[6];
SCSubgraphRef Subgraph_HLCAvg = sc.Subgraph[7];
SCSubgraphRef Subgraph_HLAvg = sc.Subgraph[8];
if (sc.SetDefaults)
{
sc.GraphName = "Copy of BaseGraph Example";
sc.StudyDescription = "This is an example of how to create a custom chart. This one is a copy of the BaseGraph.";
sc.IsCustomChart = 1;
sc.GraphRegion = 0;
sc.DrawZeros = 0;
sc.GraphDrawType = GDT_OHLCBAR;
sc.StandardChartHeader = 1;
Subgraph_Open.Name = "Open";
Subgraph_Open.DrawStyle = DRAWSTYLE_LINE;
Subgraph_High.Name = "High";
Subgraph_High.DrawStyle = DRAWSTYLE_LINE;
Subgraph_Low.Name = "Low";
Subgraph_Low.DrawStyle = DRAWSTYLE_LINE;
Subgraph_Last.Name = "Last";
Subgraph_Last.DrawStyle = DRAWSTYLE_LINE;
Subgraph_Volume.Name = "Volume";
Subgraph_Volume.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_OpenInterest.Name = "# of Trades / OI";
Subgraph_OpenInterest.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_OHLCAvg.Name = "OHLC Avg";
Subgraph_OHLCAvg.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_HLCAvg.Name = "HLC Avg";
Subgraph_HLCAvg.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_HLAvg.Name = "HL Avg";
Subgraph_HLAvg.DrawStyle = DRAWSTYLE_IGNORE;
return;
}
if (sc.UpdateStartIndex == 0)
{
sc.ResizeArrays(0);
}
for (int i = sc.UpdateStartIndex; i < sc.ArraySize; i++)
{
if (sc.OutArraySize - 1 < i)
sc.AddElements(1);
sc.DateTimeOut[i] = sc.BaseDateTimeIn[i];
for (int SubGraph = 0; SubGraph <=8; SubGraph++)
{
sc.Subgraph[SubGraph][i] = sc.BaseDataIn[SubGraph][i];
}
}
}
SCSFExport scsf_ReverseOrderCopyOfBaseGraph(SCStudyInterfaceRef sc)
{
SCSubgraphRef Subgraph_Open = sc.Subgraph[0];
SCSubgraphRef Subgraph_High = sc.Subgraph[1];
SCSubgraphRef Subgraph_Low = sc.Subgraph[2];
SCSubgraphRef Subgraph_Last = sc.Subgraph[3];
SCSubgraphRef Subgraph_Volume = sc.Subgraph[4];
SCSubgraphRef Subgraph_OpenInterest = sc.Subgraph[5];
SCSubgraphRef Subgraph_OHLCAvg = sc.Subgraph[6];
SCSubgraphRef Subgraph_HLCAvg = sc.Subgraph[7];
SCSubgraphRef Subgraph_HLAvg = sc.Subgraph[8];
SCSubgraphRef Subgraph_BidVol = sc.Subgraph[9];
SCSubgraphRef Subgraph_AskVol = sc.Subgraph[10];
SCInputRef Input_InNumberOfBarsToReverse = sc.Input[1];
if (sc.SetDefaults)
{
sc.GraphName = "Reverse Copy of Base Graph";
sc.AutoLoop = 0;
sc.IsCustomChart = 1;
sc.GraphRegion = 0;
sc.DrawZeros = 0;
sc.GraphDrawType = GDT_OHLCBAR;
sc.StandardChartHeader = 1;
sc.GraphUsesChartColors = 1;
Input_InNumberOfBarsToReverse.Name = "Number Of Bars To Reverse";
Input_InNumberOfBarsToReverse.SetInt(1000);
Input_InNumberOfBarsToReverse.SetIntLimits(10, 2000);
return;
}
int &PriorBaseGraphArraySize = sc.GetPersistentInt(1);
if (sc.IsFullRecalculation && sc.UpdateStartIndex==0)
{
sc.ResizeArrays(0);
for (int SubgraphIndex = 0; SubgraphIndex <= NUM_BASE_GRAPH_ARRAYS; ++SubgraphIndex)
{
sc.Subgraph[SubgraphIndex].Name = sc.GetStudySubgraphName(0, SubgraphIndex);
}
PriorBaseGraphArraySize = 0;
}
int RequiredBarElements = min(sc.ArraySize, Input_InNumberOfBarsToReverse.GetInt());
if (sc.OutArraySize < RequiredBarElements)
sc.ResizeArrays(RequiredBarElements);
for (int InputDataIndex = sc.ArraySize - 1, OutputIndex = 0; InputDataIndex >= 0; InputDataIndex--, OutputIndex++)
{
sc.DateTimeOut[OutputIndex] = sc.BaseDateTimeIn[InputDataIndex];
for (int SubGraph = 0; SubGraph <= NUM_BASE_GRAPH_ARRAYS; SubGraph++)
{
sc.Subgraph[SubGraph][OutputIndex] = sc.BaseDataIn[SubGraph][InputDataIndex];
}
if (PriorBaseGraphArraySize == sc.ArraySize)
break;
}
PriorBaseGraphArraySize = sc.ArraySize;
}