Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting Strategy Defaults

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

    #46
    Will this work?

    Will this work?

    [Description("Entries Per Direction")]
    [Category(
    "Order Handling")]
    publicint EntriesPerDirection
    {
    get { return entriesPerDirection; }
    set { base.EntriesPerDirection=entriesPerDirection;}
    }

    So should I also take out EntriesPerDirection under initialize()?

    Comment


      #47
      Default Contract

      zweistein,

      Do you know if it is possible to set the "Instrument" using the same method as above?


      [Description(
      "Instrument")]
      [Category(
      "Data Series")]
      public string Instrument
      {
      get { return contract; }
      set { base.Instrument=contract;}
      }

      The above code generates an error:
      Cannot convert type string to NinjaTrader.Cbi.Instrument

      Comment


        #48
        Set Default Instrument

        Josh/zweistein,

        I was able to get the Instrument to default to "NULL" (blank) and kill the Type/Value for when the strategy starts by doing the following:

        VARIABLES
        private NinjaTrader.Cbi.Instrument contract = null;

        INITIALIZE()
        DataSeriesConfigurable = false;

        PROPERTIES
        [Description("Instrument")]
        [Category(
        "Data Series")]
        public NinjaTrader.Cbi.Instrument Instrument
        {
        get { return contract; }
        set { base.Instrument=contract;}
        }

        How can I pass the instrument value to replace Null? As it stands, I am simply adding the contract I want to trade and trying to kill the initial instrument, but ideally, I would like to set the instrument which I believe is not possible according to Ray's post.

        UPDATE:
        I tested it and it will still use the default intrument that is first in your list, or persisting from last strategy. Any suggestions? FYI, tested the code and it is operating correctly other than what is outlined in this update.

        UPDATEIII:
        Disregard II, can't access FullName until after initialize. Makes sense.

        UPDATE II:
        I tried this, but when I use

        private NinjaTrader.Cbi.Instrument.FullName contract = "ES 06-09;

        I get an error saying FullName does not exist for Cbi.Instrument. As per below, it should work? Help?? lol.

        Definition
        Returns the full NinjaTrader name of an instrument. For futures, this would include the expiration date. The June S&P 500 Emini contract full name is "ES 06-07".


        Property Value
        A string representing the full name of the instrument.


        Syntax
        Instrument.FullName


        Property Of
        Custom Indicator, Custom Strategy


        Additional Access Information
        This property can be accessed without a null reference check in the OnBarUpdate() event handler. When the OnBarUpdate() event is triggered, there will always be an Instrument object. Should you wish to access this property elsewhere, check for null reference first. e.g. if (Instrument != null)

        Last edited by r2kTrader; 05-21-2009, 06:14 PM.

        Comment


          #49
          Instrument is for sure a complex class with more variables to it than we know. So I would leave that in the NT framework.

          have you tried something like

          #Variables
          string contract = "ES 06-09";



          #Properties
          [Description("Instrument")]
          [Category(
          "Data Series")]
          public NinjaTrader.Cbi.Instrument Instrument
          {
          get { return base.Instrument; }
          set {

          foreach(Instrument I in base.InstrumentList) {
          if(I.FullName==contract) base.Instrument=I;
          }
          }

          Common sense tells me there must be an InstrumentList in NT, and then you can also iterate through it.

          So I would debug and try to find the exact name of such an Instrument list. Please report if you find out

          Regards


          Comment


            #50
            Originally posted by zweistein View Post
            Instrument is for sure a complex class with more variables to it than we know. So I would leave that in the NT framework.

            have you tried something like

            #Variables
            string contract = "ES 06-09";


            #Properties
            [Description("Instrument")]
            [Category(
            "Data Series")]
            public NinjaTrader.Cbi.Instrument Instrument
            {
            get { return base.Instrument; }
            set {

            foreach(Instrument I in base.InstrumentList) {
            if(I.FullName==contract) base.Instrument=I;
            }
            }

            Common sense tells me there must be an InstrumentList in NT, and then you can also iterate through it.

            So I would debug and try to find the exact name of such an Instrument list. Please report if you find out

            Regards

            From a first glance, other than making sure we checked to see if the contract exists, it's not really different than just saying "base.Instrument=contract", no?

            Anyway, there is no InstrumentList, but there is Instruments (with the s) and that did compile, but is not doing anything.

            [update]
            forgot to post code:

            [Description("Instrument")]
            [Category(
            "Data Series")]
            public NinjaTrader.Cbi.Instrument Instrument
            {
            get { returnbase.Instrument; }
            set {
            foreach(Instrument I inbase.Instruments)
            {
            if(I.FullName==contract) base.Instrument=I;
            }

            }
            }

            Comment


              #51
              contract is a simple string now!

              One needs to find the undocumented Instrument Manager Instrument list.

              This is different from the Instruments which are set by NT only at Initialize() after you call Add("ES 12-06");

              Something not so easy to find, and NT support will not tell you because it means a myriad of more questions.

              If you find out, please let us know

              regards

              Comment


                #52
                Do not do this!

                [Description("Instrument")]
                [Category(
                "Data series")]
                publicstring Instrument
                {
                get { return contract; }
                set { base.Instrument.MasterInstrument.Name=contract; }

                // foreach(Instrument I in base.Instruments)
                // {
                // if(I.FullName==contract) base.Instrument=I;
                // }

                }

                Lol, it will rename your contracts to whatever you set value contract to.

                Now my ZB, YM and ZN shows up as "ES 06-09 06-09" in the Instrument List, lol. I am going to rename them back and fix instrument list. I thought I had cracked the case as it seemed like it was working. But it changed the "name" not the actual contract.

                Comment


                  #53
                  Originally posted by zweistein View Post
                  contract is a simple string now!

                  One needs to find the undocumented Instrument Manager Instrument list.

                  This is different from the Instruments which are set by NT only at Initialize() after you call Add("ES 12-06");

                  Something not so easy to find, and NT support will not tell you because it means a myriad of more questions.

                  If you find out, please let us know

                  regards
                  After thinking this through I see the need for the loop. It's a way to apply the proper instrument without knowing the actual "id". This was necessary because we can't make a string and instrument. lol. Let me keep going, I think it's possible. Heck, if I was able to RENAME my instruments from within my code, then certainly I can set the default instrument, lol.

                  Comment


                    #54
                    Instrument.MasterInstrument.Name = contract;

                    The above is a no-no, it will just rename the Name of the MasterInstrument in your Instruments list to the value of contract variable.

                    Not a good idea, lol.

                    Comment


                      #55
                      It is not a good idea to coerce the instrument from within a strategy .

                      Remember, you have 2 ways to open a strategy: first, from the strategy tab, and second from the chart window.

                      Using the chart window the instrument property is omitted in the parameters fields, for obvious reasons as you are supposed to apply the strategy to the instrument of the chart.

                      Therefore I would say that the only choice you have is:

                      OnBarUpdate(){
                      if(Instrument.FullName!="ES 06-09) return;
                      ...

                      here comes your code


                      }


                      regards

                      Andreas

                      P.S. Not sure what still to expect from this trading day... maybe there will be a relief rally after bernanke? I am not so convinced in this, so if then I will put little money in such a trade. Everybody seems on holidays, so better wait for monday

                      Comment


                        #56
                        So,

                        just to mention: I will not contribute more, because usually I see the questions from other people, then I become curious and I want to try out and I want to help also. But fact is that when I am active in this forum I am NOT disciplined enough for trading.
                        In the end of the day I loose concentration on my own trades, - today I was waiting for the FGBL to break the 120, entered 2 times but always out of the trades with nothing, and now finally 10 minutes ago the expected move, offcours without me.

                        Please understand that I have:

                        My own trading first,

                        my own strategy development second ( my questions are more scientific as I am trying to find a clustering algoritm that reproduces my trade experience. Currently QT Clustering stuff, we will see..

                        my private life also


                        So ,

                        r2kTrader,

                        you can do the following, it should work: I used a NetObject Spy to find out and a lot of common sense:

                        [XmlIgnore()]
                        [Description(
                        "Instrument.")]
                        [Category(
                        "Data series")]
                        public Instrument Instrument {
                        get {returnbase.Instrument ;}
                        set {
                        NinjaTrader.Cbi.InstrumentList il =NinjaTrader.Cbi.InstrumentList.GetObject(
                        "Default"); // other lists also possible
                        foreach(Instrument i in il.Instruments) {
                        if(i.FullName=="ES 06-09") base.Instrument=i;
                        }
                        }
                        }

                        Comment


                          #57
                          zweistein,

                          Thank you much.

                          For what it's worth, I will be happy to help you with your Clustering project.

                          Also, please remember, programmers don't always make the best traders and traders don't always make the best programmers. I have very strong market kung fu, reading markets I do well. (not bragging, I paid the cost).

                          If there is anything I can do to help you, let me know. I have a strong set of technical skills as it relates to technology and business. Feel free to pick my brain.

                          Comment


                            #58
                            hello,

                            seems to work well

                            any idea for obtain same thing (automatic setting) with Type (minute,...) and Value ?


                            That's so crazy this feature is not yet enable since begin in Ninja....

                            Comment


                              #59
                              Originally posted by Laurent68 View Post
                              any idea for obtain same thing (automatic setting) with Type (minute,...) and Value ?

                              That's so crazy this feature is not yet enable since begin in Ninja....
                              Laurent68, It's not crazy, it's just a design limitation. In a real-time program like NinjaTrader there are many considerations and constraints the developers have to satisfy in order to implement what sometimes seems like a simple change. The developers are pushing the envelope on a lot of their work, so I guess we have to have a little patience.

                              I made a recent (05-20-2009 04:02 PM) posting showing how to check for expected values. Also, look at r2kTrader's clever technique re Add'ing another timeframe to make sure the desired timeframe is available.

                              There's also a little more on this in another thread: http://www.ninjatrader-support2.com/...ead.php?t=1895 (which has my original code on how to check for an expected value, and how to use a special code setting to suppress certain parameter entries when starting the strategy.)

                              And more (on what not to do) in this thread:

                              (where I wrote some brilliant code where I was trying to work around this problem by dynamically selecting various timeframes during an Strategy Analyzer optimization -- but, although the code can be used to select a timeframe once, it won't work as intended in the optimizer using various timeframes to see which one is better.)

                              Comment


                                #60
                                Hello,

                                I have to make automatic trading on IB so I choose Ninja.
                                Feature about automatic setting was suggested more than 18 months ago, apparently always not available in ninja 7.
                                Order Gat (and more...) available in IB are not implemented on ninja.

                                Previous years according broker i trade full automatic trading (up to 15 strategy) on Tradestation and/or metatrader and/or Strategyrunner.
                                with ninja it's not automatic trading, it's assisted automatic trading with poor feature for that.

                                I have already code for check parameters, but i launch 12 strategy each morning, with different instrument, timeframe etc...

                                I need a software than i can trust.

                                Originally posted by KBJ View Post
                                Laurent68, It's not crazy, it's just a design limitation. In a real-time program like NinjaTrader there are many considerations and constraints the developers have to satisfy in order to implement what sometimes seems like a simple change. The developers are pushing the envelope on a lot of their work, so I guess we have to have a little patience.

                                I made a recent (05-20-2009 04:02 PM) posting showing how to check for expected values. Also, look at r2kTrader's clever technique re Add'ing another timeframe to make sure the desired timeframe is available.

                                There's also a little more on this in another thread: http://www.ninjatrader-support2.com/...ead.php?t=1895 (which has my original code on how to check for an expected value, and how to use a special code setting to suppress certain parameter entries when starting the strategy.)

                                And more (on what not to do) in this thread:

                                (where I wrote some brilliant code where I was trying to work around this problem by dynamically selecting various timeframes during an Strategy Analyzer optimization -- but, although the code can be used to select a timeframe once, it won't work as intended in the optimizer using various timeframes to see which one is better.)

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                648 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                369 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                108 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                572 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                573 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X