Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Automated Strategies using Order Flow Indicators/Chart Type

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

    Automated Strategies using Order Flow Indicators/Chart Type

    It was my intention to create an automated strategy to use a volumetric chart along with imbalances to trigger entries and then call upon an ATM strategy. However, I seem to have run into a wall.

    I was recently told by a programmer the following: "The lifetime license order flow indicators/bar types are obfuscated and the properties are private so they can't be used for inputs in strategies."

    Since this is the case currently, does Ninjatrader have any intention of "remedying" this?

    I did see a feature request with the internal tracking number SFT-3586 was created with a similar request.


    #2
    Hello Rogue_Two,

    Thanks for your post.

    You can access the Volumetric bars and their data through Ninjascript, Please see the help guide here: https://ninjatrader.com/support/help...tric_bars2.htm The example in the help guide shows all of the available information from the Volumetric bars.

    The SFT-3586, "Volumetric Bar Data Access Improvements" remains in an open status.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Are volumetric bars independent of time frames. Meaning, are they their own bar type? Or, are they just showing buy/sell information from the current chart type being used?

      Comment


        #4
        Hello marquisejames,

        Thanks for your post and welcome to the NinjaTrader forums!

        Volumetric bars are indeed their own type. When selected you then choose the base bar types of Minute, Tick, Volume, second, Day, week, Month, year, or Range, along with the value (size/period).

        Please see: https://ninjatrader.com/support/help...etric_bars.htm
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks Paul for that confirmation. But, when I add the base type like Minute, would that affect a strategy based on a bar's close. For instance if I had: Close(0) > High(1), would the calculation be made using the Volumetric bar itself, or would it use the underlying bar base type. I need to know this exact information for a strategy I'm developing. Thanks a bunch in advance.

          Comment


            #6
            Hello marquisejames,

            Thanks for your reply.

            All that the Volumetric selection does is provide additional calculations (and options) based on the data to the confines of the selected bar type. A one minute bar is a one minute bar, volumetric or not, so yes the normal price types apply, IE a Volumetric 1 minute bar will have exactly the same OHLC data as a non volumetric 1 minute bar.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Got it. Thanks

              Comment


                #8
                Hi Ninja, can a code similar to link below be used to calculate and return order flow delta (open orders, not executed orders) per tick (not per closed bar)? The code in link below is ONBARUPDATE, what if I need this info for each tick (ONTICKUPDATE) to see stack imbalances (e.g. if for 3 ticks in a row the delta is 1.5% positive hence a buy signal, for example. Does same script work for ONTICKUPDATE? Referring to code in link below:

                https://ninjatrader.com/support/help...tric_bars2.htm

                Comment


                  #9
                  Hello shahabjet1,

                  Thanks for your post.

                  No, for open orders you would need to work with level 2 data.

                  Here is a link to an example of working with level 2 data: https://ninjatrader.com/support/help...vel_ii_dat.htm
                  Paul H.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks, in example above, instead of getting bid and ask price and volume on OnBarUpdate(), can I get the bid and ask price and volume on ladder step per tick (OnTickUpdate) to identify open order imbalance at any moment for each price level in ladder?

                    Comment


                      #11
                      Hello shahabjet1,

                      Thanks for your reply.

                      The example provided is processing OnEachTick and is using OnMarketDepth() to pull the data.

                      Paul H.NinjaTrader Customer Service

                      Comment


                        #12
                        Hi, the example in below link is working on output window when close of bar cross above the 5 SMA but not plotting anything on indicator window at bottom of the chart... now, I need some help to say if the volume delta (bid vs ask) of current price level II data is lets say twice then go long. In other words, how can I get the bid or ask volume of current price in Level II at any moment? Below is a very basic equivalent strategy that it does compile with no error but does not show up in chart to be added as a strategy! Maybe you can help to fix it or identify my issues so I can add it to the chart... Also a stop loss and take profit line would be nice, I just don't know where to add them...

                        #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.Data;
                        using NinjaTrader.NinjaScript;
                        using NinjaTrader.Core.FloatingPoint;
                        using NinjaTrader.NinjaScript.DrawingTools;
                        #endregion

                        // This namespace holds all Strategies and is required. Do not change it.
                        namespace NinjaTrader.NinjaScript.Strategies
                        {
                        public class SeanLevel2 : Strategy
                        {
                        private List<LadderRow> askRows = new List<LadderRow>(10);
                        private List<LadderRow> bidRows = new List<LadderRow>(10);

                        private bool firstAskEvent = true;
                        private bool firstBidEvent = true;

                        private class LadderRow
                        {
                        public string MarketMaker; // relevant for stocks only
                        public double Price;
                        public long Volume;
                        }

                        protected override void OnStateChange()
                        {
                        if(State == State.SetDefaults)
                        {
                        Description = @"Sample Getting the depth of market";
                        Name = "Sample level2 book";
                        Calculate = Calculate.OnEachTick;
                        IsOverlay = false;
                        DisplayInDataBox = true;
                        ScaleJustification = ScaleJustification.Right;
                        }

                        else if(State == State.Historical)
                        {
                        // Since the L2 data is only stored on real-time bars, there is no need to print L2 books on historical data
                        return;
                        }
                        }

                        protected override void OnBarUpdate()
                        {
                        //When the Close price crosses over the SMA, print the L2 books.
                        if (CrossAbove(Close, SMA(5), 1))
                        {
                        ClearOutputWindow();
                        // Prints the L2 Ask Book we created. Cycles through the whole List and prints the contained objects.
                        Print("Ask Book");
                        // for (int idx = 0; idx < askRows.Count; idx++)
                        Print("Current Ask Price=" + askRows[0].Price + " Volume=" + askRows[0].Volume);

                        // Prints the L2 Bid Book we created. Cycles through the whole List and prints the contained objects.
                        Print("Bid Book");
                        // for (int idx = 0; idx < bidRows.Count; idx++)
                        Print("Current Bid Price=" + bidRows[0].Price + " Volume=" + bidRows[0].Volume);
                        if (bidRows[0].Volume > askRows[0].Volume * 2)
                        EnterLong(1);
                        }
                        }

                        protected override void OnMarketDepth(MarketDepthEventArgs e)
                        {
                        // protect e.Instrument.MarketDepth.Asks and e.Instrument.MarketDepth.Bids against in-flight changes
                        lock (e.Instrument.SyncMarketDepth)
                        {
                        List<LadderRow> rows = (e.MarketDataType == MarketDataType.Ask ? askRows: bidRows);
                        LadderRow row = new LadderRow { MarketMaker = e.MarketMaker, Price = e.Price, Volume = e.Volume };

                        if (e.Operation == Operation.Add || (e.Operation == Operation.Update && (rows.Count == 0 || rows.Count <= e.Position)))
                        {
                        if (rows.Count <= e.Position)
                        rows.Add(row);
                        else
                        rows.Insert(e.Position, row);
                        }
                        else if (e.Operation == Operation.Remove && rows.Count >= e.Position)
                        {
                        rows.RemoveAt(e.Position);
                        }
                        else if (e.Operation == Operation.Update)
                        {
                        if (rows[e.Position] == null)
                        {
                        rows[e.Position] = row;
                        }
                        else
                        {
                        rows[e.Position].MarketMaker = e.MarketMaker;
                        rows[e.Position].Price = e.Price;
                        rows[e.Position].Volume = e.Volume;
                        }
                        }
                        }
                        }

                        #region Properties

                        #endregion
                        }
                        }

                        #region NinjaScript generated code. Neither change nor remove.





                        #endregion


                        Last edited by shahabjet1; 10-20-2020, 10:19 AM.

                        Comment


                          #13
                          Hello shahabjet1,

                          Thanks for your reply.

                          What data feed do you connect to?

                          What instrument have you tested the example on?

                          Paul H.NinjaTrader Customer Service

                          Comment


                            #14
                            Hi, I use Full Depth Level II data and I want the strategy to be able to analyze any Futures instrument you have on chart, but primarily MES. Can you help me to amend strategy above for any futures instrument and add a profit target and stop loss as well? Thanks much...

                            Comment


                              #15
                              I connect to Ninjatrader Continuum for my live account market data full depth level 2

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by KirkHammett, Today, 11:15 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post KirkHammett  
                              Started by soon123, Today, 11:12 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post soon123
                              by soon123
                               
                              Started by JustinCross, Today, 09:48 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post JustinCross  
                              Started by Unsuitable, Today, 06:30 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post Unsuitable  
                              Started by michaelsh, Today, 04:28 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post michaelsh  
                              Working...
                              X