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 pibrew, Today, 06:37 AM
            0 responses
            1 view
            0 likes
            Last Post pibrew
            by pibrew
             
            Started by rbeckmann05, Yesterday, 06:48 PM
            1 response
            14 views
            0 likes
            Last Post bltdavid  
            Started by llanqui, Today, 03:53 AM
            0 responses
            6 views
            0 likes
            Last Post llanqui
            by llanqui
             
            Started by burtoninlondon, Today, 12:38 AM
            0 responses
            11 views
            0 likes
            Last Post burtoninlondon  
            Started by AaronKoRn, Yesterday, 09:49 PM
            0 responses
            15 views
            0 likes
            Last Post AaronKoRn  
            Working...
            X