Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Second Entry Only Occurs on Same Bar as First Entry

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

    Second Entry Only Occurs on Same Bar as First Entry

    Hi,

    On my current long strategy I have 2 buy zones set up. I noticed the second entry is only triggering if its buy price is hit on the same bar that triggered entry 1. I thought my logic would allow for entry two to stay active. I commented out the only cancelorder code in the strategy and that isn't the issue.

    This is off a daily timeframe and time in force is GTC.

    Bar[1] price is always above the entry MIT price.

    Code:
    protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
    {
    
    #region Entry BZ2
    
    if (order.Name == "EntryLongBZ1" && (orderState == OrderState.Filled || orderState == OrderState.Working))
    {
    entryPriceBZ2 = lineBZ2 + ticksAboveBZ2 *TickSize;
    orderLongBZ2= EnterLongMIT(1,true,lotLBZ2,entryPriceBZ2,"EntryLongBZ2");
    }
    Thanks for the help.

    #2
    Hello mlprice12,

    Thank you for your post.

    To understand why the script is behaving as it is, such as placing orders or not placing orders when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

    In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

    Below is a link to a forum post that demonstrates using prints to understand behavior and including a link to a video recorded using the Strategy Builder.
    https://ninjatrader.com/support/foru...121#post791121

    Please let me know if I 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


      #3
      Thanks BrandonH,

      Trace orders and prints work when backtesting or only testing on live data?

      Comment


        #4
        Hello mlprice12,

        Thank you for your note.

        Prints and TraceOrders work for both Historical (backtest) and Live data. You will find the output for Prints and TraceOrders in a New > NinjaScript Output window.

        Let us know if we may assist further.
        <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, Yesterday, 05:17 AM
        0 responses
        59 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        133 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        73 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X