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

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.
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Thanks Paul and cincai! Really appreciate the help

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by tsantospinto, 04-12-2024, 07:04 PM
        5 responses
        67 views
        0 likes
        Last Post tsantospinto  
        Started by cre8able, Today, 03:20 PM
        0 responses
        6 views
        0 likes
        Last Post cre8able  
        Started by Fran888, 02-16-2024, 10:48 AM
        3 responses
        48 views
        0 likes
        Last Post Sam2515
        by Sam2515
         
        Started by martin70, 03-24-2023, 04:58 AM
        15 responses
        115 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by The_Sec, Today, 02:29 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X