Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Programmatically modify Chart Trader order quantity during order execution

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

    Programmatically modify Chart Trader order quantity during order execution

    Hi guys

    Is there a way to change a default quantity in Chart Trader ATM strategy when I drop the order on the chart. I want to calculate the number of shares based on my risk and size of my account by using the nearest swing low as my stop. Let's say I create an ATM strategy with quantity 1 and I define some arbitrary stop few % below my entry. When I create a limit order from the chart it would obviously have quantity 1 but when I drop it on the chart either for immediate execution or below the bid the quantity would have to be automatically adjusted before sending the order for execution. Also when I move the order up or down the quantity would be recalculated and adjusted.

    #2
    Hello rmez01,

    Thank you for your post.

    What you have described should be mostly possible through a custom add-on in NinjaTrader. You did mention that you want an order quantity to start out as 1 but then when you click to place it on the chart the quantity would be automatically adjusted before execution. This wouldn't quite be possible because the order needs to be submitted first to have an existing object where the quantity could be changed. It would be possible to change the quantity in the Chart Trader quantity selector before the order is submitted; you could create a mouse click event that changes the quantity in the selector based on where the mouse is clicked and then when you go to place the limit order from the right-click menu it could be placed at the quantity that was set from the mouse click event.

    The attached example demonstrates how the Chart Trader UI Elements could be modified programmatically, including how to change the quantity selector.
    ChartTraderUIElementsFromAuotmationIDsIndicatorExample.zip

    If you are working with your own stop loss order that you program, you could then use Change() to update the quantity based on certain conditions, such as if the order price is modified you could detect that from the OrderUpdate event and submit a new change to also adjust the quantity. When working with ATM strategy orders, the AtmStrategyChangeStopTarget() method does not offer a quantity field. You would likely need the logic to figure out how many contracts need to be bought or sold in order to scale in/out of the active ATM strategy and submit a buy/sell accordingly.

    We have some more general information about developing Add Ons here:


    As well as this overview page, which includes the AddOn Framework NinjaScript Basic example script that demonstrates some of the capabilities of NinjaScript add-ons:


    Please let us know if we may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    581 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    338 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    554 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    552 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X