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

Intra bar order

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

    Intra bar order

    I would like to know how to put intra bar order.
    Suppose I want to buy when the price of the current bar is higher than the high of the previous bar.
    The system can be :

    protected override void Initialize()
    {
    CalculateOnBarClose = false;
    }
    protected override void OnBarUpdate()
    {
    if (High[0] > High[1])
    {
    EnterLong;
    }
    }

    But in this system the high [0] is only known at the close of the bar.
    How can I put an order at any time, when high[0] is greater than High[1].
    Thank you.

    #2
    To do what you want you use the exact code you have already. [0] is only the close when the bar closes. All other times it is the last known price.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Infortunedly that’s not what I’ve got on the chart.
      I should have buy orders near the blue lines for example.

      Web word processing, presentations and spreadsheets

      Comment


        #4
        To clarify:

        - If you run your strategy in real-time with calculate on bar close set to false, your strategy logic is evaluated on every incoming tick. If the condition is true, an order is placed and the chart will display the entry based on the actual execution time
        - In backtest, OnBarUdpate() is evaluated once per bar and once your condition is true, an execution will hold a time stamp of the following bar
        RayNinjaTrader Customer Service

        Comment


          #5
          So, with this kind of strategy, in backtest I will never get the same profit & loss I will get if I run the same strategy in real time, because in backtest I will never get an intra bar order ?
          So, in backtest there no way to get an intra bar order If I consider only one data series or do I need to use something else than OnBarUdpate() in backtest to get an intra bar order with one data series ?
          Thanks again.

          Comment


            #6
            This approach might be of value.

            RayNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by traderqz, Yesterday, 12:06 AM
            11 responses
            26 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by PaulMohn, Today, 03:49 AM
            0 responses
            7 views
            0 likes
            Last Post PaulMohn  
            Started by inanazsocial, Today, 01:15 AM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Jason  
            Started by rocketman7, Today, 02:12 AM
            0 responses
            10 views
            0 likes
            Last Post rocketman7  
            Started by dustydbayer, Today, 01:59 AM
            0 responses
            4 views
            0 likes
            Last Post dustydbayer  
            Working...
            X