Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Data Gaps Fix or Print

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

    Data Gaps Fix or Print

    Hello !!! wood some one give me idea how to access data and fix it ?
    for example build strategy to check for data gaps and print it , or fix gaps and spikes if possible or normalized


    #2
    Hello,

    I am uncertain of your question, are you asking how to correct gaps in historcial data?

    A strategy would have no way of detecting gaps in data because the strategy would not be executed on bars that are not present.

    You could potentially check the date of each bar to detect an amount of time missing, but I would need to have more details on what you are trying to accomplish first.

    I look forward to being of further assistance.

    Comment


      #3
      Hi !!! Ok something like this
      if Close[0] * Close[1] = 0 Print ++ Gap
      and if possible to delete this bar in database ?

      and if Open[0] + or - Close[1] > < 50 pips print Spike ?

      Comment


        #4
        Hi !!! for example Trading Software RigthEdge have plugin build in or external plugin like this
        I Think wood be very cool to add this future to Ninjatrader
        #region System class
        public class MySystem : MySystemBase
        {
        public override void Startup()
        {
        // Perform initialization or set system wide options here

        }


        public override void Shutdown()
        {

        foreach (Symbol mysym in Symbols)
        {
        TimeSpan difftime;
        SymbolScripts[mysym].LastBarDate = SymbolScripts[mysym].Bars.Current.BarStartTime;
        SymbolScripts[mysym].TotalBars = SymbolScripts[mysym].LastBarDate.TimeOfDay.TotalMinutes - SymbolScripts[mysym].FirstBarDate.TimeOfDay.TotalMinutes;

        difftime = SymbolScripts[mysym].LastBarDate - SymbolScripts[mysym].FirstBarDate;
        Console.WriteLine(mysym.Name + " ---------- LastBarDate=" + SymbolScripts[mysym].LastBarDate);
        Console.WriteLine(mysym.Name + " nb of minutes=" + difftime.TotalMinutes);
        if (SymbolScripts[mysym].TotalBarGaps == 0)
        {
        //Console.WriteLine(mysym.Name + ": No bar missing !");
        SystemData.Output.Add(OutputSeverityLevel.Informat ional, mysym.Name + ": No bar missing !");
        }
        else
        {
        //Console.WriteLine(mysym.Name + ": ERROR " + SymbolScripts[mysym].TotalBarGaps + " gaps of missing bars !");
        SystemData.Output.Add(OutputSeverityLevel.Error, mysym.Name + ": " + SymbolScripts[mysym].TotalBarGaps + " gaps of missing bars !");
        }
        }
        //LastBarDate = Bars.Current.BarStartTime;
        //NbBars = LastBarDate - FirstBarDate;

        }


        }
        #endregion


        /*
        Bars Checkers v0.1


        System parameters:

        MaxPercentage = max allowed price jump (close) between two consecutives bars, in percentage (eg 0.05 for 5%)
        BarFrequency = your data bar frequency in minutes

        */
        public class MySymbolScript : MySymbolScriptBase
        {
        public DateTime FirstBarDate;
        public DateTime LastBarDate;
        public double TotalBars, TotalBarGaps;

        public override void Startup()
        {
        // Perform initialization here.
        TotalBarGaps = 0;
        }

        public override void NewBar()
        {
        // Put your trading code here
        if (Bars.Count == 1)
        {
        FirstBarDate = Bars.Current.BarStartTime;
        OutputMessage(Symbol.Name + " ---------- FirstBarDate=" + FirstBarDate);
        //BarLookBackFromDate(
        }
        else
        {
        TimeSpan bartimediff = Bars.Current.BarStartTime - Bars.LookBack(1).BarStartTime;
        //TODO compare with system freq or ...
        if (bartimediff.TotalMinutes > (int) SystemParameters["BarFrequency"])
        {
        TotalBarGaps++;
        SystemData.Output.Add(OutputSeverityLevel.Error, Symbol.Name + ": bar(s) missing between " + Bars.LookBack(1).BarStartTime + " and " + Bars.Current.BarStartTime);
        }
        if (Bars.Current.Close == 0)
        {
        SystemData.Output.Add(OutputSeverityLevel.Error, Symbol.Name + " null value at time " + Bars.Current.BarStartTime);
        }
        else if (Bars.LookBack(1).Close != 0)
        {
        double barreturn = (Bars.Current.Close / Bars.LookBack(1).Close) - 1;
        if (Math.Abs(barreturn) > SystemParameters["MaxPercentage"])
        {
        SystemData.Output.Add(OutputSeverityLevel.Warning, Symbol.Name + " big jump between two consecutive bars: " + Bars.LookBack(1).Close + " to " + Bars.Current.Close + " at time " + Bars.Current.BarStartTime);
        }
        }
        }

        }

        public override void OrderFilled(Position position, Trade trade)
        {
        // This method is called when an order is filled

        }

        public override void OrderCancelled(Position position, Order order, string information)
        {
        // This method is called when an order is cancelled or rejected

        }
        }

        Comment


          #5
          Hello GainForex,

          Thanks for your posts and recommendation for improving our product.

          For realtime tick filtering, please see the helpguide section here: http://ninjatrader.com/support/helpG.../?data_tab.htm
          "Filter bad ticks % off market - Sets the real-time tick filter offset percentage (0.1 equals 1/10 of a percent)"

          For editing or deleting bar data, please see: http://ninjatrader.com/support/helpG...7/?editing.htm

          Comment


            #6
            Hello !!! i,m sorry i ask about historical data modification or gap check!!!
            with custom script in strategy tester
            if possible to access and modify data or check for Historical Gaps from strategy script
            and print it in error platform window

            Comment


              #7
              Originally posted by GainForex View Post
              Hello !!! i,m sorry i ask about historical data modification or gap check!!!
              with custom script in strategy tester
              if possible to access and modify data or check for Historical Gaps from strategy script
              and print it in error platform window
              I've not investigated modifying data per se(there's nothing via what is available in NT), but you can check for whatever you want via script and print an error...

              So are you talking live data or market replay? Or backtest?

              Comment


                #8
                Hi , i,m taking about backtesting data modification or gap print
                how to access data update or delete from strategy tester script

                Comment


                  #9
                  Originally posted by GainForex View Post
                  Hello !!! i,m sorry i ask about historical data modification or gap check!!!
                  with custom script in strategy tester
                  if possible to access and modify data or check for Historical Gaps from strategy script
                  and print it in error platform window
                  Thanks for your post.

                  There is no automatic means in ninjatrader to accomplish this.

                  You can create code within a strategy to check for gaps and could print to the output window however there is no method available to adjust the data within a strategy.

                  I previously provided a link to the Historical Data Manager for editing historical data.

                  Comment


                    #10
                    Has anyone written a script to check for tick stream data gaps?

                    Comment


                      #11
                      Hello mstreck,

                      Thanks for your post.

                      I am not aware of any, perhaps others in the community could comment on this.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      558 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      324 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      101 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      545 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      547 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X