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 Brevo, Today, 01:45 AM
        0 responses
        3 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        3 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        240 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Started by oviejo, Today, 12:28 AM
        0 responses
        6 views
        0 likes
        Last Post oviejo
        by oviejo
         
        Working...
        X