Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Accessing the periodtype & value of strategy

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

    Accessing the periodtype & value of strategy

    Hi,

    I'm trying to add another symbol to my strategy in the initialize section. I would like to have the symbol added with the same periodtype and periodvalue than the symbol for which the strategy runs.

    I'm now using a parameter, but the value of the parameter is not automaticly in sync.

    How can I access them, because initialize will not accept Bars.Periodtype.

    #2
    Hi, unfortunately symbols can't be added dynamically.

    Comment


      #3
      I now have:
      Add(strInstr, bPeriodtype, bValue)

      and on the parameterform I give the variables a value.
      I found the NinjaTrader.Data.PeriodType enum. What is the enum for a symbollist?

      Comment


        #4
        Unfortunately this is not supported. You just have to type in string values for the instrument you want.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          To match the PeriodType and Period selected in the Strategy use the following code in Initialize()

          string instrument = "^SP500";
          PeriodType periodType = (PeriodType) Enum.Parse(
          typeof(PeriodType), BarsPeriod.Id.ToString());
          Add(instrument, periodType, BarsPeriod.Value);

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CaptainJack, 05-29-2026, 05:09 AM
          0 responses
          335 views
          0 likes
          Last Post CaptainJack  
          Started by CaptainJack, 05-29-2026, 12:02 AM
          0 responses
          211 views
          0 likes
          Last Post CaptainJack  
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          196 views
          1 like
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          288 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          245 views
          0 likes
          Last Post CarlTrading  
          Working...
          X