Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Identifying a bar close in an "On price change" strategy?

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

    Identifying a bar close in an "On price change" strategy?

    I know technically every price change the computer is registering that the previous bar has closed. But I have some bools and other functionality that need to be reset after the current bar officially closes. Is it possible to do that in an "On price change" strategy?

    #2
    Hello Plzwork123,

    Thanks for your post.

    You can use the system bool IsFirstTickOfBar which will be true on the first tick of the bar when using Calculate.OnPriceChange.

    Reference: https://ninjatrader.com/support/help...ttickofbar.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      I probably should have specified. I just want to confirm this is accessible from the strategy builder? That's what I'm working in. Having a hard time finding it.

      Comment


        #4
        Hello Plzwork123,

        Thanks for your reply.

        Yes, whenever you ask a strategy question it would be helpful to identify that you are using the strategy builder so we can provide an appropriate response.

        In the Strategy Builder, there is no IsFirstTickOfBar property available.

        However, you can still create such an event, here is how:

        1) In the Inputs and variables section create a bool called FirstTickOfBar and set it to false. Create an int type variable called "WorkingBar"
        2) In set 1 (the sequence is important), have no conditions. In the action section, set the FirstTickofBar bool to be false. The bool will be set false on every tick.
        3a) In Set 2, for a condition use UerVariables>Workingbar, Not Equal, Misc>Current bar.
        3b) In set 2, for action, Misc>Set WorkingBar and assign(click set in the field) to Misc>currentBar
        3c) In set 2, for action, Misc>Set FirstTickOfBar to true by checking the check box.

        Set 2 will check to see if the working bar is the same as the current bar and if it is not then that means we have a new bar. The action then is to assign the current bar to WorkingBar so that the condition is only true once per bar and that also means we are on the first tick of the bar. Because set 1 sets the bool false on every tick, that is why set 2 must be next to set the bool to true and subsequent use of the bool will be true, until the next tick.

        This will provide a bool FirstTickOfBar that you can then use throughout your strategy. Keep in mind that sets 1 and 2 must be sets 1 and 2 in your strategy whenever you need first tick of the bar,

        NOTE: If you apply this to bars that uses IsRemoveLastBarSupported, such as Renko bars, this method will not work correctly and would generate 3 FirstTickOfBar = true conditions.




        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Ok yeah definitely wouldn't have thought to do that. Thank you kindly for the help.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by hdge4u, Yesterday, 09:09 PM
          0 responses
          15 views
          0 likes
          Last Post hdge4u
          by hdge4u
           
          Started by hdge4u, Yesterday, 09:02 PM
          0 responses
          8 views
          0 likes
          Last Post hdge4u
          by hdge4u
           
          Started by stormcloudseven, Yesterday, 08:41 PM
          1 response
          9 views
          0 likes
          Last Post DavidTrades  
          Started by GussJ, Yesterday, 01:24 PM
          0 responses
          23 views
          0 likes
          Last Post GussJ
          by GussJ
           
          Started by frslvr, Yesterday, 12:40 PM
          0 responses
          16 views
          0 likes
          Last Post frslvr
          by frslvr
           
          Working...
          X