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

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
    Brandon H.NinjaTrader Customer Service

    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.
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by kevinenergy, 02-17-2023, 12:42 PM
        118 responses
        2,778 views
        1 like
        Last Post kevinenergy  
        Started by briansaul, Today, 05:31 AM
        0 responses
        9 views
        0 likes
        Last Post briansaul  
        Started by traderqz, Yesterday, 12:06 AM
        11 responses
        28 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by PaulMohn, Today, 03:49 AM
        0 responses
        8 views
        0 likes
        Last Post PaulMohn  
        Started by inanazsocial, Today, 01:15 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Jason  
        Working...
        X