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:



            Let me know if I can be of further assistance.

            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, 02: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 jclose, Today, 09:37 PM
                0 responses
                5 views
                0 likes
                Last Post jclose
                by jclose
                 
                Started by WeyldFalcon, 08-07-2020, 06:13 AM
                10 responses
                1,413 views
                0 likes
                Last Post Traderontheroad  
                Started by firefoxforum12, Today, 08:53 PM
                0 responses
                11 views
                0 likes
                Last Post firefoxforum12  
                Started by stafe, Today, 08:34 PM
                0 responses
                11 views
                0 likes
                Last Post stafe
                by stafe
                 
                Started by sastrades, 01-31-2024, 10:19 PM
                11 responses
                169 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Working...
                X