Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calulating indicator value when CalculateOnBarClose = false

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

    Calulating indicator value when CalculateOnBarClose = false

    Hello,

    I would like to know how to retrieve the value of an indicator at the close of the previous bar when CalculateOnBarClose is set to false. When it is set to false and I want to get the previous value I am getting the value of the previous tick.

    Thanks

    #2
    Hello guillembm,
    Thanks for your post.

    You could use the IsFirstTickOfBar property to seperate your logic like this. Please see the reference sample in our help guide here: https://ninjatrader.com/support/help...either_cal.htm

    Let me know if you have any questions or if this will not work for you.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Another question about this issue.

      Can FirstTickOfBar be used in a nested conditional in a secondary condition like:

      if (MyCondition)
      {
      if (FirstTickOfBar)
      MyMethod();
      }

      or it can only be used in the main conditional like

      if (FirstTickOfBar)
      {
      if (MyCondition)
      MyMethod();
      }

      Should it work in both ways?

      Comment


        #4
        guillembm,

        You can use FirstTickOfBar wherever you like in your logic, but I suspect you are going to want to use your second snippet so that nothing prevents that condition from being checked.
        Code:
        if (FirstTickOfBar)
        {
             if ([I]MyCondition[/I])
        [I]         MyMethod[/I]();
        }
        If you went with your first snippet, and MyCondition was false, then FirstTickOfBar would not get evaluated on that pass.
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Thanks,

          The 1st one is the one I want to use.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by mjairg, 07-20-2023, 11:57 PM
          3 responses
          213 views
          1 like
          Last Post PaulMohn  
          Started by TheWhiteDragon, 01-21-2019, 12:44 PM
          4 responses
          544 views
          0 likes
          Last Post PaulMohn  
          Started by GLFX005, Today, 03:23 AM
          0 responses
          3 views
          0 likes
          Last Post GLFX005
          by GLFX005
           
          Started by XXtrader, Yesterday, 11:30 PM
          2 responses
          12 views
          0 likes
          Last Post XXtrader  
          Started by Waxavi, Today, 02:10 AM
          0 responses
          7 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Working...
          X