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 RideMe, 04-07-2024, 04:54 PM
          6 responses
          31 views
          0 likes
          Last Post RideMe
          by RideMe
           
          Started by tkaboris, Today, 05:13 PM
          0 responses
          2 views
          0 likes
          Last Post tkaboris  
          Started by GussJ, 03-04-2020, 03:11 PM
          16 responses
          3,281 views
          0 likes
          Last Post Leafcutter  
          Started by WHICKED, Today, 12:45 PM
          2 responses
          19 views
          0 likes
          Last Post WHICKED
          by WHICKED
           
          Started by Tim-c, Today, 02:10 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X