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

Multitimeframe Indicator not "showing" last candle

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

    Multitimeframe Indicator not "showing" last candle

    Hi
    I have this simple code:

    Code:
     protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "TheStratTFC";
    Calculate = Calculate.OnPriceChange;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    }
    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Month, 1);
    AddDataSeries(Data.BarsPeriodType.Week, 1);
    AddDataSeries(Data.BarsPeriodType.Day, 1);
    AddDataSeries(Data.BarsPeriodType.Minute, 240);
    AddDataSeries(Data.BarsPeriodType.Minute, 60);
    AddDataSeries(Data.BarsPeriodType.Minute, 30);
    
    }
    
    }
    
    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 0)
    {
    Print("Month: " + MonthOpen + " Week:" + WeekOpen + " Day:" + DayOpen +" 4 Hour: "+Hour4+" Hour:"+Hour+" 30 min:"+Minute30);
    }
    
    if (BarsInProgress == 1)//Month
    {
    MonthOpen = Opens[1][0];
    }
    if (BarsInProgress == 2)//Week
    {
    //WeekOpen = BarsArray[2].GetOpen(BarsArray[2].Count - 1);
    WeekOpen = Opens[2][0];
    }
    if (BarsInProgress == 3)//Day
    {
    DayOpen = Opens[3][0];
    }
    if (BarsInProgress == 4)//4 Hour
    {
    Hour4 = Opens[4][0];
    }
    if (BarsInProgress == 5)//Hour
    {
    Hour = Opens[5][0];
    }
    if (BarsInProgress == 6)//Minute 30
    {
    Minute30 = Opens[6][0];
    }
    
    
    }
    but the last candle on the different timeframes is not registred so the last values I get for all timeframes besides the primary is the candle before the last.

    Best Regards,
    Sune

    #2
    Hello Sune,

    The bars update based on the Calculate setting, and depend on if the data is historical or real-time.

    What is the value of Calculate in State.Configure?

    Is this State.Historical or State.Realtime data?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea

      I do not understand what you are pointing to. Could you elaborate ?

      Best Regards,
      Sune

      Comment


        #4
        Hello Sune,

        Below is a link to the help guide on the Calculate setting.


        And the State property.


        As well as a forum thread that discusses how historical data is processed before real-time data.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Again
          Now it works without me changing anything so seems to have been some caching or the like on the chart. Thanks for your help.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by geotrades1, Today, 10:02 AM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by ender_wiggum, Today, 09:50 AM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by rajendrasubedi2023, Today, 09:50 AM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by bmartz, Today, 09:30 AM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by geddyisodin, Today, 05:20 AM
          3 responses
          26 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X