Profile Picture

Data put into a Series on a symbol is displayed different than another

Posted By Siasb 10 Years Ago

Data put into a Series on a symbol is displayed different than another...

Message
Posted Friday February 23 2007
Not sure what am I missing? As part of a system, I have a series that gets the values for S&P, and tries to display them in an indicator window. If the data is put into the spxSymbol space, It shows up fine (commented code). If it is put into another symbol, the displayed result in the indicator pane is not correct!

...
     public  Symbol spxSymbol = new Symbol("^GSPC"); // S&P Index
     public  Symbol xauSymbol = new Symbol("^XAU"); //  XAU Index
     private DataSeries SPX  = new DataSeries();

...

     Series["SPX"].CreateSeries();
     Series["SPX"].ChartPaneName = "SPX";
     Series["SPX"].SeriesColor = Color.DarkGreen;
     Series["SPX"].AddToCharts();
...
  
     SPX.Values.Add(spxBar.Close);

     Series["SPX"][xauSymbol].Add(BarUtils.LastValueOf(SPX));
//  Series["SPX"][spxSymbol].Add(BarUtils.LastValueOf(SPX));

Posted Friday February 23 2007
What is the displayed result?  What are you trying to accomplish exactly?  Are you trying to plot the close value of one symbol onto another's chart (in an indicator pane)?

Siasb (2/23/2007)
Not sure what am I missing? As part of a system, I have a series that gets the values for S&P, and tries to display them in an indicator window. If the data is put into the spxSymbol space, It shows up fine (commented code). If it is put into another symbol, the displayed result in the indicator pane is not correct!

...
     public  Symbol spxSymbol = new Symbol("^GSPC"); // S&P Index
     public  Symbol xauSymbol = new Symbol("^XAU"); //  XAU Index
     private DataSeries SPX  = new DataSeries();

...

     Series["SPX"].CreateSeries();
     Series["SPX"].ChartPaneName = "SPX";
     Series["SPX"].SeriesColor = Color.DarkGreen;
     Series["SPX"].AddToCharts();
...
  
     SPX.Values.Add(spxBar.Close);

     Series["SPX"][xauSymbol].Add(BarUtils.LastValueOf(SPX));
//  Series["SPX"][spxSymbol].Add(BarUtils.LastValueOf(SPX));

Posted Friday February 23 2007

Are you trying to plot the close value of one symbol onto another's chart (in an indicator pane)?

Yes exactly. It seems when it gets plotted in the chart with same symbol (commented code), it's fine; But in another chart, values displayed are not correct. I have reduced the system to show this issue in the following code. I should note that other indicators and calculated series work just fine when put in (in this case) xau symbol space.

using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.Collections.ObjectModel;

using RightEdge.Common;
using RightEdge.Indicators;

public class SystemMain : SystemBase
{
 public Symbol spxSymbol = new Symbol("^GSPC"); // S&P Index
 public Symbol xauSymbol = new Symbol("^XAU");  // XAU Index
 private DataSeries SPX  = new DataSeries();

 public override void Startup()
 {
  if (!SystemData.Symbols.Contains(spxSymbol))
  {
   throw new RightEdgeError("Symbols for system must include " + spxSymbol + " and " + xauSymbol + ".");
  }
  else if (SystemData.Symbols.Count < 2)
  {
   throw new RightEdgeError("Must select the symbols: " + spxSymbol + " and " + xauSymbol + " to run the system against.");
  }

  Series["SPX"].CreateSeries();
  Series["SPX"].ChartPaneName = "SPX";
  Series["SPX"].SeriesColor = Color.DarkGreen;
  Series["SPX"].AddToCharts();
 }

 public override void NewBar()
 {
  // Process the SPX
  IList<BarData> spxBars = Bars[spxSymbol];
  BarData spxBar = spxBars[spxBars.Count - 1];
  if (!spxBar.EmptyBar) {
     NewSpxBar(spxBar);
  }
 }
 private void NewSpxBar(BarData spxBar)
 {

    SPX.Values.Add(spxBar.Close);

//  string message = BarUtils.LastValueOf(SPX).ToString();
//  SystemData.Output.Add(OutputSeverityLevel.Informational, message);

    Series["SPX"][xauSymbol].Add(BarUtils.LastValueOf(SPX));
//  Series["SPX"][spxSymbol].Add(BarUtils.LastValueOf(SPX));

 }

 private void NewXauBar(BarData xauBar)
 {
 }

 public override void NewSymbolBar(Symbol symbol, BarData bar)
 {
 }

 public override void Shutdown() {
 }

}

public class DataSeries : ISeries
{
 public List<double> Values = new List<double>();

 public double this[int index] {
  get { return Values[index]; }
 }

 public int Count {
  get { return Values.Count; }
 }

 ReadOnlyCollection<double> ISeries.Values {
  get { return new ReadOnlyCollection<double>(Values); }
 }

 public bool OldValuesChange {
  get { return false; }
 }
}

Posted Friday February 23 2007
I think I see what you're missing.  I reduced the sample a bit more and tuned it to my environment.  I think it should illustrate what you may be missing though.  I want AAPL on all of my charts.  The SeriesManager is there to make sure that when you create a series it's added to all symbols.  In this instance, we're special casing AAPL and only adding to the series for AAPL.  To get around this, you must loop manually over all symbols as shown below and and the AAPL close to the series for each symbol and it will then display in all charts.

public override void NewSymbolBar(Symbol symbol, BarData bar)

{

    if (symbol.Name == "AAPL")

    {

        foreach(Symbol mySymbol in SystemData.Symbols)

        {

            Series["Series1"][mySymbol].Add(bar.Close);

        }

    }

    // This line of code runs the actions you have set up in in the Project Form

    Actions.RunActions(symbol);

}

Posted Friday February 23 2007
Thanks Bill,


Yes, this would work if we wanted to put the series on all the charts. However, here I was trying to specifically put other series and this into one chart rather than all. The code is only part of my system, where I loop over all symbols as I need more specific control on the subset of symbols. But what is boggling me here is more specifically: Why is the data that is being put into the series (confirmed by the commented outputing code to console). Shows up wrong when displayed in the indicator pane. Not that it does not show up, but rather that it shows up wrong! If we put it in the same chart as the actual symbol is, it seems to be fine.


Posted Friday February 23 2007
I see what you mean now, but I had to re-enable the "Warn about bar data gaps when running system" to realize that there were gaps between the two symbols I was running against.  When I ran against two symbols where there were no gaps between the two, the output was as you would expect.

I attached my screen shot showing the AAPL chart with a closing price of 89.51 and the ALL chart with the AAPL closing prices plotted along the bottom.  In this case, the prices match up because there are no gaps.  I think this is what you're asking for, correct?

Anyway, NewSymbolBar() will never get called in the case of an "empty" bar.  However, NewBar() does get called regardless of the bar is empty.  You can override NewBar() and see if that helps your cause.  Make sure to call the base implementation.

Siasb (2/23/2007)
Thanks Bill,

Yes, this would work if we wanted to put the series on all the charts. However, here I was trying to specifically put other series and this into one chart rather than all. The code is only part of my system, where I loop over all symbols as I need more specific control on the subset of symbols. But what is boggling me here is more specifically: Why is the data that is being put into the series (confirmed by the commented outputing code to console). Shows up wrong when displayed in the indicator pane. Not that it does not show up, but rather that it shows up wrong! If we put it in the same chart as the actual symbol is, it seems to be fine.



Attachments
aaplall.png (366 views, 45.00 KB)
Posted Friday February 23 2007
Bill,

I have the "Warn about bar data gaps when running system" on, and there does not seems to be any gaps between the data for XAU and SPX, or it does not warn about it. I have seen it warn about others, and my main system does have provisions for handling those in calculation actually. But It does not seem to be the issue here (not 100% sure). I uncommented the code (in the previous post) and appended the close to both charts. You can see the discrepancy between the two. If there are gap problems, I presume it would show up in both?


Posted Friday February 23 2007
Is this what you're expecting?

Posted Friday February 23 2007
Yes.
Posted Friday February 23 2007
OK, interesting.  I finally bit the bullet and took your code verbatim and ran.  Basically, it worked without modification, however, there have been a number of fixes over the next few days.  Maybe I could send an interim build to see if this has been fixed for you?


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems