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

IsLastBarOnChart() and others ?

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

    IsLastBarOnChart() and others ?

    I am relatively new to Ninja and I spend a lot of time in the manual / doc. I am familiar with EasyLanguage and to a lesser extent C# with it's methods/ properties/ classes, etc. So, my point is, I am familiar in searching for things. I was not able to find IsLastBarOnChart description using both the alphabetical listing as well as the search. Search did find it being used in an example.

    Where is this described, and are there others I should know about or be able to find as parts of Ninja Language capabilities.
    Attached Files

    #2
    Hello joromero,

    Thank you for the question.

    In regards to the IsLastBarOnChart, you would not see this as it is undocumented as it is not supported but it is usable.

    Alternatively you can access the current bar information by doing the following.

    If you are trying to make the script wait until it is at the last bar of the chat and then start calculating you could use the statement below:

    Code:
    if(CurrentBar < Count - 1)
    return;
    This would check if the current bar that is being processed is the last bar, if not skip the code after the return statement.
    Here is the documentation on Count


    Another check is the historical check, this allows you to only execute after a new tick is received.
    So if you have this enabled on an indicator or strategy and apply it to a chart, it will do nothing past this line of code until a new tick is received.
    Code:
    if(Historical)
    return;
    Here is the documentation on Historical


    Please let me know if I may be of additional assistance.
    Last edited by NinjaTrader_Jesse; 07-07-2014, 08:06 AM.
    JesseNinjaTrader Customer Service

    Comment


      #3
      hello Jesse,

      How to draw text on last bar only after chart is completley load.
      For example if I use F5 to refresh chart with strategy , text is drawing on each bar

      (Chart period is 1 second)

      So I would like strart drawing text in real time only.

      if (CurrentBar > (Bars.Count - 2))
      Draw.Text(this, CurrentBar.ToString() + ( Close[0]).ToString() , "X", 0, Close[0]+0.05, Brushes.Black);

      (doesn't work)



      thank you

      Comment


        #4
        Hello oceanis400,

        If you want to only draw one object, the most simple way is to use a non-unique tag:

        Code:
        Draw.Text(this,[B] "MyNonUniqueTag"[/B] , "X", 0, Close[0]+0.05, Brushes.Black);
        You would not need to use a condition with this if you just wanted this on the last closed bar, or building bar depending on the Calculate setting. Calling the same tag name will remove the object from its current location and update its position

        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hello Jesse,

          No , I want to draw or plot only when last bar is load and display on chart.
          I haven't find way to do it.

          Text is drawing on all chart on every bar loaded. But I want to start drawing text in realtime only. (on each bar period 1s)

          sincerely

          Comment


            #6
            Hello oceanis400,

            If you only want to do something starting from realtime, you could use the Historical property to determine that.

            Code:
            if(Historical == false)
            {
                // do you code in realtime 
            }


            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thank you Jesse

              Comment


                #8
                Hello Jesse,

                Sorry , I don't find it in NT8.

                Where is Historical in NT8?

                thank you

                Comment


                  #9
                  Hello oceanis400,

                  Thank you for the post.

                  In this case, it looks as I had responded with NT7 syntax as we are in the NT7 forums. For NT8 questions please ensure to post in the NT8 forums going forward. I will move this to the NT8 forums.

                  For converting syntax from NT7 to NT8 you can use the code-breaking changes guide to find differences (select all from the dropdown and control + F Historical): https://ninjatrader.com/support/help...ng_changes.htm

                  For Historical, this is replaced with the State object and State system.



                  Code:
                  if(State == State.Realtime)
                  {
                  
                  }
                  I look forward to being of further assistance.
                  JesseNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by adeelshahzad, Today, 03:54 AM
                  5 responses
                  31 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Started by stafe, 04-15-2024, 08:34 PM
                  7 responses
                  31 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by merzo, 06-25-2023, 02:19 AM
                  10 responses
                  823 views
                  1 like
                  Last Post NinjaTrader_ChristopherJ  
                  Started by frankthearm, Today, 09:08 AM
                  5 responses
                  18 views
                  0 likes
                  Last Post NinjaTrader_Clayton  
                  Started by jeronymite, 04-12-2024, 04:26 PM
                  3 responses
                  43 views
                  0 likes
                  Last Post jeronymite  
                  Working...
                  X