Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT7 Conversion Questions -- Indicator Ninjascript

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

    NT7 Conversion Questions -- Indicator Ninjascript

    Hello,

    anyone?

    the following apply to "how to" do in Ninjascript in an Indicator

    1) how to press the ChartTrader Close Button?

    2) How to get the selected Account from ChartTrader?

    3) How to submit an order from NinjaScript?

    I don't want to use the Right Click ChartTrader, it is too cumbersome for scalping....my NT7 code submits Limit Orders with one click at the mouse pointer.

    ================================================== ================================================== ========

    This last one in NT7 I had to use an OIF submission because there was no way to submit an order from Indicator Script. An OIF file is slow....there was some code on Big Mike Trading I used to bypass writing the OIF file to disk and it worked great. Is there anything like this in NT8? (Yes, I know it is not supported, but perhaps one of the smart C# guys can tell me?)

    // from BigMikeTrading.vvMiniTradePanel
    [DllImport("user32.dll")]
    public static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);​


    region SubmitOIF
    private void SubmitOIF()
    {
    // this will only be for a set price ctl left mouse or shft left mouse
    // other submissions by Hot Key
    submittedFrom = SubmitType.SetPrice;

    // Code provided by user BigMikeTrading.decs0057
    NinjaTrader.Server.AtiServer atiServer = NinjaTrader.Cbi.Globals.AtiServer;

    MethodInfo miProcessOif = typeof(NinjaTrader.Server.AtiServer).GetMethod( "ProcessOif", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static );

    if( miProcessOif != null )
    {
    object[] args = { OIF_Command };

    try
    {
    miProcessOif.Invoke( null, args );
    }
    catch (Exception ex)
    {
    msg = ("SubmitOIF Exception = " + ex );
    Print (msg);
    }
    }

    msg =
    Environment.NewLine +
    Common.DashLine +
    Environment.NewLine +
    OIF_Command +
    Environment.NewLine +
    Common.DashLine;

    Print (msg);
    }
    #endregion​

    ================================================== ================================================== ========


    Thanks

    #2
    Hello llanqui,

    You can use Account.Flatten() to close an instrument position.
    https://ninjatrader.com/support/help...t8/flatten.htm

    As well as use the Account to submit orders through an Addon or indicator.


    Below is a link to an example of getting the ChartTrader selected account.
    https://ninjatrader.com/support/foru...98#post1055898

    Where you have inquired:
    "How to submit an order from NinjaScript?"

    This does not specify strategy, indicator, or other type of addon script.

    Below is a link to an example of submitting an order through a NinjaScript Strategy.
    https://ninjatrader.com/support/foru...269#post802269

    As well as a link to an example of placing orders with button clicks in an indicator.
    https://ninjatrader.com/support/foru...18#post1126818

    Last, below is a link to a forum post with tips on porting scripts from NT7 to NT8.
    https://ninjatrader.com/support/foru...313#post490313
    Last edited by NinjaTrader_ChelseaB; 10-28-2022, 08:03 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you.

      This is all referring to Chart Trading. Not a background running Strategy....

      I don't want to attach a Strategy to the chart....if I can avoid it....would like that the Indicator be able to submit a Limit Order at a specific price, based on the current ChartTrader Account, Quantity, and ATM

      Ninja has the buttons on ChartTrader for order entry, and as well Hot Keys, but these are not for Limit Orders at a specific price...there is that ability to do that with the right-mouse-click, then select the order type....but this is too slow for fast scalping.

      Comment


        #4
        Also, your link to Flatten() refers to AddOn not an Indicator???

        I need the order entry to be from an Indicator....don't know if a strategy could be linked to an Indicator...the Indicator needs to initiate the order submission

        is there a way to couple the signal from an Indicator to a Strategy which will submit the order?

        the signal would need to be instantaneous with no delay

        ??

        NT8 still seems to follow the same design as NT7 that does not give an Indicator access to the trade functions. Or, am I missing something??

        Comment


          #5
          Hello llanqui,

          Yes, you are able to run a NinjaScript Strategy on a chart and when applied to a chart, you will see any orders, drawing objects, etc drawn by the NinjaScript Strategy.

          don't want to attach a Strategy to the chart....if I can avoid it
          You don't have to run a strategy. I supplied both example scripts because your post did not specific what kind of script. You just said "NinjaScript". NinjaScript comes in Strategies, Indicators, Drawing Tools, Bars Types, Chart Styles, Optimizer scripts, PerformanceMetrics, and Addon windows.

          Below is a link to the help guide on the different type of NinjaScripts.


          would like that the Indicator be able to submit a Limit Order at a specific price, based on the current ChartTrader Account, Quantity, and ATM​
          Are you finding the example I have provided you is inadequate for demonstrating how to place an order from an indicator? May I confirm you have reviewed the code for this?
          Please let me know what further information you need that is not demonstrated in the script.

          is there a way to couple the signal from an Indicator to a Strategy which will submit the order?

          the signal would need to be instantaneous with no delay
          Call the indicator from the strategy if you want information from an indicator in a strategy.
          Print(SMA(7)[0]); <-- this would print the SMA value from the SMA indicator if called from a strategy.

          NT8 still seems to follow the same design as NT7 that does not give an Indicator access to the trade functions. Or, am I missing something??
          No, this is not the case.
          The example I provided you places orders using the Account from the Addon approach to place orders.
          May I confirm you a have tested the script I provided you and reviewed the code?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            the other thing about needing to use the right mouse click - menu to submit a limit order ... is that the pop up menu obscures a portion of the chart...this is not good in a fast moving scalp environment because it distracts the eye/mind from the underlying price action....

            basically the market information is lost to the eyes in the moments that the pop up is being managed

            it would be wonderful if Ninja would add a way to simply click on the chart and submit the order

            I use

            control - left mouse click to submit a sell limit at the price at the pointer
            shift - left mouse click to submit a buy limit at the price at the pointer

            is this something you could do?

            Comment


              #7
              Hello llanqui,

              it would be wonderful if Ninja would add a way to simply click on the chart and submit the order
              There is already a way to do this...

              Below is a link to an example of capturing mouse clicks.


              I have already provided you an example of how to place orders from an indicator.


              Unfortunately, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. Further, we do not provide C# programming education services or one on one educational support in our NinjaScript Support department. This is so that we can maintain a high level of service for all of our clients as well as our associates.

              That said, through email or on the forum we are happy to answer any questions you may have about NinjaScript if you decide to code this yourself. We are also happy to assist with finding resources in our help guide as well as simple examples, and we are happy to assist with guiding you through the debugging process to assist you with understanding unexpected behavior.

              If you feel that coding this yourself is difficult, you can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our NinjaTrader Ecosystem team follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Ok, I'll review all before another posting.. I'm still in the NT7 mindset and .I have to learn how NT8 provides all this easier...thank you.

                Comment


                  #9
                  Ok, in the ChartOrderbuttonsExamples Indicator it seems is that I'm looking for to allow the direct submit, (similar to an OIF in NT7?), from an indicator


                  TriggerCustomEvent(o =&gt;
                  {
                  longLimitOrder = account.CreateOrder(Instrument, OrderAction.Buy, OrderType.Limit, OrderEntry.Manual, TimeInForce.Gtc, 1, Math.Min(Instrument.MasterInstrument.RoundToTickSi ze(sma1[0]), GetCurrentAsk() - 1 * TickSize), 0, string.Empty, "Long limit order", new DateTime(), null);
                  account.Submit(new Order[] { longLimitOrder });
                  }, null);​

                  In the past I spent quite a bit of time reading the NT 8 documentation, but was never clear about what can be done in an indicator and what cannot...confused...this helps clarify, thank you.

                  Comment


                    #10


                    that is listed under AddOn in the NinjaTrader documentation, which is why I assumed it would not work in an indicator....

                    Comment


                      #11
                      Hello llanqui,

                      The Addon approach tools can be used pretty much anywhere in any script. The idea for this, is the tools are isolated enough they can be used in a new custom window.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Ok, I was confused on this issue...thanks

                        Comment


                          #13
                          In NT7 an Indicator could not access the Strategy Namespace Methods for Order Management...and it had none of its own

                          glad to see that NT8 opened Indicator to be able to do trade functions...

                          actually, very happy about this because for me it was a major issue in NT7

                          will make my life simplier :-)

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          631 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          364 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          105 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          566 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          568 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X