Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order Size Failure and using Market Replay

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

    Order Size Failure and using Market Replay

    Hello,

    My Strategy is calculating Order size dynamically. It will usually open 3 orders with the same Entry Price but vary the Profit Target for each order. The strategy uses only Managed Approach orders of EntryLongLimit() , SetProfitTarget() and SetStopLoss(), etc...

    For my testing I am using NT 64 bit 7.0.1000.16 (Live) and:
    Account: Replay101
    Buying Power: 200,000.00
    Cash Value: 100,000.00
    Excess Equity: 200,000.00
    Initial Margin: 0.00


    As an example:

    Where SPY Close[0] = 179.16... Submit 3 orders with an Entry Limit price at 178.44, StopLoss price at 178.27 and Profit Targets at 178.92, 179.17 and 180.69. Order #1 Size= 706 shares, Order #2 Size= 1059, Order #3 Size = 1764. Therefore the total Position Size = 3,529 shares. The 3 orders break out the Order Sizes to take profit at different price points. THIS ABOVE example WORKS just fine.

    BUT when the strategy submits the following same order BUT with different order sizes for each of the 3 orders it fails with this error:
    "Market Replay Connection. Order has exceeded available account equity: Please reduce order size affected Order: Buy 2117 Limit @ 178.44"

    This is the example of the Order that failed:
    Where SPY Close[0] = 179.16... Submit 3 orders with an Entry Limit price at 178.44, StopLoss price at 178.27 and Profit Targets at 178.92, 179.17 and 180.69. Order #1 Size= 706 shares, Order #2 Size= 706, Order #3 Size = 2117. The total Position Size is the same (3,529 shares) as before yet an individual order has exceeded "some NT internal" limit.

    Can you please explain How I can calculate or determine the Maximum individual order size for the strategy to use to prevent NT from failing the order/strategy.

    Thank you

    #2
    Hello rayko,

    Since you are having multiple orders you will have to manually calculate this to see if you have enough Cash value to be able to cover your orders so, GetAccountValue() can get the "CashValue" and be able to calculate how many orders you can purchase.



    Let us know if you have any questions.
    JCNinjaTrader Customer Service

    Comment


      #3
      Thanks for the Link.

      I had the strategy print out CashValue before and after submitting each order. The value printed out for me was $100,000. In other words, submitting an order regardless of the equity share price does not change NT CashValue while using Replay.

      Or does CashValue update itself when connected to a broker account ?

      I also research this link http://www.ninjatrader.com/support/h...countvalue.htm where it says


      Equities - Order share size is calculated based on AccountSize / Current Close Price
      So.. Is Max Order Size = Account Size / Current Close Price ?

      Comment


        #4
        Hello rayko,

        The Replay101 CashValue will update as well from the Broker's Side if they support the "CashValue" Account Balance which most of them do.

        Here is a link that goes over which Brokerage Technology's support what Account Balance reports.


        For the "Max Order Size = Account Size / Current Close Price" that will make sure that you keep a positive CashValue which will work for the Sim101/Replay101 account and most brokerage providers.
        JCNinjaTrader Customer Service

        Comment


          #5
          I did some more digging thru the NT help files and found what I needed to work-around the problem of the strategy calculating and order size that causes Account Excess Equity to drop below Zero.

          Steps:
          1. Specify "by strategy" for Strategy Order Property "Set Order Quantity".

          This will allow the strategy to manually determine order quantity.

          2. Set "Maintenance margin" to Zero in Tools > Options > Simulator

          Default value is 0.30 or 30% margin. However if I put in a ZERO then the Simulation / Replay accounts will never reject an order since Excess Equity will never deplete below zero.

          I have created a spreadsheet that calculates Excess Equity based on Equity Share Price and Order Quantity. I built it using the info from the NT help in Configuration > Options > Simulator Tab under "How the Margin parameters impact Account values". You would need to enter the either the Buy or Sell side green cells for Share Price and Qty, and Maintencence Margin as a decinal. I will calculate the blue cells of either the Buy or Sell calculated remaining Excess Equity. I can post it if you guys want it. Let me know.

          Comment


            #6
            Hello rayko,

            If you could post it that would be a great resource to other members that may have the same question.
            JCNinjaTrader Customer Service

            Comment


              #7
              I’ve upload the Max Excess Equity Calculator spreadsheet and a Word document showing how to use it.
              Enjoy !
              Attached Files

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              648 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              369 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              108 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              572 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              574 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X