Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Create variable in private void ()

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

    Create variable in private void ()

    Hello,

    I've got this:

    PHP Code:
        for (int x 1;   x++)
                { 
                    
    DoStuff(x);
                } 
    Where x is barsinprogress (I added two symbols: SPY, DIA).
    PHP Code:
            private void DoStuff(int x )

        
    //in here i got two integers a, b;
      

    Now when the first symbol (loop x=1) is done, it has stored something in integer a and b.
    Now the second symbol is on, DIA, but now it will overwrite something what is stored in a by SPY.

    How can I overcome this? So that SPY and DIA have is own 'a' and 'b'. (I think, it should be in the loop i.e. It creats a1, b1, a2, b2 as integers/doubles, but how do I do that?)

    Someone who has a suggestion for me?

    Thanks

    #2
    Hello no111,
    You can create a List of your variable and store the values there.
    http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx

    Unfortunately its more of C# query and beyond what we could support.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Originally posted by no111 View Post
      Hello,

      I've got this:

      PHP Code:
          for (int x 1;   x++)
                  { 
                      
      DoStuff(x);
                  } 
      Where x is barsinprogress (I added two symbols: SPY, DIA).
      PHP Code:
              private void DoStuff(int x )

          
      //in here i got two integers a, b;
       

      Now when the first symbol (loop x=1) is done, it has stored something in integer a and b.
      Now the second symbol is on, DIA, but now it will overwrite something what is stored in a by SPY.

      How can I overcome this? So that SPY and DIA have is own 'a' and 'b'. (I think, it should be in the loop i.e. It creats a1, b1, a2, b2 as integers/doubles, but how do I do that?)

      Someone who has a suggestion for me?

      Thanks
      Easiest way is to have 2 more integers, so that each set is separate and populated depending on the value of x.

      private void DoStuff(int x )
      {
      if (x == 1) {//populate a1 and b1}
      else if (x == 2) {//populate a2 and b2}
      }

      Comment


        #4
        Originally posted by koganam View Post
        Easiest way is to have 2 more integers, so that each set is separate and populated depending on the value of x.

        private void DoStuff(int x )
        {
        if (x == 1) {//populate a1 and b1}
        else if (x == 2) {//populate a2 and b2}
        }
        Thank you for an answer. My idea was to add more than 2 symbols, for example 10 ETF's so I can measure the performance of the strategy better (with combined results if you backtest a basket, you don't get a equity curve for example).

        Any ideas for that?

        Comment


          #5
          Originally posted by no111 View Post
          Thank you for an answer. My idea was to add more than 2 symbols, for example 10 ETF's so I can measure the performance of the strategy better (with combined results if you backtest a basket, you don't get a equity curve for example).

          Any ideas for that?
          You can use a bunch of suitably named variables or you can use Arrays to hold the two sets of values.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by jeronymite, 08-09-2020, 09:26 PM
          2 responses
          27 views
          0 likes
          Last Post koganam
          by koganam
           
          Started by Cicero, Today, 09:41 AM
          0 responses
          4 views
          0 likes
          Last Post Cicero
          by Cicero
           
          Started by Czarek, Today, 09:28 AM
          0 responses
          2 views
          0 likes
          Last Post Czarek
          by Czarek
           
          Started by fut_practic, 08-11-2020, 05:01 PM
          1 response
          17 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by nordseven, 02-24-2017, 02:14 AM
          4 responses
          2,298 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X