Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy determine if backtesting or live

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

    strategy determine if backtesting or live

    Is there a way to distinguish is a strategy is being used live vs trading in the strategy analyzer?

    In other words, I wanted to make sure that the user has performed some key training modules prior to going "live" - how could I tell if a user was attaching my strategy to a live chart?

    thanks,
    TODDL

    #2
    Hello TODDLINDSTROM,


    You could use the Historical property to check if your script is running on historical data. With a strategy, when running a backtest, this property will always return true. When running a live strategy, this property will be true until the strategy starts processing real-time data.


    Here is an example that will only the script to run on real-time data.
    Code:
    protected override void OnBarUpdate()
    {
        // Only run on real-time data
        if (Historical)
             return;
    }
    Here is the Historical Help Guide to assist you further.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    27 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    117 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    69 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    226 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    417 views
    0 likes
    Last Post CaptainJack  
    Working...
    X