Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Single-click order entry on chart

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

    Single-click order entry on chart

    Hello,

    I know ChartTrader supports right-click and selecting limit order on the menu. I'd like to be able to single-click on the chart and have a buy/sell limit order placed there based whether it's below/above the last price. It should use the current settings from ChartTrader, e.g. account, quantity, and ATM strategy. I'd probably want it to require also pressing Shift+Ctrl while clicking.

    a) Is that possible out-of-the-box with some configuration?

    b) If not, can you point me in the right direction for how to build it with NinjaScript? I've written a couple of custom indicators. Would this be an indicator, or something else like an add-on or strategy? How would it receive mouse/keyboard input to detect Shift-Ctrl-click? And how does it place an order based on current ChartTrader settings? (Any pointers to relevant manual sections, examples, or existing forum threads would be plenty.)

    Thanks!

    #2
    Hello darkbluedove , thanks for your post.

    This is possible in NinjaScript. I attached an example indicator that will submit a limit order at the price when you click the mouse. To detect if a keyboard key is pressed you can use IsKeyDown.

    Edit: I noticed you have questions on the ChartTrader settings. You need to use the WPF Automation ID to get the correct object. There is an example of the idea here. The same concept applies for the other ChartTrader elements. You can look for the automation ID of a WPF object by using inspect.exe

    Please let me know if you have any questions on this material.
    Attached Files
    Last edited by NinjaTrader_ChrisL; 08-28-2020, 09:06 AM.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Sweet; thanks, Chris! This is great. I went through the materials and got the example indicator working. I'll see how far I get with my custom indicator. It will be really helpful in trading!

      Comment


        #4
        Hi darkbluedove - this is exactly what I've been looking for as well (preferably with the ISKEYDOWN option). Did you have any success yet? Unfortunately I don't know how to code it myself. All the best, David

        Comment


          #5
          Originally posted by davidhuels View Post
          Hi darkbluedove - this is exactly what I've been looking for as well (preferably with the ISKEYDOWN option). Did you have any success yet? Unfortunately I don't know how to code it myself. All the best, David
          Hi, davidhuels. I'm optimistic that I should be able to get it working, at least without the ATM strategy; it looks like that might add some complication, so I'll probably phase it to start with an order and right quantity, and add an option to do half size (like Ctrl-Shift-2). I'm juggling priorities while learning the system as I'm new to it, so hopefully in the next couple weeks I should have something.

          Comment


            #6
            Hello darkbluedove and welcome to the forums, davidhuels!

            Chris is out of the office at this time, but I wanted to share some more information that might be helpful.

            For submitting ATM strategies with AddOn Framework code, please see our documentation below. StartAtmStrategy would be used instead of Account.Submit().



            For accessing ChartTrader properties, you could try accessing ChartControl.OwnerChart.ChartTrader. This is not documented, but you can use intellisense/intelliprompt to look at the properties therein.



            I have also attached an example that can demonstrate using ChartControl.PreviewKeyDown events to monitor key presses.

            We look forward to assisting.
            Attached Files
            JimNinjaTrader Customer Service

            Comment


              #7
              Thanks, Jim! This is quite helpful!

              Regarding ATM, it sounds like it's made to be simple to kick off an entry order. One concern I'm wondering about based on recent testing using NinjaTrader manually:

              Will the quantities of the target orders automatically adjust based on the quantity of the entry order? [BTW, any insights would help with my manual trading, too!]

              For example, let's say I often adjust the entry quantity, and I always want 2 targets with half quantity each. If I manually adjust the entry quantity, the ATM target quantities don't seem to adjust to be half/half. Like if the ATM was set to entry quantity 10, with 2 target legs of 5 & 5, then when I change the Chart Trader entry quantity for the next trade to be 14, I'd want the ATM target legs to be 7 & 7.

              1) Is there a way so that during manual trading, the ATM strategy adjusts the target leg quantities automatically based on the proportions in the ATM template?

              2) When using StartAtmStrategy(), what is the recommended way to achieve this?

              a) It would be great if it's automatically adjusted when submitting the ATM template name and account order object. Is that possible?

              b) If not, here's some brainstorming: I've been manually adjusting the ATM target leg quantities in the temporary "Custom" ATM settings. If the script can somehow use the current ATM settings in Chart Trader, even if they are NOT saved to an ATM template, that would be ok.
              Last edited by darkbluedove; 09-02-2020, 09:20 PM.

              Comment


                #8
                Hello darkbluedove,

                1) Is there a way so that during manual trading, the ATM strategy adjusts the target leg quantities automatically based on the proportions in the ATM template?
                When manual trading, if you change the ATM strategy template, the order submission Quantity Up/Down selector will adjust to the ATM strategy template's order quantity. If we adjust the order quantity after that the quantity will change the behavior of the ATM strategy so additional contracts and target levels are not used.

                2) When using StartAtmStrategy(), what is the recommended way to achieve this?

                a) It would be great if it's automatically adjusted when submitting the ATM template name and account order object. Is that possible?

                b) If not, here's some brainstorming: I've been manually adjusting the ATM target leg quantities in the temporary "Custom" ATM settings. If the script can somehow use the current ATM settings in Chart Trader, even if they are NOT saved to an ATM template, that would be ok.
                StartAtmStrategy would be used in place of Account.Submit(). Our documentation has some example code that demonstrates how it can be used, and you may reference our AddOn Framework example for a working implementation. StartAtmStrategy can be given an AtmStrategy or a string for an Atm Strategy Template.

                AddOn Framework example - https://ninjatrader.com/support/help...t_overview.htm

                If you use the quantity from ChartTrader's Quantity property, then your order submission should use what ChartTrader has, which would change when you change your ATM strategy.

                Please be sure to peek through ChartControl.OwnerChart.ChartTrader with intelliprompt/intellisense to see how you can use it for your needs.

                We look forward to assisting.

                JimNinjaTrader Customer Service

                Comment


                  #9
                  Thanks, NinjaTrader_Jim !

                  I've made a ton of progress putting together the various pieces from this thread and other documentation. It's starting to come together for what I need.

                  One thing for which I could use your pointers:

                  I'm trying to get documentation on class AtmStrategy. The short article in the guide isn't very helpful, and I also looked through IntelliSense. In particular, I want to change the quantities in the legs of the selected ATM strategy in ChartTrader: ChartControl.OwnerChart.ChartTrader.AtmStrategy. I need to update them to keep the same proportions (for example, half and half for 2 target legs) so that the current ATM strategy uses whatever is the current ChartTrader total quantity (which I'm successfully using for other purposes through ChartControl.OwnerChart.ChartTrader.Quantity).

                  Can you please provide any insights/examples/links?
                  Last edited by darkbluedove; 09-10-2020, 11:50 PM.

                  Comment


                    #10
                    Hello darkbluedove,

                    Thanks for your question.

                    How an ATM strategy distributes each leg is configured in the ATM strategy template and could not be set programmatically. Let's consider if we create an ATM strategy template that protects 2 contracts and has 1 contract per leg. If we manually enter a position with a quantity of 4, the ATM strategy will enter with the first leg covering 3 contracts and the second leg covering 1 contract.

                    If you want to have the order quantity split in half for separate legs, I would suggest creating 2 ATM strategies so each strategy has one target/stop and then you can submit 2 entry orders with a quantity of ChartControl.OwnerChart.ChartTrader.Quantity/2.

                    Please let me know if you have any additional questions.
                    JimNinjaTrader Customer Service

                    Comment


                      #11
                      Hi, NinjaTrader_Jim . Thanks for the info and your thoughts on how it could be achieved. I'll stick to ATM strategies with one leg.

                      I've been testing out the single-click order entry code. One thing I've noticed is that even when an active ATM strategy is selected in ChartTrader, the subsequent orders entered by the code as they get filled are not updating/canceling the ATM strategy's target/stop orders. I have a key combo for AtmStrategy.StartAtmStrategy() and another one for Account.Submit(). If Account.Submit() is used, then the new order is completely separate from the active ATM strategy, which makes sense. If AtmStrategy.StartAtmStrategy() is used, then the new order starts an entirely new ATM strategy with its own target/stop orders as if an ATM strategy template had been selected. However, in my logs I verified that the name of ChartControl.OwnerChart.ChartTrader.AtmStrategy was the selected *active* ATM strategy, not its template.

                      When trading manually, if an active ATM strategy is selected in ChartTrader or SuperDOM, then new orders placed manually participate in updating/canceling the quantities of the existing ATM target/stop orders. How can we get the programmatic orders to behave that way?

                      Comment


                        #12
                        Hello darkbluedove,

                        Thanks for your question.

                        I am not aware of any supported way to scale into active Atm strategies using AddOn Framework code. I'll leave this thread open for any community members to share their insight if they have had success, but I do not have any documentation or example code to reference how an AtmStrategySelectionMode can be used with AddOn Framework code.

                        Something to note as well, when we scale into an Atm strategy with Chart Trader or the SuperDOM, we see additional orders submitted with different OCO IDs (ref Orders tab.) Chart Trader/SuperDOM will consolidate these visually depending on the AtmStrategySelectionMode, but since we do not have control over order markers, I do not see a way forward to recreate this functionality with AddOn Framework code.
                        JimNinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_ChrisL View Post
                          Hello darkbluedove , thanks for your post.

                          This is possible in NinjaScript. I attached an example indicator that will submit a limit order at the price when you click the mouse. To detect if a keyboard key is pressed you can use IsKeyDown.

                          Edit: I noticed you have questions on the ChartTrader settings. You need to use the WPF Automation ID to get the correct object. There is an example of the idea here. The same concept applies for the other ChartTrader elements. You can look for the automation ID of a WPF object by using inspect.exe

                          Please let me know if you have any questions on this material.
                          I downloaded and installed this script. When I click above price, it sets a Buy Stop and Sell Limit order, but puts them both at the same price, so the position gets liquidated immediately. I tried various offset settings, and nothing changed. How can I change where the closing order is relative to the entry price?

                          Comment


                            #14
                            This morning I woke up and my sim account charts all have orange colored record of all the orders from last night when I was playing with this indicator. I can't delete them and they are cluttering my charts.

                            Comment


                              #15
                              Hello NTTrader33,

                              Can you post an image of what orange record you are referring to?

                              If you are having trouble with the pricing you would need to print out the prices you are seeing in the scripts LeftMouseDown method to see what prices are generated. The script you are using has LeftMouseDown method which controls the order submission and gathering prices.
                              JesseNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by funk10101, Today, 09:43 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post funk10101  
                              Started by pkefal, 04-11-2024, 07:39 AM
                              11 responses
                              37 views
                              0 likes
                              Last Post jeronymite  
                              Started by bill2023, Yesterday, 08:51 AM
                              8 responses
                              44 views
                              0 likes
                              Last Post bill2023  
                              Started by yertle, Today, 08:38 AM
                              6 responses
                              26 views
                              0 likes
                              Last Post ryjoga
                              by ryjoga
                               
                              Started by algospoke, Yesterday, 06:40 PM
                              2 responses
                              24 views
                              0 likes
                              Last Post algospoke  
                              Working...
                              X