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

How can I access to data of last bar?

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

    How can I access to data of last bar?

    Hi there,

    I'm new at NinjaTrader and NinjaScript. However, I have experince in MetaTrader, so I'm not completely foreign to trade programming.

    I've installed NT and connected to Yahoo for daily data.

    I created an indicator that has the following line in it to print bar data on th chart:

    Print(CurrentBar.ToString() + " " + ToDay(Time[0]) + " Open: " + Open[0].ToString() + " Close: " + Close[0].ToString());

    and here's the last part of output as of today (June 1st) for symbol INTC:
    ....
    ....
    242 20100517 Open: 21.75 Close: 22.02
    243 20100518 Open: 22.14 Close: 21.43
    244 20100519 Open: 21.52 Close: 21.6
    245 20100520 Open: 21.02 Close: 20.79
    246 20100521 Open: 20.41 Close: 20.91
    247 20100524 Open: 20.95 Close: 20.67
    248 20100525 Open: 20.12 Close: 20.85
    249 20100526 Open: 21.1 Close: 20.7
    250 20100527 Open: 21.16 Close: 21.76

    My question is : where is May 28th data?
    Considering yesterday was a holiday, May 28th is the last bar, and I can see May 28th bar on the chart. In fact, when I insert a SMA into the chart, I can see that the SMA is not plotted for May28th either.

    I'm sure I'm missing something here, any help is appreciated.

    Thanks,

    Nick.

    #2
    Hi 10percent, and welcome to the forums!

    It looks like the last available day using the Yahoo feed is May 28th, so this is treated as the current bar.

    You will need to change the CaculateOnBarClose setting (Right click>Indicators) to false. Or change this in your code.

    More info at - http://www.ninjatrader-support.com/H...ateOnBarClose1
    TimNinjaTrader Customer Service

    Comment


      #3
      Tim, thanks for quick reply.

      I had added

      CalculateOnBarClose = false;

      in my code, but I kept pressing F5 on the chart to receive the changes.
      I removed the indicator and added back on, now It works.

      Nick.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      238 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      9 responses
      382 views
      1 like
      Last Post Gavini
      by Gavini
       
      Started by oviejo, Today, 12:28 AM
      0 responses
      1 view
      0 likes
      Last Post oviejo
      by oviejo
       
      Started by pechtri, 06-22-2023, 02:31 AM
      10 responses
      125 views
      0 likes
      Last Post Leeroy_Jenkins  
      Started by judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      59 views
      0 likes
      Last Post DynamicTest  
      Working...
      X