Is it a bug a MC.NET?

Questions about MultiCharts .NET and user contributed studies.
oneshotbin
Posts: 4
Joined: 11 Jan 2014

Is it a bug a MC.NET?

Postby oneshotbin » 11 Jan 2014

I encountered a strange case when I try to write a indicator and find lost part of the data when try to draw a curve with the data. I did some test to verify and find it's maybe a bug of MC.NET.

Hope can get answer from the developers of MC.NET or fans or MC.NET.

Here are the steps:

[A] I write a simple indicator to export the data and can export full data to a text file:

using System;
using System.IO;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator{
public class BINL_Export : IndicatorObject {
public BINL_Export(object _ctx):base(_ctx){}

//public ISeries<Double> price { get; set; }

private IPlotObject plot1;
protected override void Create() {
// create variable objects, function objects, plot objects etc.
plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));

using (TextWriter tw1 = File.CreateText("e:\\export.txt"))
{
tw1.WriteLine("DateTime Open High Low Close");
}


}
protected override void StartCalc() {
// price = Bars.Close;
}
protected override void CalcBar(){
using (TextWriter tr1 = File.AppendText("e:\\export.txt"))
{
tr1.WriteLine("{0:000} {1} {2} {3} {4} {5}", Bars.CurrentBar, Bars.TimeValue, Bars.OpenValue, Bars.HighValue, Bars.LowValue, Bars.CloseValue);
}
// indicator logic
plot1.Set(Bars.Close[0]);
}
}
}

It's simple and the output file export.txt is correct.

DateTime Open High Low Close
001 2013-3-27 18:30:00 31.48 32.02 31.17 32.01
002 2013-3-28 18:30:00 32.17 32.65 31.91 32.08
003 2013-4-1 18:30:00 32.13 32.2 31.07 31.15
004 2013-4-2 18:30:00 31.33 31.38 30.03 30.14
005 2013-4-3 18:30:00 30.24 30.39 28.76 29.05
006 2013-4-4 18:30:00 29.12 29.29 28.8 28.97
007 2013-4-5 18:30:00 28.64 28.92 28.07 28.88

008 2013-4-8 18:30:00 29.23 29.46 28.73 28.93
009 2013-4-9 18:30:00 29.13 29.57 28.88 28.88
010 2013-4-10 18:30:00 29.04 29.45 28.93 29.3
011 2013-4-11 18:30:00 29.38 29.86 28.85 29.77
012 2013-4-12 18:30:00 29.6 29.68 29.02 29.4
013 2013-4-15 18:30:00 28.99 29.19 27.9 28.01
014 2013-4-16 18:30:00 28.38 29.01 28.32 28.63
015 2013-4-17 18:30:00 28.29 28.37 27.7 28.08

I added the export function in MACD indicator of the system, find lost some data.

only list the changes I made base on standard MACD indicator.

...
using System.IO;

namespace PowerLanguage.Indicator
{
public class MACD : IndicatorObject
{
...

protected override void Create(){
...
File.Delete("e:\\pricelist_macd.txt");

using (TextWriter tw1 = File.CreateText("e:\\export_macd.txt"))
{
tw1.WriteLine("DateTime Open High Low Close");
}

}

protected override void StartCalc(){
...
}


protected override void CalcBar(){
...
using (TextWriter tr1 = File.AppendText("e:\\export_macd.txt"))
{

tr1.WriteLine("{0:000} {1} {2} {3} {4} {5}", Bars.CurrentBar, Bars.TimeValue, Bars.OpenValue, Bars.HighValue, Bars.LowValue, Bars.CloseValue);
}

}
}
}

You can find the output file export_macd.txt is not correct.

DateTime Open High Low Close
001 2013-3-27 18:30:00 31.48 32.02 31.17 32.01
001 2013-4-5 18:30:00 28.64 28.92 28.07 28.88
002 2013-4-8 18:30:00 29.23 29.46 28.73 28.93
003 2013-4-9 18:30:00 29.13 29.57 28.88 28.88
004 2013-4-10 18:30:00 29.04 29.45 28.93 29.3
005 2013-4-11 18:30:00 29.38 29.86 28.85 29.77
006 2013-4-12 18:30:00 29.6 29.68 29.02 29.4
007 2013-4-15 18:30:00 28.99 29.19 27.9 28.01
008 2013-4-16 18:30:00 28.38 29.01 28.32 28.63
009 2013-4-17 18:30:00 28.29 28.37 27.7 28.08
010 2013-4-18 18:30:00 28.15 28.24 27.73 28.01
011 2013-4-19 18:30:00 28.23 28.23 27.86 28.01
012 2013-4-22 18:30:00 28.12 28.61 27.6 28.41


compare with export_macd.txt and export.txt , there lost data below in MACD indicator.

002 2013-3-28 18:30:00 32.17 32.65 31.91 32.08
003 2013-4-1 18:30:00 32.13 32.2 31.07 31.15
004 2013-4-2 18:30:00 31.33 31.38 30.03 30.14
005 2013-4-3 18:30:00 30.24 30.39 28.76 29.05
006 2013-4-4 18:30:00 29.12 29.29 28.8 28.97



Why ?

Regards,
oneshotbin

oneshotbin
Posts: 4
Joined: 11 Jan 2014

Re: Is it a bug of MC.NET? <solved>

Postby oneshotbin » 12 Jan 2014

Just found the solution from this post.

http://www.tradingcode.net/multicharts- ... rice-data/

Open the code source file in the PowerLanguage Editor and then go to File —> Properties. In the Indicator Properties window (see below) select ‘User Specified’ and specify the value =1 can solve this problem.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Is it a bug a MC.NET?

Postby JoshM » 12 Jan 2014

Do you use multiple data series on that chart? Does the regular MACD lines plot correctly for those missing days?

In a recent thread here missing bar numbers are discussed; perhaps the same issue underlays both problems.

If you use multiple data series I'd start by checking the MaxBarsBack and Realtime-history matching options.


Return to “MultiCharts .NET”