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

AddDataSeries() is not working on live

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

    AddDataSeries() is not working on live

    Hi,

    I'm trying to use AddDataSeries() in a very simple strategy with live data but it is not working. The code is:

    Code:
    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.Indicators;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion
    
    //This namespace holds Strategies in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class test : Strategy
    {
    
    
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "test";
    Calculate = Calculate.OnBarClose;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    }
    else if (State == State.Configure)
    {
    AddDataSeries(BarsPeriodType.Tick, 1);
    }
    else if (State == State.DataLoaded)
    {
    
    }
    }
    
    protected override void OnBarUpdate()
    {
    if(BarsInProgress == 0) {
    Print("Bar0");
    }
    if(BarsInProgress == 1) {
    Print("Bar1");
    }
    
    }
    
    
    }
    }
    The strategy works with historical data but when it is real it doesn't work, see the attached image to see the output.

    Hope you can help me, I'm sure I'm doing something wrong.


    #2
    Hello lju45,

    Thanks for your post.

    Are you enabled for and connecting to real-time data when running the strategy?

    Or, are you only receiving and connecting to delayed data from Kinetick or Interactive Brokers?

    Please write into scriptingsupport[AT]ninjatrader[DOT]com and include your Log and Trace files in your response. In the subject of the email include 'ATTN: Brandon' and in the body of the email include a link to this forum thread.

    Follow the steps below to manually attach your log and trace files to your response so I may investigate this matter further.
    • Open your NinjaTrader folder under, "Documents" (sometimes called, "My Documents")
    • Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
    • Send the 2 compressed folders as attachments to this email.
    • Once complete, you can delete these compressed folders.
    Thanks in advance; I look forward to resolving this item.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by PaulMohn, Today, 12:36 PM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by yertle, Yesterday, 08:38 AM
    8 responses
    36 views
    0 likes
    Last Post ryjoga
    by ryjoga
     
    Started by rdtdale, Today, 01:02 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by alifarahani, Today, 09:40 AM
    3 responses
    17 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by RookieTrader, Today, 09:37 AM
    4 responses
    20 views
    0 likes
    Last Post RookieTrader  
    Working...
    X