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);
}
By the way, I am using Interactive Brokers as data source.
Cheers!