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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      67 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      36 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      59 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      62 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      53 views
      0 likes
      Last Post CarlTrading  
      Working...
      X