I want to implement an indicator that loads a custom ASCII symbol for further calculations. It seems that the CustomInstrument inherits the session of the main chart symbol. But I'd like to apply another session to my CustomInstrument (a different session as it used by the main chart). The session set in the QuoteManager (in this case for "OVX.XO.M1") seems not being considered.
Do have an idea how to achieve this? Here is the code:
Code: Select all
public class Test_CustomInstrument : IndicatorObject
{
public Test_CustomInstrument(object _ctx):base(_ctx){}
private IPlotObject plot1;
CustomInstrument m_MyCustomInstrument;
protected override void Create()
{
plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));
}
protected override void StartCalc()
{
MTPA_MCSymbolInfo2[] symb = SymbolStorage.GetSymbols("ASCII Mapping", "OVX.XO.M1", ESymbolCategory.Index);
if (symb.Length > 0)
{
MTPA_MCSymbolInfo2 mySymbol = symb[0];
Output.WriteLine("symbol name = " + mySymbol.SymbolName);
Output.WriteLine("main symbol session = " + Bars.Request.SessionName);
m_MyCustomInstrument = new PowerLanguage.CustomInstrument(Bars, "ASCII Mapping", mySymbol, Bars.Request.Resolution, false);
Output.WriteLine("custom symbol session = " + m_MyCustomInstrument.Request.SessionName);
}
}
protected override void CalcBar()
{
plot1.Set(m_MyCustomInstrument.CloseValue);
}
protected override void Dispose( bool _b)
{
m_MyCustomInstrument.Dispose();
}
}
Regards