Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Referencing Instrument in Strategy Code

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

    Referencing Instrument in Strategy Code

    Hi there.

    I will be back testing and optimizing on a basket of 5 Futures contracts. My problem is that I don't want the same session template to be used on all the instrument in the basket. Is there some way to reference the current instrument that is being back tested so that I can create my own custom session templates in the strategy code so that not all instruments are taking trades on the same session template. For example:

    If(Instrument == "ES 12-06" && ((Time[0].DayOfWeek == DayOfWeek.Monday) && (ToTime(Time[0]) >= ES-starttime)) && ((Time[0].DayOfWeek == DayOfWeek.Monday) && (ToTime(Time[0]) <= ES-endtime)))
    {
    ES-cantrade = true;
    }

    Thanks

    Ash

    #2
    This would allow you to get the instrument's name and then you could filter as needed.



    That being said there are a couple ways you could go about addressing this problem depending on your end goal.

    If you're wanting individual backtest results for each instrument in the basket, then your method will be the best.

    If you were looking for an aggregated list results only let me know and I'll give you an alternative approach.
    LanceNinjaTrader Customer Service

    Comment


      #3
      I believe this is exactly what I was looking for. Thanks Lance appreciate it.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 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
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      574 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X