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

Giving a strategy a UI...?

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

    Giving a strategy a UI...?

    Hi,

    first day real trading after weeks of development, my little Mr. Robot worked perfectly.

    Sadly, i got problems with some control setups, and the UI provided by Ninja just is not up to the task at all. THIS now, is not a complaint, rather my needs are special.

    In the end, I want to have:
    * My own log area. The output window is not usable, simply be cause it mixes the streams of multiple strategies
    * Some control area. THe straat should not run at special times. Stopping / restarting is painfull. I woul drather have something where I can with some buttons tell the strat to stay out, only go long / short etc.

    I think of doing my own window for that and reference it from the strategy, with the help of some helper code that wraps things up nicely.

    This would incidentally generate some "strategy control window" where the strategies can sign up for (i.e. must be coded), put their info into separate output streams and actually where there is some control interface were I can do the stuff said above.

    Anything AGAINST that approach or alternatives? Anyone else having similar means? My need mostly comes from my strategy being a fully automated intraday setup, and sometimes the market just does not work - and some of those things are known before (I.e. "stay out" before market news).

    #2
    NetTecture, good to hear the robot did its job well - unfortunately your needs would need custom coding to unsupported methods (which can result in code breaking in future releases).
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Just a tip

      Hi,

      I made a similar sort of program regarding your question±

      `some buttons tell the strat to stay out, only go long / short`

      Just create an if/statement where it looks for a particular txt file.

      if c:\long.txt exists then take longs
      if c:\short.txt exists then take shorts
      if c:\flat.txt exists then don't take any trades...

      it's simple but yet effective and fast.

      or:

      Last edited by Creamers; 08-01-2009, 05:39 AM.

      Comment


        #4
        Originally posted by NinjaTrader_Bertrand View Post
        NetTecture, good to hear the robot did its job well - unfortunately your needs would need custom coding to unsupported methods (which can result in code breaking in future releases).
        Ok, lets get in. What exactly IS allowed?

        I mean, I am fine with a lot.

        * Can I legally open windows? As long as I make sure they get closed?
        * Can I open and allocate a TCP port?
        * Remoting?

        The last two would allow me to have a separate control application.

        I Do not really like the file idea, because I would like something more - well - exposing more information.

        Surely you must have a documentation outlining the limits of what you allow Saying it is not allowed is fine, but your code refers to the C# documentation all the time. What permission set do you define as valid, in terms of CAS (Code Access Security)? Which part of legally defined C# am I allowed to use without risk?

        Comment


          #5
          NetTecture, there's a simple line we draw - what is supported by us in our help guide and forum samples here is supported. When you step out of this and decide to use C# and undocumented classes you're basically on your own and we assume that you're an experienced enough programmer to handle this. With 'code breaking' I meant that code that does for example work now, could need modifications to continue working in updated releases of NinjaTrader.
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Forms

            I don't know if this helps, but I found that dynamically creating forms in a strategy works fine. Use VS to create your forms and copy the code in the strategy. Definately make sure you cleanup the memory.

            Comment


              #7
              Ah, nice - will do. As you can see, between what Ninja says they support in the documentation, and what they are really supporting, there is a difference (Which personally I find not surprising - but seriously sad, programmers should becompetent enough to properly document where the supported stuff ends and all I did ask was their setups - .NET core information).

              Good to know that works. acutally will move a lot of stuff out into a dll, as it looks - I can put some forms in there Thanks for the info.

              Comment


                #8
                >> but seriously sad, programmers should becompetent enough to properly document where the supported stuff ends and all I did ask was their setups
                Not sure why you got confused. NT supports what is documented - which is what we call NinjaScript, anything else it not supported. Please let us know as you have any question about the documented NinjaScript. On anything beyond you are on your own and needed to make sure it still would compile/work on NT upgrades.

                Comment


                  #9
                  Originally posted by NinjaTrader_Dierk View Post
                  >> but seriously sad, programmers should becompetent enough to properly document where the supported stuff ends and all I did ask was their setups
                  Not sure why you got confused. NT supports what is documented - which is what we call NinjaScript, anything else it not supported. Please let us know as you have any question about the documented NinjaScript. On anything beyond you are on your own and needed to make sure it still would compile/work on NT upgrades.
                  What about all the examples you provide that ALREADY go beyond the documentation? Per your defintion elements such as file access already are totally unsupported But you do provide samples outside the documentation.

                  What about the little fact that some trivial baseline things are not documented, like the question whether event handlers have to be reentrant for multi threading? You talk of multiple threads calling into a strategy on more than one element, but provide no hint whether such calls to event handlers would be serialized, or whether the handlers have to be reentrant.

                  What about the fact that there is zero information available about how the threading model, assembly loading etc. are set up for strategies and/or indicators?

                  If I compare that to the level of quality available, for example, for ASP.NET - the differences in documentation are astonishing.

                  Comment


                    #10
                    >> What about all the examples you provide that ALREADY go beyond the documentation? Per your defintion elements such as file access already are totally unsupported But you do provide samples outside the documentation.
                    This is documented NinjaScript

                    >> What about the little fact that some trivial baseline things are not documented, like the question whether event handlers have to be reentrant for multi threading? You talk of multiple threads calling into a strategy on more than one element, but provide no hint whether such calls to event handlers would be serialized, or whether the handlers have to be reentrant.
                    Not supported are per my clarification

                    >> What about the fact that there is zero information available about how the threading model, assembly loading etc. are set up for strategies and/or indicators?
                    Not supported as per my clarification

                    Comment


                      #11
                      Forms

                      Sorry, I didn't mean to step in, but I wanted to clarify what I had said earlier for the benefit of those who are interested.

                      I added form variables to the strategy something like this:

                      Code:
                      private Form _frmTrades = new Form();
                      I then created code to configure the forms any way I need to. You can also add dynamic controls on the fly. Visual Studio will build most of the code for you. The below is just an example of one technique:

                      Code:
                       
                      private System.Windows.Forms.Label labelTime;
                       
                      // 
                      // labelTime
                      // 
                      labelTime = new System.Windows.Forms.Label();
                      labelTime.AutoSize = true;
                      labelTime.Location = new System.Drawing.Point(98, 9);
                      labelTime.Name = "labelTime";
                      labelTime.Size = new System.Drawing.Size(14, 14);
                      labelTime.Text = "#";
                       
                      _frmTrades.Controls.Add(labelTime);
                       
                      _frmTrades.SuspendLayout(); // force a redraw
                      Any of the above code should be done once at initialization.

                      Finally, it is important to make sure that you clean up.

                      Code:
                       
                      #region Dispose
                        
                        public override void Dispose()
                        {
                         _frmTrades.Close();
                         _frmTrades = null;
                         
                         base.Dispose();
                        }
                        
                        #endregion
                      The only downside I have had is in testing my strategies with the market replay. You have to make sure you close and remove the strategy before jumping around.

                      I don't add forms all that often (NT gives you logging and debugging which works for most scenarios), but when I really do need something that is not built-in, this technique works for me.

                      I hope this helps!
                      Michael

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by giulyko00, Today, 11:49 AM
                      2 responses
                      11 views
                      0 likes
                      Last Post giulyko00  
                      Started by Aviram Y, Today, 06:03 AM
                      2 responses
                      10 views
                      0 likes
                      Last Post Aviram Y  
                      Started by FishTrade, Today, 03:42 PM
                      0 responses
                      1 view
                      0 likes
                      Last Post FishTrade  
                      Started by Richozzy38, Today, 01:06 PM
                      3 responses
                      14 views
                      0 likes
                      Last Post Richozzy38  
                      Started by ttrader23, Today, 09:04 AM
                      2 responses
                      12 views
                      0 likes
                      Last Post ttrader23  
                      Working...
                      X