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 CarlTrading, 03-31-2026, 09:41 PM
          1 response
          31 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, Yesterday, 02:41 AM
          0 responses
          14 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          22 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          40 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          34 views
          0 likes
          Last Post CarlTrading  
          Working...
          X