Support Board
Date/Time: Mon, 23 Dec 2024 16:03:17 +0000
Post From: Line On Line by Code
[2015-10-02 03:52:39] |
KhaosTrader - Posts: 128 |
Hi, I managed to make a unique look on chart lines, by putting two moving averages on top of each other with different styles (see attached image). I wanted to do this with code, so I tried, but it didn't work. Please forgive me if the code is not the best, its my first attempt at coding this platform. Tell me what I should do to make the visual effect work.. Code below: SCSFExport scsf_SimpMovAvg(SCStudyInterfaceRef sc)
{ //sc.FreeDLL = 1; SCSubgraphRef Average_Outter = sc.Subgraph[0]; SCSubgraphRef Average_Inner = sc.Subgraph[0]; SCInputRef Length = sc.Input[0]; // Set configuration variables if (sc.SetDefaults) { // Set the configuration and defaults sc.GraphName = "SimpleX Moving Average"; sc.StudyDescription = "Example function for calculating a simple moving average."; // Set the region to draw the graph in. Region zero is the main // price graph region. sc.GraphRegion = 0; // Set the name of the first subgraph Average_Inner.Name = "Average"; // Set the color, style and line width for the subgraph Average_Outter.PrimaryColor = RGB(112,0,0); Average_Outter.DrawStyle = DRAWSTYLE_LINE; Average_Outter.LineStyle = LINESTYLE_SOLID; Average_Outter.LineWidth = 6; Average_Inner.PrimaryColor = RGB(255,255,255); Average_Inner.DrawStyle = DRAWSTYLE_LINE; Average_Inner.LineStyle = LINESTYLE_DASHDOT; Average_Inner.LineWidth = 1; // Set the Length input and default it to 30 Length.Name = "Length"; Length.SetInt(20); Length.SetIntLimits(1,MAX_STUDY_LENGTH); Length.SetDescription("The number of bars to average."); sc.AutoLoop = 1; sc.AlertOnlyOncePerBar = true; // 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 = 1; // Must return before doing any data processing if sc.SetDefaults is set return; } // Do data processing // Set the index of the first array element to begin drawing at sc.DataStartIndex = Length.GetInt() - 1; // Calculate a simple moving average from the base data sc.SimpleMovAvg(sc.Close,Average_Outter,Length.GetInt()); sc.SimpleMovAvg(sc.Close,Average_Inner,Length.GetInt()); //if (sc.CrossOver(Average_Inner,sc.Close)) //sc.SetAlert(1, "Moving average has crossed last price."); // Since we are using auto-looping we do not specify the Index parameter. } |
LineOnLine.png / V - Attached On 2015-10-02 03:49:34 UTC - Size: 64.51 KB - 275 views |