Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Inline Strategy Metrics

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

    #16
    Thank you for the code sample. In using the code I receive the following error message: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart. Any thoughts on how to fix or added check in place before the code section. With this code commented out I do not get any errors with the working strategy I am adding this to.

    - CableTrader007

    Comment


      #17
      Hello CabelTrader007,

      Thank you for your response.

      I have corrected the for loop below, you will also want to ensure 30 bars have processed with CurrentBar:
      Code:
      		protected override void OnBarUpdate()
      		{
      			if(CurrentBar <= 30)
      				return;
      			if(Performance.AllTrades.Count > 30)
      			{
      				for(int i = 30; i > 0; i--)
      				{
      					totProfit[i-1] = Performance.AllTrades[Performance.AllTrades.Count - i].ProfitCurrency;
      				}
      				double totAvgProfit = SMA(totProfit, 30)[0];
      				double totStdDev = StdDev(totProfit, 30)[0];
      				double perfMetric = totAvgProfit / totStdDev;
      			}
      		}

      Comment


        #18
        Thank you for the quick reply. Please explain why the check for 30 bars. The calculation already has a check for 30 trades which does not have anything to do with the number of bars.

        Comment


          #19
          Hello CableTrader007,

          Thank you for your response.

          The DataSeries totProfit is synced to the primary bar series you apply the strategy to via the line in the Initialize() method that reads totProfit = new DataSeries(this);. So the totProfit would not have all the values we want before 30 bars have processed.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          647 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          368 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          571 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X