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 argusthome, Yesterday, 10:06 AM
      0 responses
      20 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      18 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      14 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      9 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      40 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X