Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Setting variables for supplementary bar

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

    Setting variables for supplementary bar

    Hi,
    I am having problem setting variables for my supplementary bar. Let me give an easy example below to show what I mean:

    #region Variables
    private DataSeries vol5m;
    private DataSeries vol10m;
    #endregion


    protected override void Initialize()
    {
    vol5m= new DataSeries(this);
    vol10m= new DataSeries(this);

    Add(PeriodType.Minute, 10);

    CalculateOnBarClose = true;
    }


    protected override void OnBarUpdate()
    {

    if (BarsInProgress == 0)
    {
    vol5m.Set(Volume[0]);
    }

    if (BarsInProgress == 1)
    {
    vol10m.Set(Volumes[1][0]);

    Print("Barsinprogress 1 " + Time[0] + " " + vol10m[0] + " " + vol10m[1] + " " + vol10m[2] + " " + vol10m[3] + " " + vol10m[4] + " " + vol10m[5] + " ");
    }

    }

    When I set the primary bar to 5 minute, here is the output:

    Barsinprogress 1 22/7/2014 10:00:00 AM 4707 2101 6281 3973 9424 2779
    Barsinprogress 1 22/7/2014 10:10:00 AM 6380 2569 4707 2101 6281 3973
    Barsinprogress 1 22/7/2014 10:20:00 AM 4481 2947 6380 2569 4707 2101


    Take the output from 10am as an example, the vol10m[0] is "4707". I expected the "4707" to become vol10m[1] when the bar was next updated at 10:10am. However, as you can see from the 10:10am output that the "4707" is actually vol10m[2].

    Basically whatever number that is set as vol10m[0] will become vol10m[2] when the bar gets updated next, and then become vol10m[4] when it gets updated again. I don't know where the numbers for vol10m[1], vol10m[3], vol10m[5],... etc come from, but they should not be there. (It is easy to verify that the vol10m[1], vol10m[3] etc should not be there because I can simply plot a 10-minute chart to check the volume)

    This is just a simple example to illustrate the problem I have been trying to solve for the past week. Would anyone be able to help ?

    Thanks very much.

    #2
    Hello Yawbus,

    Thank you for your post.

    There is a syncing conflict here with the dataseries.
    You are syncing both data series to the primary time frame from when you are adding the indicator to the chart. The additional index that you are seeing is a "filler' bar to account for the additional bar from the 5m time frame

    You can take a look at the sample below on syncing to a different time frame
    http://www.ninjatrader.com/support/f...ead.php?t=3572

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your help, Cal.

      I can now sync DataSeries correctly to the secondary bar. However I am still having problem syncing BoolSeries correctly to the secondary bar. In the following example:

      protected override void OnBarUpdate()
      {
      if (secondarySeries == null)
      {
      secondarySeries = new BoolSeries(?));
      }

      if my secondarySeries is now a BoolSeries, I cannot think of an indicator to replace the "?", is there one ?

      Thanks again.

      Comment


        #4
        Yawbus,

        You would sync the same way you did this with the dataseries
        Cal H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Rapine Heihei, Today, 08:19 PM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 08:25 PM
        0 responses
        3 views
        0 likes
        Last Post Rapine Heihei  
        Started by f.saeidi, Today, 08:01 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 07:51 PM
        0 responses
        6 views
        0 likes
        Last Post Rapine Heihei  
        Started by frslvr, 04-11-2024, 07:26 AM
        5 responses
        96 views
        1 like
        Last Post caryc123  
        Working...
        X