Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Requesting clarification on SampleOnOrderUpdate code

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

  • NinjaTrader_BrandonH
    replied
    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.

    Leave a comment:


  • 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.

Latest Posts

Collapse

Topics Statistics Last Post
Started by Darkslide_Tom, Yesterday, 11:08 PM
0 responses
7 views
0 likes
Last Post Darkslide_Tom  
Started by wolfrine97, Yesterday, 10:54 PM
0 responses
6 views
0 likes
Last Post wolfrine97  
Started by sastrades, Yesterday, 09:24 PM
0 responses
9 views
0 likes
Last Post sastrades  
Started by techbid, 03-21-2025, 12:16 PM
1 response
14 views
0 likes
Last Post techbid
by techbid
 
Started by laketrader, 03-10-2025, 07:20 AM
7 responses
68 views
0 likes
Last Post laketrader  
Working...
X