• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dictionary

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

    #16
    Originally posted by koganam View Post

    You use brackets, not braces, when you declare and initialize a struct.

    Like so:
    Code:
    StockEntry ("ABC", PeriodType.Minute, 1, 0)
    The keyword new is not mandatory.
    Thanks for writing that all out. So I'm not needing List any longer?...
    List<StockEntry> _stocks = new List<StockEntry>();
    or any kind of Add?...
    _stocks.Add(StockEntry("ABC", PeriodType.Minute, 5, 0));


    I tried using just this...
    StockEntry("ABC", PeriodType.Minute, 5, 0);
    But got the error "StockEntry is a 'type' but used like a 'variable' "
    So I looked at your reference and this below seemed to work, should I use this?...
    StockEntry stockentry1 = new StockEntry("ABC", PeriodType.Minute, 5, 0);
    Last edited by zachj; 09-22-2013, 07:17 PM.

    Comment


      #17
      Originally posted by zachj View Post
      Thanks for writing that all out. So I'm not needing List any longer?...
      List<StockEntry> _stocks = new List<StockEntry>();
      or any kind of Add?...
      _stocks.Add(StockEntry("ABC", PeriodType.Minute, 5, 0));


      I tried using just this...
      StockEntry("ABC", PeriodType.Minute, 5, 0);
      But got the error "StockEntry is a 'type' but used like a 'variable' "
      So I looked at your reference and this below seemed to work, should I use this?...
      StockEntry stockentry1 = new StockEntry("ABC", PeriodType.Minute, 5, 0);
      StockEntry("ABC", PeriodType.Minute, 5, 0); is an expression, not a statement, so should not be on a line by itself: you use it as an assignment subject.

      StockEntry stockentry1 = new StockEntry("ABC", PeriodType.Minute, 5, 0); is a statement, and a valid one to assign and name a specific StockEntry struct.

      Whether you want to put the structs in a list really depends on what you want to do. I simply gave you the statements/expressions that give you the ability to create the necessary objects. I did suggest that you may want to use a list of structs. I simply showed you how to create the structs that you might want to track.

      You can name the structs before you store them, or you can store them directly, and name and assign them when you are ready to use them, after accessing them by their index in the List<>. The struct is simply an object that has, in one place, all the properties that you want to track.

      Comment


        #18
        Originally posted by koganam View Post
        StockEntry("ABC", PeriodType.Minute, 5, 0); is an expression, not a statement, so should not be on a line by itself: you use it as an assignment subject.

        StockEntry stockentry1 = new StockEntry("ABC", PeriodType.Minute, 5, 0); is a statement, and a valid one to assign and name a specific StockEntry struct.

        Whether you want to put the structs in a list really depends on what you want to do. I simply gave you the statements/expressions that give you the ability to create the necessary objects. I did suggest that you may want to use a list of structs. I simply showed you how to create the structs that you might want to track.

        You can name the structs before you store them, or you can store them directly, and name and assign them when you are ready to use them, after accessing them by their index in the List<>. The struct is simply an object that has, in one place, all the properties that you want to track.
        I think that I need to use a List. What I'm trying to do is just be able to Count & track the # of times each stock has Entered Long in a multi-instrument scipt and ultimately keep 10minutes between trades per individual instrument. So if there's been more than 1 trade it will then go to BarsSinceEntry() to make sure two 5min bars have elapsed before it can enter another trade.

        The only way I can have an error NOT pop up is by adding to the list in this way below. Does this look acceptable?...
        List<StockEntry> _stocks = new List<StockEntry>();
        protected override void Initialize()
        {
        _stocks.Add(new StockEntry { Name = "ABC", Period = PeriodType.Minute, Value = 5, Count = 0 } );
        //other stock added here..
        }

        Comment


          #19
          Originally posted by zachj View Post
          I think that I need to use a List. What I'm trying to do is just be able to Count & track the # of times each stock has Entered Long in a multi-instrument scipt and ultimately keep 10minutes between trades per individual instrument. So if there's been more than 1 trade it will then go to BarsSinceEntry() to make sure two 5min bars have elapsed before it can enter another trade.

          The only way I can have an error NOT pop up is by adding to the list in this way below. Does this look acceptable?...
          List<StockEntry> _stocks = new List<StockEntry>();
          protected override void Initialize()
          {
          _stocks.Add(new StockEntry { Name = "ABC", Period = PeriodType.Minute, Value = 5, Count = 0 } );
          //other stock added here..
          }
          Certainly valid syntax.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ralett, Today, 07:29 PM
          1 response
          2 views
          0 likes
          Last Post NinjaTrader_Marco  
          Started by bboyle1234, Today, 10:46 PM
          0 responses
          1 view
          0 likes
          Last Post bboyle1234  
          Started by swcooke, Today, 04:29 PM
          0 responses
          4 views
          0 likes
          Last Post swcooke
          by swcooke
           
          Started by bboyle1234, Today, 04:27 PM
          0 responses
          2 views
          0 likes
          Last Post bboyle1234  
          Started by swcooke, Today, 03:31 PM
          2 responses
          11 views
          0 likes
          Last Post swcooke
          by swcooke
           
          Working...
          X