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

Adding user defined contacts

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

    Adding user defined contacts

    I want to add a contract to a strategy from a user input.


    I am pretty sure its not supported but I think I saw a reference sample somewhere but cant find it. Could someone point me in the correct direction?

    Also is it possible to expose a list of all instruments available in Ninjatrader?

    #2
    Hello GKonheiser,

    When you mention you want to add a contract to a strategy by a user input, are you saying you want to control the quantity of each order?

    If so, in the strategy parameters set 'Set order quantity' to 'by default quantity' and set Default quantity to the number of contracts you would like each trade size to be.


    I am not aware of a way to list all instruments in the Instrument Manager.
    It is not supported to do so, but it is possible to list all instruments in an instrument list (such as the Default instrument list, or the NASDAQ 100 instrument list.

    This is unsupported code
    Code:
    NinjaTrader.Cbi.InstrumentList list = NinjaTrader.Cbi.InstrumentList.GetObject("Custom");
    if (list != null)
    {
    foreach (Instrument i in list.Instruments)
    {
    Print(i.FullName);
    }
    }
    else
    {
    //Log("AddInstrumentsByListExample: There is no instrument list named Custom", LogLevel.Information);
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Sorry it was badly worded. What I meant was I want the user to input a product name in Strategy properties and then add that contract in the script, so if user entered es then I would add es in OnInitialize?

      Comment


        #4
        Hello GKonheiser,

        Yes, though this is not supported to do so, you can add a data series to a script using the name specified by a user input.

        Create a private and public variable set using the variable type of string.

        private string secondarySeries;

        [Description("Name of secondary data series")]
        [GridCategory("Parameters")]
        public string SecondaryDataSeries
        {
        get { return secondarySeries; }
        set { secondarySeries = value; }
        }


        Then in Initialize() add with
        Add(secondarySeries, PeriodType.Minute, 1);
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Rogers101, 05-05-2024, 11:30 AM
        8 responses
        30 views
        0 likes
        Last Post Rogers101  
        Started by llanqui, Today, 07:04 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by cmtjoancolmenero, 04-25-2024, 03:58 PM
        20 responses
        114 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by knowmad, Today, 03:52 AM
        1 response
        20 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by llanqui, Yesterday, 03:51 PM
        5 responses
        23 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X