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

Requesting clarification on SampleOnOrderUpdate code

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

    Requesting clarification on SampleOnOrderUpdate code

    Hi there. I have a question about the very last few lines of this sample code provided. Here is the code:

    // Reset our stop order and target orders' Order objects after our position is closed. (1st Entry) <<<<<<<<<<<<<<<<< ?
    if ((stopOrder != null && stopOrder == execution.Order) || (targetOrder != null && targetOrder == execution.Order)){
    if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled){
    stopOrder = null;
    targetOrder = null;
    }
    }​

    My question is about the parenthesized bit at the end of the comment "(1st Entry)". I'm trying to understand how the code flows if say my order quantity is 2 orders, both with the same stoploss level set but for one of which I have set a target takeprofit.

    The second line appears to nullify the stopOrder object if the first takeprofit is hit but there's still a stop remaining.

    #2
    Hello markdshark,

    Thanks for your post.

    If you have an order quantity of two, one order with a stop and target and the second order will only a stop, you would need to create a separate Stop order object for the script that has only a stop and no target, such as stopOrder2, so that the separate Stop order object remains after the stopOrder and targetOrder were set to null.

    Let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by RookieTrader, Today, 09:37 AM
    3 responses
    15 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by kulwinder73, Today, 10:31 AM
    0 responses
    5 views
    0 likes
    Last Post kulwinder73  
    Started by terofs, Yesterday, 04:18 PM
    1 response
    23 views
    0 likes
    Last Post terofs
    by terofs
     
    Started by CommonWhale, Today, 09:55 AM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by Gerik, Today, 09:40 AM
    2 responses
    7 views
    0 likes
    Last Post Gerik
    by Gerik
     
    Working...
    X