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

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.
    Emily C.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bortz, 11-06-2023, 08:04 AM
    47 responses
    1,611 views
    0 likes
    Last Post aligator  
    Started by jaybedreamin, Today, 05:56 PM
    0 responses
    9 views
    0 likes
    Last Post jaybedreamin  
    Started by DJ888, 04-16-2024, 06:09 PM
    6 responses
    19 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by Jon17, Today, 04:33 PM
    0 responses
    6 views
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    22 views
    0 likes
    Last Post Javierw.ok  
    Working...
    X