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

When is Time[0] active

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

    When is Time[0] active

    I have some logic in indicator and was wondering when Time[0] becomes the the current bar on the chart. When i did a printout it was the very first bar on the chart.

    I have this statement

    if (Time[0] > drawList[nIndex].Time)
    {

    I use this function only at startup

    i used this
    if (CurrentBar == 2)
    {
    }

    and it doesn't work;


    if I keep it out it will work but because of the loop logic it will take a while to load.

    How do you get around this issue?

    #2
    Hello ballboy11,

    Thank you for writing in.

    Every bar draw on a chart will have been at a time, Time[0]. For example, when a chart is drawn, the bars are drawn on the chart from left to right, and on each bar being drawn, it is the current bar.

    If you wanted to prevent the issue where old historical bars are Time[0], you could add the following to the top of your code,k
    Code:
    if(State ==State.Historical) return;
    The above will cause the script to only run in real time.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by nicthe, 08-23-2023, 07:53 AM
    7 responses
    195 views
    0 likes
    Last Post nicthe
    by nicthe
     
    Started by nicthe, Today, 09:24 AM
    0 responses
    5 views
    0 likes
    Last Post nicthe
    by nicthe
     
    Started by stalt, 12-28-2015, 01:36 PM
    6 responses
    1,536 views
    0 likes
    Last Post giulyko00  
    Started by Tburg1073, Today, 08:36 AM
    0 responses
    6 views
    0 likes
    Last Post Tburg1073  
    Started by alexstox, 10-16-2018, 03:29 PM
    10 responses
    334 views
    0 likes
    Last Post Tburg1073  
    Working...
    X