Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Determining direction in which bar opens and how to place an order accordingly.

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

    Determining direction in which bar opens and how to place an order accordingly.

    I want to see if the current bar opens either up or down. Depending on how the bar opens, I want to submit an order. What would be the best way to go about this? And is this possible to perform during live trading (not asking if it would be profitable but rather if it is possible for ninjatrader to determine the direction in which the CURRENT bar opens in real time).

    #2
    Not sure what are you going to achieve here.

    What is mean by determine up / down.

    If you want to determine the bar whether is green bar / red bar, you can use Close[0] and Open[0]

    For example :
    if (Close[0] > Open[0])
    --> Here is green bar and do what you want

    if (Close[0] < Open[0])
    --> Here is red bar and do what you want

    Comment


      #3
      Hello wowza,

      Thanks for your post and welcome to the NinjaTrader forums!

      In order to work with the currently forming bar on real-time (or playback with market replay) data, your strategy will need to use either Calculate.OnEachtick or Calculate.OnPriceChange. Reference: https://ninjatrader.com/support/help...?calculate.htm Using either of those calculate settings will cause the bar index of [0] to point to the currently forming bar. Close[0] in these cases will represent the current price. Close[1] will be the close price of the just-closed bar.

      If you wish to compare the open price on the new bar as soon as it opens, you can use the system bool IsFirstTickOfBar to trigger a check of the open price to the close price of the previous bar, for example:

      if (IsFirstTickofBar && Open[0] > Close[1])
      {
      // do something
      }

      Reference: https://ninjatrader.com/support/help...ttickofbar.htm

      As forum member cincai advised, you can check a bar's direction by checking the close price to the open price, keeping in mind that the currently forming bar can change direction.

      Comment


        #4
        Thanks Paul and cincai! Really appreciate the help

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        88 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        134 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        119 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        67 views
        0 likes
        Last Post PaulMohn  
        Working...
        X