Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bar Score Over N Bars

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • aventeren
    replied
    Originally posted by koganam View Post
    Any object that is public in a namespace can be accessed by any other object that uses the namespace.
    Thanks; so I'll assume that your very precise answer means that yes, an indicator or a strategy can access a publicly exposed DataSeries.


    Thanks!

    Leave a comment:


  • koganam
    replied
    Originally posted by aventeren View Post
    Okay, thanks Koganam; I'll take a look at this either later tonight (after NBA Finals Game 7) or in the AM.


    So basically I'm thinking that I'll need to create a new DataSeries in the "source" indicator (which we're calling IndicatorSource here), and then .Set the new DataSeries values to populate the new DataSeries values. Then under Properties expose a new public DataSeries instead of the current double that I am trying to expose now. So that's where my mind is currently at while sitting in front of the TV without having my computer in front of me.


    I guess one basic question I have: it is possible to grab a publicly exposed indicator value (ie, the new DataSeries above) and then use that in another indicator, right? Or can you only pull a publicly exposed DataSeries into a strategy (ie, not an indicator).


    Thanks for your help, Koganam. You're an all star!


    Aventeren
    Any object that is public in a namespace can be accessed by any other object that uses the namespace.

    Leave a comment:


  • aventeren
    replied
    Originally posted by koganam View Post
    Not quite. If you expose anything other than a Plot, you need to run Update() in the getter.

    Here is a reference sample that might get you going much faster. http://www.ninjatrader.com/support/f...ead.php?t=4991
    Okay, thanks Koganam; I'll take a look at this either later tonight (after NBA Finals Game 7) or in the AM.


    So basically I'm thinking that I'll need to create a new DataSeries in the "source" indicator (which we're calling IndicatorSource here), and then .Set the new DataSeries values to populate the new DataSeries values. Then under Properties expose a new public DataSeries instead of the current double that I am trying to expose now. So that's where my mind is currently at while sitting in front of the TV without having my computer in front of me.


    I guess one basic question I have: it is possible to grab a publicly exposed indicator value (ie, the new DataSeries above) and then use that in another indicator, right? Or can you only pull a publicly exposed DataSeries into a strategy (ie, not an indicator).


    Thanks for your help, Koganam. You're an all star!


    Aventeren

    Leave a comment:


  • koganam
    replied
    Originally posted by aventeren View Post
    Thanks, Koganam;

    The values that I want to expose from the IndicatorSource are double values, which in the IndicatorSource indicator were:

    //Variables
    private double seriessum = 0; // Variable to store the series sum over N bars

    //OnBarUpdate
    series.Set(score); //Where "score" is a type int value that represents the current bar's score and "series" is a DataSeries.
    seriessum = SUM(series, serieslength)[0]; // This is where the seriessum variable received its values, which are of type double--AND MOST IMPORTANTLY, THESE ARE THE VALUES THAT I AM LOOKING TO PLOT. seriessum is simply a score count of n bars. Again, these are the values that I am looking to plot.

    //Properties
    //This is where I publicly exposed the seriessum values as a type double called Seriessum
    [Browsable(false)]
    [XmlIgnore()]
    public double Seriessum
    {
    get { return seriessum; }
    }

    Would you concur that my logic (above) is correct?

    Thanks, Koganam--I REALLY appreciate your help.

    Aventeren
    Not quite. If you expose anything other than a Plot, you need to run Update() in the getter.

    Here is a reference sample that might get you going much faster. http://www.ninjatrader.com/support/f...ead.php?t=4991

    Leave a comment:


  • aventeren
    replied
    Originally posted by koganam View Post
    We need to be sure of what you want to do.

    Are you sure that you want to expose a double, rather than a DataSeries. The code that you have posted exposes a double.
    Thanks, Koganam;

    The values that I want to expose from the IndicatorSource are double values, which in the IndicatorSource indicator were:

    //Variables
    private double seriessum = 0; // Variable to store the series sum over N bars

    //OnBarUpdate
    series.Set(score); //Where "score" is a type int value that represents the current bar's score and "series" is a DataSeries.
    seriessum = SUM(series, serieslength)[0]; // This is where the seriessum variable received its values, which are of type double--AND MOST IMPORTANTLY, THESE ARE THE VALUES THAT I AM LOOKING TO PLOT. seriessum is simply a score count of n bars. Again, these are the values that I am looking to plot.

    //Properties
    //This is where I publicly exposed the seriessum values as a type double called Seriessum
    [Browsable(false)]
    [XmlIgnore()]
    public double Seriessum
    {
    get { return seriessum; }
    }

    Would you concur that my logic (above) is correct?

    Thanks, Koganam--I REALLY appreciate your help.

    Aventeren
    Last edited by aventeren; 06-20-2013, 05:40 PM.

    Leave a comment:


  • aventeren
    replied
    2nd: Can someone please confirm that the proper way to make an indicator's values available within a new indicator, that the following line of code is the correct way to initialize and add an indicator to a new indicator:

    //Iniitalize()
    Add(IndicatorSource()); // Adds the IndicatorSource

    The above assumes that the name of the indicator that I am trying to call is named "IndicatorSource"--and it also assumes that the IndicatorSource indicator does not have any overloads, which it doesn't.

    I am getting the following error when I try and add IndicatorSource into the indicator:

    CS1502: The best overload method match for 'Ninjatrader.Indicator.IndicatorBase.Add(NinjaTrad er.Gui.Chart.Line)' has some invalid arguments.

    CS1501: Argument '1': cannot convert from 'NinjaTrader.Indicator.IndicatorSource' to 'NinjaTrader.Gui.Chart.Line'

    Can someone please help me determine what might be causing this error and what the proper way to add an existing indicator to a new indicator so that the existing indicator's values can be plotted?

    Thanks,

    Aventeren

    Leave a comment:


  • koganam
    replied
    Originally posted by aventeren View Post
    So I think I need to work on this step wise.

    1st: Can someone please confirm that if I place this code:

    [Browsable(false)]
    [XmlIgnore()]
    public double Seriessum
    {
    get { return seriessum; }
    }

    In the Properties section of the IndicatorSource code, that other indicators will be able to access the IndicatorSource's Seriessum values?

    Before I get into adding an indicator to another indicator, I first want to make sure that I have properly revealed the Seriessum values for use.

    Thanks,

    Aventeren
    We need to be sure of what you want to do.

    Are you sure that you want to expose a double, rather than a DataSeries. The code that you have posted exposes a double.

    Leave a comment:


  • aventeren
    replied
    So I think I need to work on this step wise.

    1st: Can someone please confirm that if I place this code:

    [Browsable(false)]
    [XmlIgnore()]
    public double Seriessum
    {
    get { return seriessum; }
    }

    In the Properties section of the IndicatorSource code, that other indicators will be able to access the IndicatorSource's Seriessum values?

    Before I get into adding an indicator to another indicator, I first want to make sure that I have properly revealed the Seriessum values for use.

    Thanks,

    Aventeren

    Leave a comment:


  • aventeren
    replied
    Originally posted by koganam View Post
    You always plot the indicator by simply assigning values to the Plot/Values[0]/Value. In this case, not knowing the indicator or plot names, here is the generic code that you will use in the calling indicator.

    Code:
     
    Values[0].Set(CalledIndicator([] paramaeters).PlotIdentifierInCalledIndicator[0]);
    Instead of "Values[0]", you can use "Plots[0]", or just "Value".
    Thanks for your help, Koganam.

    Let's assume that the indicator that I am going to call is called IndicatorSource. Therefore, to add IndicatorSource to the new indicator, under Initialize I would do:

    //Iniitalize()
    Add(IndicatorSource()); // Adds the IndicatorSource

    But I have a question on this, as the IndicatorSource does not have any parameters that need to be spelled out (ie, like a EMA length or moving average type, etc.). So to add the IndicatorSource to the new indicator, do I just use:

    Add(IndicatorName());

    or do I have to:

    Add(IndicatorName(something)); // Where "something" is something that you can help me with?

    Also, given in the IndicatorSource Properties that I have publicly revealed the seriessum by:

    [Browsable(false)]
    [XmlIgnore()]
    public double Seriessum
    {
    get { return seriessum; }
    }

    That means that I now want to call the Seriessum values from the IndicatorSource...and then plot those in the new indicator.

    So from what I understand, I had to add a new plot to the new indicator (also under Initialize()):

    //Initialize()
    Add(new Plot(Color.Green, "score")); // From what I understand, the Values[0] are assigned to this plot.

    But this is where I run into a block, as I don't know how to place the Seriessum values from the IndicatorSource into the new "score" plot.

    Would I use something like:

    Value.Set(IndicatorSource.Seriessum[0]);

    ???

    Leave a comment:


  • koganam
    replied
    Originally posted by aventeren View Post
    Okay, I now have a Bar Score Over N Bars. Now I want to plot these values in a separate panel. Can someone help me figure this one out?

    I revealed the seriessum values in Properties by:

    [Browsable(false)]
    [XmlIgnore()]
    public double Seriessum
    {
    get { return seriessum; }
    }

    So I should be able to reference this indicator and grab these values. From my understanding, I would do that in the new indicator by:

    //Initialize()
    Add(IndicatorName(parameter1, parameter2, etc)); // Adds the IndicatorName to the new indicator so that I can grab the public values.

    // OnBarUpdate()
    Add(new Plot(Color.Green, "seriessum"); // From what I understand, this defines the plot for Values[0]

    Okay, so I think the above is right. Next, how to I actually plot the scores in this indicator?

    Thanks! I REALLY appreciate your help.

    Aventeren
    You always plot the indicator by simply assigning values to the Plot/Values[0]/Value. In this case, not knowing the indicator or plot names, here is the generic code that you will use in the calling indicator.

    Code:
     
    Values[0].Set(CalledIndicator([] parameters).PlotIdentifierInCalledIndicator[0]);
    Instead of "Values[0]", you can use "Plots[0]", or just "Value".
    Last edited by koganam; 06-20-2013, 04:21 PM.

    Leave a comment:


  • aventeren
    replied
    Next Question: How Do I Plot the Score?

    Okay, I now have a Bar Score Over N Bars. Now I want to plot these values in a separate panel. Can someone help me figure this one out?

    I revealed the seriessum values in Properties by:

    [Browsable(false)]
    [XmlIgnore()]
    public double Seriessum
    {
    get { return seriessum; }
    }

    So I should be able to reference this indicator and grab these values. From my understanding, I would do that in the new indicator by:

    //Initialize()
    Add(IndicatorName(parameter1, parameter2, etc)); // Adds the IndicatorName to the new indicator so that I can grab the public values.

    // OnBarUpdate()
    Add(new Plot(Color.Green, "seriessum"); // From what I understand, this defines the plot for Values[0]

    Okay, so I think the above is right. Next, how to I actually plot the scores in this indicator?

    Thanks! I REALLY appreciate your help.

    Aventeren

    Leave a comment:


  • aventeren
    replied
    Originally posted by aventeren View Post
    So I found this: http://www.ninjatrader.com/support/f...ad.php?t=55693.

    This may be the way...

    I'm going to try this and report back.
    So I was successful on the DataSeries route. THANKS!

    I did this by:

    //Variables
    private DataSeries series;
    private int sumlength = 10; // Defines how many bars I want in my sum (10 in this case)
    private double seriessum; // This is the variable that will hold the sum IT HAS TO BE TYPE DOUBLE BC IT WILL BE HOLDING A DATASERIES!!!

    //Initialize()
    series = new DataSeries(this); // Need to initialize the DataSeries

    // OnBarUpDate()
    series.Set(barscore); // Use .Set(variable) to populate the DataSeries (barscore is the score value assigned to each bar)
    seriessum = SUM(series, sumlength)[0]; // This is how you sum the score over sumlength bars (10 in this case) IT IS IMPORTANT TO ADD ON THE [0] AFTER THE SUM()...So Don't forget!!!!

    Okay, that was it.

    Thanks to everyone for their help. Hopefully this will help others.

    Leave a comment:


  • aventeren
    replied
    Originally posted by aventeren View Post
    Okay, so I've correctly implemented the DataSeries, and I am able to correct assign the bar score to the DataSeries, and I have confirmed that the DataSeries is displaying the correct bar score for the [0] and [1] bars.

    Now, how can I sum N bar scores using the values stored in the DataSeries?

    Could I use like a For loop or something?

    Hmmmmm.....
    So I found this: http://www.ninjatrader.com/support/f...ad.php?t=55693.

    This may be the way...

    I'm going to try this and report back.

    Leave a comment:


  • aventeren
    replied
    One Small Step...

    Okay, so I've correctly implemented the DataSeries, and I am able to correct assign the bar score to the DataSeries, and I have confirmed that the DataSeries is displaying the correct bar score for the [0] and [1] bars.

    Now, how can I sum N bar scores using the values stored in the DataSeries?

    Could I use like a For loop or something?

    Hmmmmm.....

    Leave a comment:


  • aventeren
    replied
    Originally posted by NinjaTrader_PatrickH View Post
    Hello Aventeren,

    Correct, on each OnBarUpdate() the Set() method will set the current value based on what is detailed in the Set() method, in this case barvalue.
    Okay, so let's assume that I do this. Now I have a DataSeries's value for each bar--and I should be able to reference these values using the [0], [1], [2], ..., [100] BarsAgo framework.

    Now, how would I sum the previous N DataSeries values to create the running score--and how would I do that in such a manner as I could change N from 5 to 50 to 100 and get the correct score?

    Thanks!

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by CarlTrading, 03-31-2026, 09:41 PM
1 response
152 views
1 like
Last Post NinjaTrader_ChelseaB  
Started by CarlTrading, 04-01-2026, 02:41 AM
0 responses
89 views
1 like
Last Post CarlTrading  
Started by CaptainJack, 03-31-2026, 11:44 PM
0 responses
131 views
2 likes
Last Post CaptainJack  
Started by CarlTrading, 03-30-2026, 11:51 AM
0 responses
127 views
1 like
Last Post CarlTrading  
Started by CarlTrading, 03-30-2026, 11:48 AM
0 responses
107 views
0 likes
Last Post CarlTrading  
Working...
X