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

Order entry one bar later

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

    #16
    Hello Impeesa,

    Thank you for your post.

    Please confirm the following: Are you placing the BarsInProgress check within OnBarUpdate()?

    1. How can we code the strategy to submit an order limit +- n ticks from the close of a bar where DeltaHigh>Limit or DeltaLow<-Limit?

    To have your strategy submit a limit order +/- N ticks from the Close of a bar, you could add a check for your condition to compare the cumulativeDelta.DeltaHigh[0] or .DeltaLow[0] to the DeltaLimit you specified in your script followed by calling EnterLongLimit to place an order if the condition is met. Please see the example code snippet below for how this could be accomplished.

    if (cumulativeDelta.DeltaHigh[0] > DeltaLimit)
    {
    EnterLongLimit(Convert.ToInt32(DefaultQuantity), (Close[0] + (4 * TickSize)) , @"LongEntryStrong");
    }

    2. I suppose that if next bars conditions are not met the order will cancel as normal.

    If the limit order isLiveUntilCanceled property is set to false or is not used and the order is not filled and not submitted again on the next bar, the order will automatically be canceled.

    Please review this help guide link for information about the isLiveUntilCanceled property - https://ninjatrader.com/support/help...tlonglimit.htm

    Let us know if we may further assist.
    Brandon H.NinjaTrader Customer Service

    Comment


      #17
      Hello Brandon

      Maybe I am wrong but I think all you mention is in your script in post #6 and as is shown in screenshots of posts #7 and #8 it does not work.

      1.- The code does not submit an order limit from the close of the bar where conditions are met. It submits an order during the bar where conditions are met.

      2.- The orders are not cancelled automatically.

      Thanks. I keep on learning

      Comment


        #18
        Hello Impeesa,

        Thank you for your post.

        In post number 6 considering realtime data, we had set the previously attached script to use Calculate OnEachTick so that the strategy's indicator matched up with the OrderFlow Cumulative Delta indicator that was added to the chart for testing purposes. When the Calculate mode is set to OnEachTick, orders will be placed on the bar that the conditions are being met.

        To have your strategy place orders at the close of a bar when a condition becomes true, your strategy's Calculate mode would need to be set to .OnBarClose instead of .OnEachTick.

        Considering historical data, my example was not making a BarsInProgress check, so logic was being executed for both the Primary Data Series and the added Tick Series.

        Please review this Multi-Timeframe and Multi-Instrument help guide link to better understand how added data series are accessed - https://ninjatrader.com/es/support/h...tDrivenOnbarup dateMethod

        When a script is processing Realtime data it uses Calculate OnPriceChange or OnEachTick. If the strategy is processing OnPriceChange or OnEachTick, you could check if a bar is closed by checking if IsFirstTickOfBars is true.

        Please also review these help guides about Caculate OnBarClose, OnEachTick, OnPriceChange as well as how IsFirstTickOfBar is used.

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

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

        As you can see in the attached screenshot, when running the strategy we can see in the NinjaScript Output window that orders are being canceled automatically. This is because our strategy does not specify if isLiveUntilCanceled is true. If the isLiveUntilCanceled property is set to false or is not used and the order is not filled and not submitted again on the next bar, the order will automatically be canceled.

        Click image for larger version

Name:	2020-09-21_15-07-25.png
Views:	161
Size:	508.3 KB
ID:	1119205

        Let us know if we may further assist.
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Segwin, 05-07-2018, 02:15 PM
        10 responses
        1,767 views
        0 likes
        Last Post Leafcutter  
        Started by Rapine Heihei, 04-23-2024, 07:51 PM
        2 responses
        30 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by Shansen, 08-30-2019, 10:18 PM
        24 responses
        943 views
        0 likes
        Last Post spwizard  
        Started by Max238, Today, 01:28 AM
        0 responses
        9 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by rocketman7, Today, 01:00 AM
        0 responses
        7 views
        0 likes
        Last Post rocketman7  
        Working...
        X