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 NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        81 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        149 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        79 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        52 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        59 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X