Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy in live mode handles old data

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

    Strategy in live mode handles old data

    Hi,

    I am running a strategy, that opens based on the latest price a bracket order.

    When I start the strategy in live mode then first it loads some old data, and in the Method OnBarUpdate, when I fixate the starting price, I get some old price and the strategy doesn't work.

    To prevent that I am checking for the historical state, and only respect the price when the state is not historica.

    State != State.Historical

    This makes the strategy work fine.

    But I have than a problem with the backtest, it has only historical data I assume.

    I tried checking BarsInProgress == 0, but it didn't help.

    How is it possible to make the strategy using only latest data during live market run and all data during backtesting?

    Where do I get a log for the strategy analyzer. When I start the strategy in live mode, it trades. When I backtest it for one year with all test data available, I get an empty result with zero trades.

    Thanks and best regards
    Last edited by moneymaster; 02-12-2025, 01:53 AM.

    #2
    Hello moneymaster,

    Thank you for your post.

    You can use IsInStrategyAnalyzer to check if your script is running in the analyzer. The Strategy Analyzer only runs on historical data so your check to return when State is State.Historical will cause it not to run at all in the Strategy Analyzer.

    Code:
    //Return if we are not running this strategy from the Strategy Analyzer and State is Historical
    if(!IsInStrategyAnalyzer && State == State.Historical)
    {
    return
    }
    Please let us know if you have any further questions. ​

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    55 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    37 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    17 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    19 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    49 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X