Is it possible to create an indicator without using data series functions?

Questions about MultiCharts .NET and user contributed studies.
r41866
Posts: 6
Joined: 03 Mar 2023

Is it possible to create an indicator without using data series functions?

Postby r41866 » 29 Mar 2023

In Multicharts.Net, creating an indicator seems very cumbersome. I checked a few built in indicators and I found all of them use data series functions. Do I have to create and use those functions? For example, for something as simple as drawing a line which is the average of bar high and bar low, can I do it without using functions? Thanks.

HellGhostEvocatorX
Posts: 80
Joined: 10 Feb 2022
Has thanked: 52 times
Been thanked: 11 times

Re: Is it possible to create an indicator without using data series functions?

Postby HellGhostEvocatorX » 30 Mar 2023

Well what does complicated mean? you could use normal multicharts, the scope of the code is generally smaller there, but so are the possibilities. In Multicharts.net the amount of code for the same programming is always larger, but it also offers a lot more possibilities and I personally just like the Csharp programming language.

Do you understand how series work?

Basically, as far as I know, all the necessary basic data is available in the form of series (generally these are price/time data). You can ultimately convert these into your own formats.
basically a series corresponds to a list like in csharp which is automatically filled with a new data point with each new candlestick.

A series is always counted back from the last bar: Bars.Close[0] contains the close price of the last bar, e.g. $10 on the chart. Bars.Close[1] the penultimate e.g. 12$ . When a new candlestick is added, the original Bars.Close[0] now becomes Bars.Close[1] and the previous Bars.Close[1] becomes Bars.Close[2] (12$)

For your example, such a code would be correspondingly short and easy to implement:

Code: Select all

Plotline = (Bars.High[0]+Bars.Low[0])/2
Then all you have to do is print them on the chart.

You see series simplify this, since the line is also calculated from the first bar when the drawing is created, as if a new bar is added every now and then.

Otherwise, take a look at viewtopic.php?t=48718 and https://www.tradingcode.net/, this will make it easier for you to get started. All beginnings are difficult. just try to create some indicators, your learning curve will increase steeply :)

Maybe you mean something else by "function" but Bars.Close[0] would not actually be a function itself but rather a call to the first element in the array (series). and you can "bars." at any time in protected override void CalcBar() without having to define a variable or something similar.

If you insert the following line under CalcBar(), you can also display the values ​​of Bars.Close in the Multicharts.net output window, which may improve your understanding of series:

Code: Select all

Output.WriteLine("BarsCloseValue{0},{1}", Bars.Close[0], Bars.FullSymbolData.Current);

HellGhostEvocatorX
Posts: 80
Joined: 10 Feb 2022
Has thanked: 52 times
Been thanked: 11 times

Re: Is it possible to create an indicator without using data series functions?

Postby HellGhostEvocatorX » 30 Mar 2023

Code: Select all

using System; using System.Drawing; using PowerLanguage.Function; namespace PowerLanguage.Indicator { [SameAsSymbol(true)] public class TestDurchschnitt : IndicatorObject { //private AverageFC m_averagefc1; // private VariableSeries<Double> m_avg; private IPlotObject Plot1; public TestDurchschnitt(object ctx) : base(ctx) { // length = 9; } //private ISeries<double> price { get; set; } //[Input] //public int length { get; set; } //[Input] //public int displace { get; set; } protected override void Create() { //m_averagefc1 = new AverageFC(this); //m_avg = new VariableSeries<Double>(this); Plot1 = AddPlot(new PlotAttributes("Avg", 0, Color.Yellow, Color.Empty, 0, 0, true)); } protected override void StartCalc() { //price = Bars.Close; //m_averagefc1.price = price; //m_averagefc1.length = length; Output.Clear(); } protected override void CalcBar() { Plot1.Set((Bars.High[0] + Bars.Low[0]) / 2); Output.WriteLine("Durchschnitt{0},{1}", ((Bars.High[0] + Bars.Low[0]) / 2), Bars.FullSymbolData.Current); //m_avg.Value = m_averagefc1[0]; //if (displace >= 0 || Bars.CurrentBar > Math.Abs(displace)) //{ // Plot1.Set(displace, m_avg.Value); // if (displace <= 0) // { // if (this.CrossesOver(price, m_avg)) // { // Alerts.Alert("Price crossing over average"); // } // else // { // if (this.CrossesUnder(price, m_avg)) // { // Alerts.Alert("Price crossing under average"); // } // } // } //} } } }
and here is your complete code example, I used the moving average 1line as a template ;)


Return to “MultiCharts .NET”