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

Minimum 3 bars...

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

    Minimum 3 bars...

    Hello to all,

    This code does not work.

    Where am I wrong?

    Hello,
    Vy61
    Attached Files

    #2
    Hello Vy61cm,

    Thank you for your post and welcome to the Forums!

    You will need to add a CurrentBar check in the beginning the OnBarUpdate() to ensure that enough data has been loaded for the script to check for its calculations. The reason for this is because you are checking back 2 bars ago for Low. When the script starts it will be with the first bar and since there is no data to request for 2 bars ago it will not work.

    Code:
    if(CurrentBar < 2)
    return;
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Cal,

      Just one thing.
      How do I plot, not on the Bar[0] but on Bar[1]?

      Thank you,
      VY
      Attached Files

      Comment


        #4
        vy61cm,

        Just out of curiosity, why would you want to plot this one bar ago? The signal would have happened on that bar and then plotted there.

        You can do this by changing your .Set() to this

        Code:
        Plotto1.Set(1,1);
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Cal,

          It 's the first time I write code for NT7. It 'an exercise to see how it works. They are basic building blocks.

          I'm interested to see graphically the object at that point. But it may be useful for other things.

          Thank you,
          VY

          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