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

Multi Time Frame Data

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

    Multi Time Frame Data

    I have a fairly simple question which I can't seem to find a solution to. I am developing a strategy which I plan on trading on the 15m time frame, this strategy also uses data from the daily time frame. I can't seem to retrieve the data from the daily time frame correctly. I have attached a copy of the code below.

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class TrendTrading : Strategy
    {
    private double _DailyHigh;

    protected override void OnStateChange()
    {
    if (State == State.Configure)
    {
    AddDataSeries(BarsPeriodType.Minute, 60);
    AddDataSeries(BarsPeriodType.Day, 1);
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 2)
    {
    _DailyHigh = High[0];
    }
    Print("High: " + _DailyHigh);
    }
    }
    }

    When I run this code in market replay mode on the 15m chart, I am getting a value of 0 for the variable _DailyHigh (The high of the most recently closed bar on the daily time frame).

    I can't seem to find where I am going wrong.

    #2
    Hello Sudonega,

    I am not able to reproduce this behavior.

    Below is a link to a video of the test.


    Do you have more than 1 day of data?

    As a tip, to export a NinjaTrader 8 NinjaScript so this can be shared and imported by the recipient do the following:
    1. Click Tools -> Export -> NinjaScript...
    2. Click the 'add' link -> check the box(es) for the script(s) and reference(s) you want to include
    3. Click the 'Export' button
    4. Enter a unique name for the file in the value for 'File name:'
    5. Choose a save location -> click Save
    6. Click OK to clear the export location message
    By default your exported file will be in the following location:
    • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
    Below is a link to the help guide on Exporting NinjaScripts.
    http://ninjatrader.com/support/helpG...-us/export.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea, thanks for looking into this. I managed to resolve this issue, for some reason when I enter market replay mode and load up the daily chart, it doesn't instantly load historical bars which is why it was retrieving a null value for High[0] as there were no bars which had previously closed. It's a bit strange because it does load up the historical bars on the lower time frames such as the 60 minute chart.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by timmbbo, Today, 08:59 AM
      1 response
      2 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by KennyK, 05-29-2017, 02:02 AM
      2 responses
      1,281 views
      0 likes
      Last Post marcus2300  
      Started by fernandobr, Today, 09:11 AM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by itrader46, Today, 09:04 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by bmartz, 03-12-2024, 06:12 AM
      5 responses
      33 views
      0 likes
      Last Post NinjaTrader_Zachary  
      Working...
      X