Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

running a strategy on a chart, data not generated for historical data

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

    running a strategy on a chart, data not generated for historical data

    too long subject line:
    implementing TrendLines code in my tick replay strategy, run it on a chart, the rays are not generated for historical data

    Hi Friends!

    The trendlines indicator is implemented by adding the TrendRay and TrendQueue classes and queueing up rays from OnBarUpdate().

    I want to expand on this concept in a strategy so I copied the code (changing names along the way).

    When I run the strategy in the strategy analyzer, it works as expected, but when I run the strategy in a chart, the trendlines are not Enqueued or drawn for the historical part of the data, just the real time.

    How can I fix that?

    I suspect this is easily answered so only a brief overview of the code here, but I would be happy to elaborate if necessary.

    The strategy has Bars[0] = minute bars and Bars[1] = BarsPeriodType.Tick, 1

    And the code looks kind of like this..

    Code:
    OnBarUpdate(){
     if (BarsInProgress == 0)
       if (IsFirstTickOfBar) {
        if( swing.SwingHighBar(1, 1, Strength + 1) != -1 ){
         if( various conditions ) trendLines.Enqueue(highTrend);
        }
       }
    }
    Thanks!

    #2
    Hello robforee,

    Open a chart to the same instrument, bar type, and interval and add the indicator using the same parameters.

    Do you see historical drawing objects?

    The TrendLines indicator included with NinjaTrader re-uses tag names to ensure there is only one of that object type on the chart.

    If you want to see previous lines, you can copy this script, and then use unique tag names to generate new objects instead of updating existing objects.

    Below is a link to a video on copying scripts.


    And a link to a forum post on using unique tag names.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    52 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X