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

Intrabar Order quantity and position update

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

    Intrabar Order quantity and position update

    Hello everyone!
    I'm coding a system which enters a multiple lot size (one shot) and partial exits via limit orders. Position.Quantity is updated at the end of the bar, so new orders are placed at the end of bar. Any suggestion to get position quantity updated intrabar (or at order execution)?

    Thanks

    Marce

    #2
    >> Position.Quantity is updated at the end of the bar
    Incorrect.
    Position.Quantity is updated right as the execution comes in (and the position changes). OnBarUpdate might be triggered at the end of the bar (if CalculateOnBarClose=true).

    Comment


      #3
      Thanks Dierk for your ultra quick reply!
      Maybe i coded something doesn't work in rt....but as the code below, orders are generated the next bar:

      Code:
      if (Position.MarketPosition == MarketPosition.Long
      					if (Position.Quantity == ctr)
      					{
      					
      						ExitLongLimit(ctr/3, (Position.AvgPrice + target1), "1st Exit", "");
      						ExitLongStop(ctr, (Position.AvgPrice - stop), "1stStop", "");
      					}
      					else if (Position.Quantity == (ctr/3)*2)
      					
      					{
      						ExitLongLimit(ctr/3, (Position.AvgPrice + target2), "2nd Exit", "");
      					    ExitLongStop(Position.Quantity , (Position.AvgPrice - secondstop), "2ndStop", "");
      						
      					}

      Comment


        #4
        Right, since OnBarUpdate is triggered only once per bar (CalculateOnBarClose=true, please see my post below).

        I suggest:
        - play around with CalculateOnBarClose=false
        - debug your strategy using TraceOrders and per here: http://www.ninjatrader-support.com/v...ead.php?t=3418

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by mattbsea, Today, 05:44 PM
        0 responses
        2 views
        0 likes
        Last Post mattbsea  
        Started by RideMe, 04-07-2024, 04:54 PM
        6 responses
        31 views
        0 likes
        Last Post RideMe
        by RideMe
         
        Started by tkaboris, Today, 05:13 PM
        0 responses
        2 views
        0 likes
        Last Post tkaboris  
        Started by GussJ, 03-04-2020, 03:11 PM
        16 responses
        3,282 views
        0 likes
        Last Post Leafcutter  
        Started by WHICKED, Today, 12:45 PM
        2 responses
        20 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Working...
        X