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

How to reference the Master Instrument in the Initialize() method?

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

    How to reference the Master Instrument in the Initialize() method?

    Hi,
    Can you advise how I would reference the Master Instrument in the initialize method for the purposes of multi time period strategy testing?

    This is what I have:
    protectedoverridevoid Initialize()
    {
    MainInstrument =
    "$EURJPY";
    Add(MainInstrument,PeriodType.Second,
    1, MarketDataType.Bid);


    I would prefer not to have to have to manually recode and recompile the strategy every time I want to test the strategy on a new instrument.

    Thanks for your time,
    Ian

    #2
    Originally posted by ianlav View Post
    Hi,
    Can you advise how I would reference the Master Instrument in the initialize method for the purposes of multi time period strategy testing?

    This is what I have:
    protectedoverridevoid Initialize()
    {
    MainInstrument =
    "$EURJPY";
    Add(MainInstrument,PeriodType.Second,
    1, MarketDataType.Bid);


    I would prefer not to have to have to manually recode and recompile the strategy every time I want to test the strategy on a new instrument.

    Thanks for your time,
    Ian
    Make it a string parameter, and expose the property so that you can change it from the PropertyGrid.

    Comment


      #3
      Hello Ian,

      Welcome to the NinjaTrader Support Forums!

      You may use the Instrument.FullName for this. For example:

      Code:
      Add(Instrument.FullName, PeriodType.Minute, 60, MarketDataType.Last);
      JCNinjaTrader Customer Service

      Comment


        #4
        Thank you for your reply. However, when I compile the change you suggest, it generates an error message that I can't resolve. Please see the attached image for details.

        Can you help further?

        Thanks,
        Ian
        Attached Files

        Comment


          #5
          koganam, thanks you for your input. I have tried what you suggested, but it does not appear to work. Because I am adding a data series from the initialize() method, it looks for the value as soon as I open the strategy tester, before I am able to enter a value in the property grid. I instead pulls in the default value for the parameter.

          Might there be anything else you can suggest?

          Thanks,
          Ian

          Comment


            #6
            It appears to be unsupported.





            But read this and the link in there






            Originally posted by ianlav View Post
            koganam, thanks you for your input. I have tried what you suggested, but it does not appear to work. Because I am adding a data series from the initialize() method, it looks for the value as soon as I open the strategy tester, before I am able to enter a value in the property grid. I instead pulls in the default value for the parameter.

            Might there be anything else you can suggest?

            Thanks,
            Ian

            Comment


              #7
              Originally posted by ianlav View Post
              koganam, thanks you for your input. I have tried what you suggested, but it does not appear to work. Because I am adding a data series from the initialize() method, it looks for the value as soon as I open the strategy tester, before I am able to enter a value in the property grid. I instead pulls in the default value for the parameter.

              Might there be anything else you can suggest?

              Thanks,
              Ian
              Not sure what you are saying here. The Plots and any Lines are setup in the Initialize() event, and their parameters can all be changed. Why do you think that any other parameter cannot be changed just because it is called in the Initialize() method? The PropertyGrid always shows the default value, when you first open the PropertyGrid, before you change the value. That is the purpose of a default value for the backing store.

              It sounds to me that the problem is in your implementation of the code, not a problem with how NT processes it?
              Last edited by koganam; 05-25-2013, 09:50 PM.

              Comment


                #8
                Hello ianlav,

                You syntax looks correct, but taking into account that it is also giving you a compile error on a commented out line (47) you may want to take a look at you full Initialize Method.

                Here is a compiled example.
                Attached Files
                JCNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Taddypole, 04-26-2024, 02:47 PM
                1 response
                10 views
                0 likes
                Last Post NinjaTrader_Eduardo  
                Started by futtrader, 04-21-2024, 01:50 AM
                6 responses
                58 views
                0 likes
                Last Post futtrader  
                Started by sgordet, Today, 11:48 AM
                0 responses
                4 views
                0 likes
                Last Post sgordet
                by sgordet
                 
                Started by Trader146, Today, 11:41 AM
                0 responses
                5 views
                0 likes
                Last Post Trader146  
                Started by jpapa, 04-23-2024, 07:22 AM
                2 responses
                19 views
                0 likes
                Last Post rene69851  
                Working...
                X