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 claxxical, 05-30-2017, 12:30 PM
        39 responses
        4,500 views
        0 likes
        Last Post fiendtrades  
        Started by tonynt, 05-21-2019, 06:27 AM
        12 responses
        541 views
        1 like
        Last Post fiendtrades  
        Started by alexstox, 10-16-2018, 03:29 PM
        12 responses
        355 views
        0 likes
        Last Post Tburg1073  
        Started by truepenny, Today, 03:59 AM
        0 responses
        5 views
        0 likes
        Last Post truepenny  
        Started by truepenny, Today, 03:45 AM
        0 responses
        10 views
        0 likes
        Last Post truepenny  
        Working...
        X