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