Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Programmatically differentiate backtest and real time?

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

    Programmatically differentiate backtest and real time?

    As you know order size must be set differently for a backtest than for realtime, especially in FX. Specifically, in backtest for Forex you use 10,000 for 1 mini lot. But in real time, you use only 1 for a mini lot (in a mini account).

    So I'm looking for a NinjaScript variable that indicates whether it currently runs on real time or backtest data?

    It appears NT is missing such an indicator.

    My idea, at the moment is to set a variable, realTimeFlag, in OnMarketData() to true since OnMarketData() never gets called on backtest data.

    The idea is to use that variable elsewhere in the strategy to correctly set the order size if running in real time?

    Is there a better way? Is this idea risky?

    Sincerely,
    Wayne

    #2
    if (!Historical)
    // We are real-time

    RayNinjaTrader Customer Service

    Comment


      #3
      My other idea worked. But this is very cool and much simple. Honestly, I did search help and the forum and never found this.

      Sincerely,
      Wayne

      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