Custom index building and charting - help needed

Questions about MultiCharts .NET and user contributed studies.
macieyo
Posts: 2
Joined: 02 Jul 2012

Custom index building and charting - help needed

Postby macieyo » 20 Apr 2018

Hi Multicharts Support and Community,

I would like to code a custom index build from at least two symbols (Forex pairs or Stocks) and be able to display it as a candlestick chart.

It is possible to add the requested symbols to the chart or use the CustomInstrument class but it is difficult to construct accurate OHLC values for the custom index.

Is there a way to aggregate, for example, 1 second bars into 1 minute (or 1 minute into 1 day)?

Pseudo code would look like below:

Code: Select all

protected override void StartCalc()

{

m_USDJPY = new PowerLanguage.CustomInstrument(Bars, "USD.JPY", new Resolution { Size = 1, Type = EResolution.Second }, true);

m_USDCHF = new PowerLanguage.CustomInstrument(Bars, "USD.CHF", new Resolution { Size = 1, Type = EResolution.Second }, true);

}

protected override void CalcBar()
{

plotOpen1minute.Set((m_USDJPY.CloseValue/m_USDCHF.CloseValue).First, Color.Green);

plotHigh1minute.Set((m_USDJPY.CloseValue/m_USDCHF.CloseValue).Max, Color.Green);

plotLow1minute.Set((m_USDJPY.CloseValue/m_USDCHF.CloseValue).Min, Color.Green);

plotClose1minute.Set((m_USDJPY.CloseValue/m_USDCHF.CloseValue).Last, Color.Green);
}
I would appreciate any hints or sample code.

By the way, I am using Interactive Brokers as data source.

Cheers!

User avatar
Anna MultiCharts
Posts: 415
Joined: 14 Jul 2017
Has thanked: 30 times
Been thanked: 104 times

Re: Custom index building and charting - help needed

Postby Anna MultiCharts » 24 Apr 2018

Hello, macieyo!

Your code looks fine and operable. Unfortunately we cannot think of a better way for achieving your goal.


Return to “MultiCharts .NET”