Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Jon17, Today, 04:33 PM
    0 responses
    1 view
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    4 views
    0 likes
    Last Post Javierw.ok  
    Started by timmbbo, Today, 08:59 AM
    2 responses
    10 views
    0 likes
    Last Post bltdavid  
    Started by alifarahani, Today, 09:40 AM
    6 responses
    40 views
    0 likes
    Last Post alifarahani  
    Started by Waxavi, Today, 02:10 AM
    1 response
    19 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Working...
    X