Announcement

Collapse
No announcement yet.

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.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    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:	190
Size:	508.3 KB
ID:	1119205

        Let us know if we may further assist.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        25 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        121 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        64 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X