Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Data Collection Per Trade

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

    Data Collection Per Trade

    It would be great to be able to collect additional user-defined data on a per-trade basis. For example, I would love to collect volume data, indicator values, % price movements, etc. on the entry bar of a trade and show that data in the trades tab grid in the strategy analyzer results. That way, I could analyze volume, etc. on winning vs losing trades, etc.

    For example I could call something like this for each order entry:
    (IOrder) Order.AddCustomData("Volume", int, CurrentBarVolume)
    (IOrder) Order.AddCustomData("Pct Change", double, CurrentBarPriceChange)

    #2
    Originally posted by Anagoge View Post
    It would be great to be able to collect additional user-defined data on a per-trade basis. For example, I would love to collect volume data, indicator values, % price movements, etc. on the entry bar of a trade and show that data in the trades tab grid in the strategy analyzer results. That way, I could analyze volume, etc. on winning vs losing trades, etc.

    For example I could call something like this for each order entry:
    (IOrder) Order.AddCustomData("Volume", int, CurrentBarVolume)
    (IOrder) Order.AddCustomData("Pct Change", double, CurrentBarPriceChange)

    Hello,

    Thank you for your post and suggestion.

    I will forward this to development for future consideration.

    Have a great day and happy trading!
    Ray S.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by Anagoge View Post
      It would be great to be able to collect additional user-defined data on a per-trade basis. For example, I would love to collect volume data, indicator values, % price movements, etc. on the entry bar of a trade and show that data in the trades tab grid in the strategy analyzer results. That way, I could analyze volume, etc. on winning vs losing trades, etc.

      For example I could call something like this for each order entry:
      (IOrder) Order.AddCustomData("Volume", int, CurrentBarVolume)
      (IOrder) Order.AddCustomData("Pct Change", double, CurrentBarPriceChange)
      Hi Anagoge,

      Attached is a custom "OptimizationType" called Optimization Logger that I use for this kind data gathering. When selected in the "Optimize on..." dropdown box of an Optimize or Walk Forward Optimization action it will do two things:
      1 - Record strategy summary information by appending to a file called Summary Reports.csv
      2 - Record per trade information by creating a .csv file for each iteration of the optimization. The file contains a row for each trade and columns for the following:

      row["BarID"] = calculationTime.ToBinary();
      row["CalculationTime"] = calculationTime;
      row["CalculationBar"] = Strategy.CurrentBar - barsback;
      row["EntrySignal"] = t.EntryExecution.Order.Name;
      row["EntryBar"] = t.EntryExecution.BarIndex;
      row["EntryTime"] = t.EntryExecution.Time;
      row["ExitSignal"] = t.ExitExecution.Order.Name;
      row["ExitBar"] = t.ExitExecution.BarIndex;
      row["ExitTime"] = t.ExitExecution.Time;
      row["Profit"] = Math.Round(t.ProfitCurrency * t.Quantity);

      (now to your actual question, i think)
      It also adds a column for each indicator.Value[] that is added in the Strategy. The values that populate each of the indicator columns are the values from the close of the bar that triggers the order that was filled. So if you want to see the volume on those bars, just Add(VOL()); to your strategy.

      Hope this helps.

      Cheers,
      Frank
      Attached Files

      Comment


        #4
        Thanks for your posting your ideas. Your approach might be the closest we can get using the current NT release. Ideally, we would be able to add metrics to the existing grids/UI, but file output is a reasonable workaround in many cases. Often, my optimizations are large enough that I need to use the genetic optimizer, but these two tools could also be combined. Thanks again!

        Comment


          #5
          Originally posted by LotsaOptions View Post
          Hi Anagoge,

          Attached is a custom "OptimizationType" called Optimization Logger that I use for this kind data gathering. When selected in the "Optimize on..." dropdown box of an Optimize or Walk Forward Optimization action it will do two things:
          1 - Record strategy summary information by appending to a file called Summary Reports.csv
          2 - Record per trade information by creating a .csv file for each iteration of the optimization. The file contains a row for each trade and columns for the following:

          row["BarID"] = calculationTime.ToBinary();
          row["CalculationTime"] = calculationTime;
          row["CalculationBar"] = Strategy.CurrentBar - barsback;
          row["EntrySignal"] = t.EntryExecution.Order.Name;
          row["EntryBar"] = t.EntryExecution.BarIndex;
          row["EntryTime"] = t.EntryExecution.Time;
          row["ExitSignal"] = t.ExitExecution.Order.Name;
          row["ExitBar"] = t.ExitExecution.BarIndex;
          row["ExitTime"] = t.ExitExecution.Time;
          row["Profit"] = Math.Round(t.ProfitCurrency * t.Quantity);

          (now to your actual question, i think)
          It also adds a column for each indicator.Value[] that is added in the Strategy. The values that populate each of the indicator columns are the values from the close of the bar that triggers the order that was filled. So if you want to see the volume on those bars, just Add(VOL()); to your strategy.

          Hope this helps.

          Cheers,
          Frank
          Got the following errors any idea?, do I need to add any reference to it?

          Regards
          Attached Files

          Comment


            #6
            Yes, you need to add a reference to System.Data.dll usually located somewhere under C:\Windows\Microsoft.NET\Framework*

            See here for the assembly/class details:

            Comment


              #7
              There seems to be a minor issue with the code. I get this error in the Log tab:
              Error on calling the 'GetPerformanceValue' method for optimization type class 'OptimizationLogger': Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

              on both of these two lines of code:
              DateTime calculationTime = Strategy.Time[barsback];
              row[i.GetType().Name + index.ToString()] = i.Values[index][barsback];

              But I just tested it after hacking around that issue and the overall concept works.

              Comment


                #8
                Originally posted by Anagoge View Post
                Yes, you need to add a reference to System.Data.dll usually located somewhere under C:\Windows\Microsoft.NET\Framework*

                See here for the assembly/class details:
                http://msdn.microsoft.com/en-us/libr...datatable.aspx

                Thanks work like a charm

                Comment


                  #9
                  I don't suppose that there is an updated NT7 version of this as this is exactly the kind of thing that I have been looking for?

                  Thanks
                  Alex

                  Comment


                    #10
                    Hello,

                    This has to be added manually through NinjaScript by tracking your own information in a seperate file. You wouldnt be able to add saved information to the NinjaTrader database. However you could save this information to a text file for example if you analyze trade data in excel.



                    Let me know if I can be of further assistance.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Jon17, Today, 04:33 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post Jon17
                    by Jon17
                     
                    Started by Javierw.ok, Today, 04:12 PM
                    0 responses
                    4 views
                    0 likes
                    Last Post Javierw.ok  
                    Started by timmbbo, Today, 08:59 AM
                    2 responses
                    10 views
                    0 likes
                    Last Post bltdavid  
                    Started by alifarahani, Today, 09:40 AM
                    6 responses
                    41 views
                    0 likes
                    Last Post alifarahani  
                    Started by Waxavi, Today, 02:10 AM
                    1 response
                    19 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Working...
                    X