• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

UserDefinedMethods

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

    UserDefinedMethods

    Hi,

    I am trying to move some code from a strategy into UserDefinedMethods as I have found I now need it in additional strategies.

    This code will be called from various timeframes that will not be known by the method in advance and those dataseries will normally be a secondary series within the calling strategy.

    Is there a way to pass in only one data series instead of 4 (OHLC)? For example, if I passed in only the BarsInProgress value would the UserDefinedMethods code be able to use that to access the correct dataseries?

    I am also working under the assumption that the UserDefinedMethod's variables have their own scope and persist between calls or is the scope somehow related to the scope of the calling strategy?

    Thanks
    Scott

    #2
    Scott, unfortunately you would need to process this code in the strategy itself as you can't dynamically Add() series - the needed series need to be hardcoded into the strategy / indicator Initialize().
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks for getting back to me. If I know ahead of time there are only a couple of timeframes I use, could I add them in the strategy and then pick between them with a parameter at runtime?

      If that is possible is there any performance hit doing it that way?

      Scott

      Comment


        #4
        This would be possible, add the ones you intend using and then pick from the BarsArray / BIP as needed. It would impact performance as objects are added that might end up not being needed, but best is to test on your strategy and individual system setup.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Bertrand, thanks for the information. I assume if these are all the same instrument any BIP issue would be limited FirstTickOfBar and referrencing the right OHLC by index; is that correct?

          It would also seem the performance issue would be mimimal as the instruments will always be the same.

          Scott

          Comment


            #6
            Hello,

            Yes this is how you would do it and no issue there.

            You will need to is BIP as described below:

            http://www.ninjatrader.com/support/h...nstruments.htm

            Let me know if I can be of further assistance.
            BrettNinjaTrader Product Management

            Comment


              #7
              Brett, can you use a DataSeries in a UserDefinedMethod? Since it is a partial class can you initialize the dataseries used by the method in the calling strategy's initialize event and would it have to be public to be seen by the method?

              I tried passing a dataseries into the method but then I get a message saying NinjaTrader cannot run the strategy because it cannot serialize the parameter because it does not have a parameterless constructor.

              I am a fairly decent programmer but this has me stumped. I have a function that uses OHLC and some dataseries variables. I need to move that to a UserDefinedMethod if possible. Can this be done; I am currently chasing my tail.

              Thanks Scott
              Last edited by ScottB; 09-28-2010, 01:26 PM.

              Comment


                #8
                I stopped and restarted NinjaTrader, passed everything by reference and suddenly life is good.

                Thanks
                Scott

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by frankduc, Today, 07:26 AM
                0 responses
                2 views
                0 likes
                Last Post frankduc  
                Started by chnh1, Yesterday, 11:51 PM
                1 response
                16 views
                0 likes
                Last Post NinjaTrader_PaulH  
                Started by Jasper99, Yesterday, 10:29 PM
                1 response
                29 views
                0 likes
                Last Post NinjaTrader_ChrisSch  
                Started by Jasper99, Yesterday, 09:50 PM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_ChrisSch  
                Started by StevenNelson, Yesterday, 05:57 PM
                1 response
                16 views
                0 likes
                Last Post NinjaTrader_Marco  
                Working...
                X