Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to access the Instrument a strategy is working on ?

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

    How to access the Instrument a strategy is working on ?

    When i add a new strategie using the panel i select my instrument but inside the ninjascript if i call Instrument.FullName i always get the first instruments of my Book not the one the strategy is configured for

    Can someone share a piece of code with me, i'm a beginner.

    Thank you for any help.

    Robert

    #2
    In fact it seems that the Instrument.FullName is initialized to default name in the Initialize method and to the configured instrument only when OnBarUpdate() is called which is kind of weird for me that initialize do not initialize.

    Thank you.

    Comment


      #3
      Solido, please post the code you're using - the accessed instrument object will be populated when the OnBarUpdate() is called the first time as the strategy is applied - http://www.ninjatrader-support.com/H...tFullName.html

      Comment


        #4
        Here was my missconception

        Code:
        protected override void Initialize() {
                CalculateOnBarClose = true;
        	Log("Configuring Order "+ Instrument.FullName, LogLevel.Information);  
        }
        When i add the strategy and configure it with let's say : FGBL 10-09,
        the first log will be C 10-09 which is the first instrument in my Book.

        I then need to start the run of the strategy to really log FGBL 10-09 which
        confuse me in my test.

        I'm an experienced programmer but new to the NT Platform and i've to setup a multi-account multi-broker multi-instrument tools. To get this done my strategy will parse an external order file and log that the configured instrument match the signal order.

        So the first log WILL BE totally confusing for my traders. The script is working but the fact that initialize is called twice (when added and runned) can make lot of noise in the Log.

        Thank you again for any piece of advices.

        Robert

        Comment


          #5
          Solido, the Initialize() can be called up to 3 times I believe. Also please test with the FGBL 12-09, as October one does not exist, it uses quarterly cycle.

          To get around this, why not call this on the first OnBarUpdate() bar one time?

          Comment


            #6
            I already use the FGBL 12-09, i was a mistake in my previous post.

            Yes i will work on the first call of OnBarUpdate() it's just tricky for a basic stuff because i have to declare some test case. Maybe for next release of NT ?

            Thank you for your help Bertrand.

            Robert.

            Comment


              #7
              Thanks for the suggestion, you can check Post # 16 from this thread here for an idea to workaround the Initialize() being called multiple times - http://www.ninjatrader-support2.com/...ad.php?t=20470

              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