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

EnterLongLimit() from an Indicator? (instead of a Strategy)

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

    EnterLongLimit() from an Indicator? (instead of a Strategy)

    Is it possible to call order related functions (such as EnterLongLimit()) from an "Indicator", instead of a "Strategy"?

    It seems to be a chicken and the egg thing. I want to keep Chart Trader enabled, so this means I can't use a "Strategy". But if I use an Indicator, these methods don't seem exposed.

    Is there a trick that I'm missing? Possible to call them via NinjaTrader.Strategy library from within an Indicator?

    EDIT: I tried to do something like this, but it didn't seem to work
    PHP Code:
    NinjaTrader.Strategy.AtmStrategy ATMs = new NinjaTrader.Strategy.AtmStrategy();
    ATMs.EnterLongStopLimit(...);
    //OR
    ATMs.AtmStrategyCreate(...); 
    Any help is greatly appreciated!
    Daniel
    Last edited by neoikon; 05-15-2015, 09:32 AM.

    #2
    I haven't been able to use the NS order methods via an Indicator due to what you just described.

    They only way I have been to get around this it to get the Account and set it an Account Object so that I have the CreateOrder() method available. There are a lot of threads on here about getting the Account object and doing this. This is really on the unsupported side of NT but they might a link or two to get you pointed in the right direction

    Comment


      #3
      Hello,

      In addition to what calinus mentioned, there are two scripts on our File Sharing forum that may interest you. One will place buttons on a chart with Chart Trader disabled, and the other will draw order lines on the chart with Chart Trader enabled. You could use either of these as-is, or use the code as a reference to develop your own versions:

      http://www.ninjatrader.com/support/f...d=5&linkid=490

      http://www.ninjatrader.com/support/f...d=5&linkid=666

      In the current beta version of NinjaTrader 8, you are able to enable strategies on charts with Chart Trader enabled, so there is a light at the end of the tunnel on this particular issue.
      Last edited by NinjaTrader_DaveI; 05-15-2015, 09:46 AM.
      Dave I.NinjaTrader Product Management

      Comment


        #4
        Thank you both for the replies!

        On a related note, I tried the code below, but it seems to have placed an order out there that I cannot delete or manipulate from the chart.

        PHP Code:
        Account myAccount NinjaTrader.Cbi.Globals.Accounts.FindByName(AccountName);
        myAccount.CreateOrder(...); 
        The order shows up on the "Orders" tab, but won't let me delete it. I even added and called "myAccount.CancelAllOrders(Instrument);" and "myAccount.Orders[0].Cancel();" and it won't budge.

        Price has even touched this many times and it won't fill, which is odd too.

        How can I forcefully cancel this order? (This is only a SIM account)

        ----------------

        I had already added my buttons to the Toolbar, but was trying to get them to actually place the Limit order out there, based on my indicator's logic.

        What I really want is for it to place the BuyStopLimit order out there... and that's it. Then I want to be able to manipulate it, cancel it, etc. from the chart as if I had manually right-clicked and placed a "Buy Stop Limit" order.

        Your links have put in the right direction, thanks!

        Comment


          #5
          Hello,

          This kind of methodology is technically unsupported in NinjaTrader 7, but this thread will remain open for any other users who have experience creating something like this to reply and add their two cents.
          Dave I.NinjaTrader Product Management

          Comment


            #6
            I have a working example just not in front of me at the moment.

            I will get one for you hopefully by tonight.

            Comment


              #7
              Ok going through it you need to submit the order after you create it.

              Order ord = account.CreateOrder(...);
              ord.Submit();

              That should submit it and get it working. allowing you to manipulate it and cancel it.

              I've attached a working example for you as well
              Attached Files

              Comment


                #8
                Originally posted by Calonious View Post
                I've attached a working example for you as well
                Thanks! The big step that I was missing was the "ord.Submit();" step.

                I had an order out there that I could not manipulate via the chart (due to not submitting it in my previous attempts), but I was able to find the specific order, via code, and cancel it.

                Thanks again!

                Comment


                  #9
                  Thank you again for the example CS file.

                  I see that you are calling "Strategy.AtmStrategyCreate()" after you create the buy order. How is this connected to the order created with CreateOrder()?

                  Once the order is filled, I'd like it to trigger an ATM strategy. I'm not sure if this is 2 separate steps or part of one step.

                  Is there a way to call a pre-defined ATM strategy by name? Should this replace the CreateOrder() call? Or is it a separate step afterward?

                  Thanks again!

                  Comment


                    #10
                    Its not as easy as that unfortunately. I do have something that I can send you via PM as it does get dirty in the code.

                    Comment


                      #11
                      Sent, let me if that works for you!

                      Comment


                        #12
                        Hi Calonious, I have similar question. I want to place ATM StopLimit order from indicator. From the sample that you have, you were using CreateOrder followed with ATMStrategyCreate()... I tried to modify it by remove the CreateOrder and just follow the ATMStrategyCreate (following how I would use in Strategy script)... but seems like after clicking the button, nothing happen.

                        Can enlighten me how to enter an ATM strategy from indicator? If you have a sample cs to demonstrate it that would be awesome. Thanks!

                        My test code:
                        private void tsBtn_Click(object sender, EventArgs e)
                        {
                        string sTrATM_TemplateName ="TREND-ATM";
                        double dBlEntryTrigLvl = 2999;

                        dBlEntryTrigLvl = High[0] + (10 * TickSize);

                        Strategy.AtmStrategyCreate(OrderAction.Buy, OrderType.StopLimit, dBlEntryTrigLvl, dBlEntryTrigLvl, TimeInForce.Day, Strategy.GetAtmStrategyUniqueId(), sTrATM_TemplateName, Strategy.GetAtmStrategyUniqueId());

                        }

                        Comment


                          #13
                          Hello chrishyewll,

                          Below is a link to an example of placing an order with an Atm Strategy through the addon approach (also used for indicators).


                          The Addon Framwork script also demonstrates this.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Thanks, ChelseaB. Unfortunately I need NT7 version... will this work for NT7 too?

                            Comment


                              #15
                              Hello chrishyewll,

                              Unfortunately, there is not support for NinjaTrader 7 to submit orders with Atm Strategies and this is not documented and there are no examples (that I am aware of).

                              This is a new set of features and documentation for NinjaTrader 8.

                              This thread will remain open for any community members that may know of undocumented methods of placing orders outside of a NinjaScript Strategy.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by swestendorf, Today, 11:14 AM
                              2 responses
                              5 views
                              0 likes
                              Last Post NinjaTrader_Kimberly  
                              Started by xiinteractive, 04-09-2024, 08:08 AM
                              4 responses
                              13 views
                              0 likes
                              Last Post xiinteractive  
                              Started by Mupulen, Today, 11:26 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post Mupulen
                              by Mupulen
                               
                              Started by Sparkyboy, Today, 10:57 AM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by TheMarlin801, 10-13-2020, 01:40 AM
                              21 responses
                              3,917 views
                              0 likes
                              Last Post Bidder
                              by Bidder
                               
                              Working...
                              X