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

Try develop a indicator that is like order flow a little bit

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

    Try develop a indicator that is like order flow a little bit

    I am totally new, so maybe I am asking very basic questions here.
    I try to develop a indicator to show me how many positions are sold actively and bought actively.
    Here "actively" means that positions are sold or bought manually by human. it is not that positions
    are sold or bought by system automatically when price reach at a specific value.

    Because i do not have too much conception or context about Ninja Scription and the whole process
    of trade. I just learn some examples of Ninja Scription and know some basic knowledges. So I just
    image and describe a ideal scenario that I want, and explan more about the idea of first paragraph.

    Let's assume there is a event that could be triggered at every tick or close event of a bar or every
    change of price. then the event could have 2 (or more ) parameters to show me the the quantity of
    position was sold actively and the quantity of position was bought actively. then i can use these data
    to develop my indicator.

    here is my questions:
    1.If there is this ideal scenario please tell me how to use it(or any other solutions that can do same thing)
    I alreay read all references that i can find, i do not find any topic to show me this.

    2.Is it necessary to buy more data if i want to do it?
    hopefully it is not the only way, becasue i guess this data is not about depth of market. If it is could you
    tell me some details about it, such as how to buy, price, etc... or maybe a link to appropriate webpage is enough

    Thanks


    #2
    Hello UMLer,

    Thanks for your post.

    I understand that you are wanting to identify buys and sells that occur on the market.

    Buy and Sell information is determined by comparing bid/ask prices associated with the Last tick.

    The easiest way for a NinjaScript beginner to accomplish this would be through using OnMarketData. Note for historical processing you could use Tick Replay.

    For an example of using OnMarketData to get the number of buys and sells that occur see the BuySellVolume indicator that comes default with NinjaTrader. To view the BuySellVolume script, open a New > NinjaScript Editor window, open the Indicators folder, and select the BuySellVolume file.

    Also, see the help guide documentation below for more information.
    OnMarketData: https://ninjatrader.com/support/help...marketdata.htm
    Tick Replay: https://ninjatrader.com/support/help...ick_replay.htm

    I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript:
    https://ninjatrader.com/support/help..._resources.htm

    If you are new to C#, to get a basic foundation for the concepts and syntax used in NinjaScript I would recommend this section of articles in our help guide first: https://ninjatrader.com/support/help...g_concepts.htm

    And the MSDN (Microsft Developers Network) C# Language Reference.
    https://ninjatrader.com/support/help...erence_wip.htm

    Let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for reply.
      I copy this OnMarketData method of BuySellVolume indicator below:
      protected override void OnMarketData(MarketDataEventArgs e)
      {
      if(e.MarketDataType == MarketDataType.Last)
      {
      if(e.Price >= e.Ask)
      buys += (Instrument.MasterInstrument.InstrumentType == Cbi.InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume(e.Volume) : e.Volume);
      else if (e.Price <= e.Bid)
      sells += (Instrument.MasterInstrument.InstrumentType == Cbi.InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume(e.Volume) : e.Volume);
      }
      }

      consider the context about my question i prefer to discuss my relevant questions in this same post.
      please look at the if statement "if(e.Price >= e.Ask)". My questions are:
      Q1:
      if the condition is e.Price > e.Ask then it means orders were bought actively (the word "actively" is context of this topic)
      because orders were bought at a higher price than market asked
      is it correct?

      Q2:
      if the condition is e.Price == e.Ask then it means orders could be bought actively or not.
      because orders might be bought at the price as same as market asked. and also when
      the price reached the value, there are some limited orders could be bought automatically
      by system.
      is it correct?

      Q3:
      if both Q1 and Q2 are correct then is it possible to know the volume of those orders
      that are bought actively only (do not include volume of limited orders)?

      Thanks

      Comment


        #4
        Hello UMLer,

        Thanks for your note.

        All Last ticks are qualified trades. The Ask and Bid are the most recent transactions that have occurred associated with the Last tick.

        NinjaTrader just marks buys and sells with >= operators. I am not aware of the significance of having Ask == Last.

        If you wanted to count buys as >, you could certainly do that by modifying an indicator such as BuySellVolume.

        Let us know if we may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          I add indicator BuySellVolume to my chart, time frame is 10 second. and attachment just show one bar char.
          please look at the left one. total volume is 12. my questions are
          Q1: red part is the buying volume?
          Q2: green part is the selling volume?
          Q3: total volume is 12, red part is a little bit more than 5 and less than 6, let's say it is 5.2, so green part is 12 - 5.2 = 6.8
          why is it not equal?

          Thanks
          Attached Files

          Comment


            #6
            Hello UMLer,

            Thanks for your note.

            The BuySellVolume indicator is an indicator that works on real-time data. This means that bars will begin forming in real-time and not historically. To have the indicator process data historically, you would need to enable Tick Replay in the Data Series window.

            To enable Tick Replay, navigate to Tools > Options > Market Data tab and ensure the 'Show tick replay' checkbox is checked. Then, in the Chart window, select the Data Series button on the Chart Toolbar, select the data series, check the Tick Replay checkbox in the data series Properties section, and click OK.

            Note you may need to right-click > 'Reload NinjaScript' after enabling Tick Replay.

            If you look at the BuySellVolume indicator's Properties section in the Indicators window, you could see which color indicates buys and which color indicates sells. You could also modify these colors. See the attached image.

            See the help guide documentation below for more information.
            Tick Replay: https://ninjatrader.com/support/helpGuides/nt8/NT%20HelpGuide%20English.html?tick_replay.htm

            Let us know if we may assist further.
            Attached Files
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Thanks
              I add volume profile indicator to my chart, for example it is 1min chart. then i can see the indicator on chart.
              10 min later, there are some data, then i switch to 3 min timepframe, then all data just gone.

              then i try again enable replay option. i can see that it is different. when i switch timeframe data still there. looks
              like Ninja Trader use historical data and real time data to show indicator, is it right?

              And no matter I enable replay option or not, when i switch timeframe, indicator "volume up down" can work well.
              i mean data always there. why is it different?

              Comment


                #8
                Hello UMLer,

                Thanks for your note.

                This is the expected behavior of the BuySellVolume indicator. The BuySellVolume indicator is an indicator that works only with real-time data unless Tick Replay is enabled for the Data Series that the indicator is applied to.

                This means that if you switch instruments or timeframes, the indicator will recalculate using the current real-time data that is coming in on the chart.

                The VolumeUpDown indicator calculates using historical data and real-time data which is why you see that indicator plot historically.

                If you want the BuySellVolume indicator to calculate historical values and plot historically, you would need to enable Tick Replay as noted in my previous post. Otherwise, this indicator will only plot real-time values when applied to a chart.

                Let us know if we may further assist.
                Brandon H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by judysamnt7, 03-13-2023, 09:11 AM
                4 responses
                59 views
                0 likes
                Last Post DynamicTest  
                Started by ScottWalsh, Today, 06:52 PM
                4 responses
                36 views
                0 likes
                Last Post ScottWalsh  
                Started by olisav57, Today, 07:39 PM
                0 responses
                7 views
                0 likes
                Last Post olisav57  
                Started by trilliantrader, Today, 03:01 PM
                2 responses
                21 views
                0 likes
                Last Post helpwanted  
                Started by cre8able, Today, 07:24 PM
                0 responses
                10 views
                0 likes
                Last Post cre8able  
                Working...
                X