I have been playing with data retrieving using CustomInstrument, and noticed that it is working fine for retrieving instruments except the resolution the same as the primary data's.. I know I could do it with DataLoader, but the later is not bond with primary bars and would make plotting more difficult. It would be nicer if Multicharts would allow requesting new instruments with the same resolution as the primary data's, facilitating plotting.
I also know I could bypass the problem by loading data2 to chart, and using BarsOfData(2) , but if I were to manually load 10-20 instruments to chart every time, that would be a painful process.
I am not sure if not allowing the resolution same as primary series is by design or a bug.
The following is the sample code, with primary chart data resolution of 1 day. All resolutions works fine except the resolution the same as primary data's.
Code: Select all
using System;
using System.Drawing;
using PowerLanguage.Function;
using System.Collections.Generic;
namespace PowerLanguage.Indicator
{
//[SameAsSymbol(true)]
public class _aTest : IndicatorObject
{
CustomInstrument inst2;
public _aTest(object ctx) : base(ctx){
}
protected override void Create(){
}
protected override void StartCalc(){
inst2 = new PowerLanguage.CustomInstrument(
Bars,
"TS",
SymbolStorage.GetSymbols("TS", "QQQ")[0],
new Resolution { Size = 1, Type = EResolution.Minute },
//new Resolution { Size = 1, Type = EResolution.Hour },
//new Resolution { Size = 1, Type = EResolution.Day },
//new Resolution { Size = Bars.Info.Resolution.Size, Type = Bars.Info.Resolution.Type },
true,
RequestQuoteField.Trade
);
}
protected override void CalcBar(){
Output.WriteLine("inst2.CloseValue={0}", inst2.CloseValue);
}
protected override void Dispose( bool _b)
{
inst2.Dispose();
}
}
}