Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Two Contracts instead of One

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

    Two Contracts instead of One

    Hi all - I am using the SampleOnOrderUpdate to add to my strategy. However, I am having issues when I switch to two or more contracts. Looks like I am buying the two contracts, however, my stops and targets are getting submitted with just 1 contract and the other contract is been sold at the EOD.

    Can someone tell me how to update this strategy to work with two or more contracts?
    Attached Files

    #2
    Hello felixolmo,

    Below is a link to the original reference sample in the help guide.


    In the modified script you have posted, the entry is using a quantity of 1 on line 80. Try setting this to 2.

    The exit will be using the entry Filled amount as the quantity for the exit.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chelsea. I will be trying that tomorrow morning.

      One question I have is, how can I save the average fill price if is fill at different prices? Any guidance on that? At the end I would like to have a list of the average fills on the orders generated by the strategy. for example, if the strategy submits one order for two contracts, I would like to save once the average once both contracts are filled. Not save two times one for each contract.

      Any guidance that you can provide would be appreciated.

      Comment


        #4
        Hello felixolmo,

        You could wait until the order.OrderState is OrderState.Filled where all contracts will be filled before taking an action.

        The order.AverageFillPrice includes all filled contracts for the order.

        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Would this be complete under OnExecutionUpdate?

          Comment


            #6
            Hello felixolmo,

            Eventually.. OnExecutionUpdate() triggers for every execution. So some may be part fills and some may be the final fill.


            Once the order.OrderState is OrderState.Filled, the order will be filled.
            Last edited by NinjaTrader_ChelseaB; 01-11-2022, 12:46 PM.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            50 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            126 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            69 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            42 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X