• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Place Order for Next Bar

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

    Place Order for Next Bar

    My strategy runs off a Range (4) chart with a .25 TickSize. The strategy involves placing Buy/Sell Stop orders one tick above/below the signal bars high/low.

    My problem:

    In fast markets the strategy will often get an invalid order message because the market has moved too fast.

    What I would like to do:

    Before the current bar, closes, if the strategy has a valid signal, I would like to place a pending order 1 tick above/below the bars predicted high/low to get in the trade on the next bar. Placing the order on the current bar for the next bar should avoid invalid orders in a fast market? If the new bar never hits the price, the order should be cancelled.

    For example using a long entry, the buy stop order price is calculated from the bars current low + (5*TickSize) because the bar will close no higher than the current low + 4 ticks.

    Because I don't know all the ins and outs of how NT places orders, I'm not sure if this is possible or if my 'solution' is a real solution or not.

    Thanks in advance.

    #2
    Hello Trader_Mark,

    Thanks for opening the thread.

    Before the current bar, closes, if the strategy has a valid signal, I would like to place a pending order 1 tick above/below the bars predicted high/low to get in the trade on the next bar. Placing the order on the current bar for the next bar should avoid invalid orders in a fast market? If the new bar never hits the price, the order should be cancelled.
    Placing an order safely 1 tick above the market price is difficult to manage when considering slippage. Your idea to "predict" where the market might be and place an order at that price is a good shot to try and get the order in before the market disallows the submission.

    As we cannot predict when the last tick of a bar will come in, you will have to come up with your own reliable way to submit your order during the development of the current bar.

    Some ideas would include...
    • Running the strategy with Calculate.OnEachTick for intra-bar events and modifying the logic to have Calculate.OnBarClose events happen on IsFirstTickOfBar.
    • Using a custom timer event to trigger your order submission after some time passes after the last bar close.
    • Implement an additional data series for intra-bar granularity


    Here are some resources to review that can help you develop these ideas.

    Calculate - https://ninjatrader.com/support/help.../calculate.htm

    IsFirstTickOfBar - https://ninjatrader.com/support/help...ttickofbar.htm

    Custom Timer Event sample - http://ninjatrader.com/support/forum...ead.php?t=5965

    Multi Series NinjaScript documentation - https://ninjatrader.com/support/help...nstruments.htm

    Intra-bar granularity example - http://ninjatrader.com/support/forum...ead.php?t=6652

    Please let me know if I may be of further assistance.
    Last edited by NinjaTrader_Jim; 08-24-2017, 06:08 AM.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you, I will check out those links.

      If we could consider for a moment that 1) Calculate.OnBarClose is specified and 2) the signal bar is the bar where all conditions are true for an order to be placed and it is the far right bar, bar[0].

      When the bar closes a new bar will be formed and I guess the order is placed. When placing the order and specifying the price, since we are still inside OnBarUpdate(), does referencing bar[0] in the order, such as Low[0] reference the signal bar Low or the new bar Low?

      Code:
      protected override void OnBarUpdate()
              {
                     .....<snip>.....
                     // Set 1
                      if ((amaSuperTrendU111.Trend[1] == -1 && amaSuperTrendU111.Trend[0] == 1) // trend change, down to up, possible this bar
                          && (Low[0] + (4*TickSize) > amaSuperTrendU111.ReversePrice) // the high/close of this bar could cross the supertrend stop line
                          
                          && (StochasticsFast1.D[0] > 20)
                          && ((StochasticsFast2.D[0] > StochasticsFast1.D[0]) || (StochasticsFast1.D[0] > 80))
                          )
                      {
                          EnterLongStopMarket(Convert.ToInt32(DefaultQuantity), Low[0] + (5*TickSize), @"StrategyLong");
                      }

      Comment


        #4
        Hello Trader_Mark,

        When using Calculate.OnBarClose, referencing a price object with a barsago of 0 would represent the bar that just completed and has been 'closed.'

        When using Calculate.OnEachTick, referencing a price object with a barsago of 0 would represent the current developing bar.

        I forgot to provide additional information on doing this with a Multi Series NinjaScript. The idea would be to implement an additional data series with finer granularity and to do certain actions on the BarsInProgress of that data series. I would suggest to review the "True Event Driven OnBarUpdate() Method" section of the Multi Time Frame and Instruments section of the help guide for implementation.

        True Event Driven OnBarUpdate() Method: https://ninjatrader.com/support/help...arupdateMethod

        I have also updated my previous message with links to the Multi Time Frame and Instruments section of the help guide and with a sample that adds an additional data series. The sample is used to describe submitting orders to a secondary data series, but is also useful for seeing a working implementation of a Multi Series script.

        If you have any additional questions on the provided material, please don't hesitate to ask.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by JPPoulin, Today, 01:32 PM
        2 responses
        11 views
        0 likes
        Last Post JPPoulin  
        Started by bltdavid, Today, 01:09 PM
        0 responses
        9 views
        0 likes
        Last Post bltdavid  
        Started by pstrusi, Today, 12:50 PM
        2 responses
        8 views
        0 likes
        Last Post pstrusi
        by pstrusi
         
        Started by ralett, Today, 11:52 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_PatrickG  
        Started by rtwave, Yesterday, 07:06 PM
        2 responses
        27 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Working...
        X