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

GDAX Ask/Bid Volume

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

    GDAX Ask/Bid Volume

    Hello,


    I am trying to use ask/bid volume in my indicator.
    By adding secondary data series like;
    (Primary series is Last)



    Code:
    AddDataSeries(null, BarsPeriodType.Tick, 1, MarketDataType.Ask);
    AddDataSeries(null, BarsPeriodType.Tick, 1, MarketDataType.Bid);
    I should be able to use;


    Code:
    Plot0[0] = Volumes[1][0]
    Plot1[0] = Volumes[2][0]
    But that didn't work.


    So i tried;
    Code:
    Plot0[0] = GetCurrentAskVolume()
    Plot1[0] = GetCurrentBidVolume()
    This works for one of the volumes, but only when I change the primary input series to Ask or Bid.


    Can anyone help me access both volumes? Preferably without changing the primary input series from Last.


    Thankyou


    Edit: Volumes[1][0] not Volume[1][0]...
    Last edited by Rastus; 09-22-2018, 03:16 AM.

    #2
    Hello Rastus,

    You cannot supply null as a parameter to AddDataSeries().

    You would need to supply a hard coded (non-dynamic) string using the overload parameter set.
    AddDataSeries(string instrumentName, BarsPeriodType periodType, int period, MarketDataType marketDataType)

    For example:
    AddDataSeries("ES 12-18", BarsPeriodType.Tick, 1, MarketDataType.Ask);

    Also, are you able to load 1 tick ask and bid data on a chart directly and have this load?
    (Who are you connected to for data?)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi ChelseaB,


      I used null, only so I can run the indicator on different instruments. By putting "BTCUSD" in there, i can now use Volumes[1][0].


      But if the primary instrument is Last, I am still not getting the Ask (or Bid) Volumes.


      I was under the impression, that OnBarUpdate would run for any tick event. And by further segmenting with;


      if(BarsInProgress == 1)
      {
      Plot0[0] = Volumes[1][0]
      }
      Then I would plot the Ask Volume?


      But what is happening is it only plots for a Last tick event.


      I'm using the GDAX data feed.

      Comment


        #4
        Hello Rastus,

        If the MarketDataType is ask with AddDataSeries(), this will be the ask volume.with Volumes[barsInProgres index][bar index].

        To compare, try adding an ask series directly to a chart, and add the VOL indicator to a and change the input series to the input series using ask.
        Below is a public link to a video that demonstrates changing the input series for an indicator.


        Are you on the latest version of NinjaTrader 8 (8.0.15.1)? (Help > About)
        Are you connecting to the Coinbase connection type?
        Where you able to load a 1 minute ask chart?
        Last edited by NinjaTrader_ChelseaB; 09-23-2018, 09:56 PM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thankyou for your assistance ChelseaB,


          I was on version 8.0.14.2, so now ive upgraded. GDAX is now Coinbase. Ok.


          Here is a screenshot of what im trying to achieve.
          Click image for larger version

Name:	CryptoVolume.jpg
Views:	1
Size:	159.6 KB
ID:	889118


          Here is my code.


          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          Calculate = Calculate.OnEachTick;

          Description = "My Indicator";
          Name = "Test1";
          IsOverlay = false;
          IsSuspendedWhileInactive = true;

          AddPlot(Brushes.Salmon, "Plot0");
          AddPlot(Brushes.LightSkyBlue, "Plot1");
          AddPlot(new Stroke(Brushes.Salmon, 2), PlotStyle.Bar, "Plot2");
          AddPlot(new Stroke(Brushes.LightSkyBlue, 2), PlotStyle.Bar, "Plot3");


          }
          else if (State == State.Configure)
          {
          AddDataSeries("BTCUSD", BarsPeriodType.Tick, 1, MarketDataType.Ask);
          AddDataSeries("BTCUSD", BarsPeriodType.Tick, 1, MarketDataType.Bid);
          }
          }

          protected override void OnBarUpdate()
          {

          if(CurrentBars[0] < 2 || CurrentBars[1] < 2)
          return;

          // Runs OnBarUpdate for an ASK update
          if(BarsInProgress == 1)
          {
          Plot2[0] = Volumes[1][0];
          }
          }


          So basically Im trying to get the 1 tick ask & bid volume into my indicator.

          Im using the Last as the primary data series, as sort of a middle point.

          It seems that OnBarUpdate only runs for the primary data series? Is this true?




          I can open 1 minute charts. But I'm interested in 1 tick.


          Thankyou.

          Comment


            #6
            Hello Rastus,

            Unfortunately, Coinbase does not provide historical tick data.

            However, this would work in real-time. Are you unable to get values with real-time data?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi ChelseaB,


              Yes that's correct.
              I thought with that code i posted, then it would simply replot the Ask Volume.

              Ultimately, i would like all three volumes available in my indicator.

              Real time is all I need.
              Can you suggest any things i can try?


              Thankyou

              Comment


                #8
                Hello Rastus,

                I'm not seeing any issue.

                With the code shown, you are trying to plot the last received ask tick's volume while the primary bar is open, is this correct?
                So if the primary bar is 1 minute, you want the last tick received during that minute, is this correct?
                And you want to plot the volume of that single last received tick for that 1 minute bar, is this correct?

                Below is a video showing that the last ask tick's volume during that minute matches an ask chart.


                Attached is the script I have tested.

                If you follow the exact steps shown in the video using the provided test script are you getting different behavior than what is shown in the video?

                Also, to get decimals with the volume use Core.Globals.ToCryptocurrencyVolume((long)Volumes[1][0]);
                Attached Files
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  So helpful ChelseaB!


                  I will re asses the situation with your code and video soon.
                  I think my problem was in comparing crypto to forex, where the last to ask/bid quote ratio is closer to 1:1.


                  Initially i was trying to determine ask/bid volume fluctuations relative to the last. I will look at your code asap, but maybe i have to separate ask/bid with last. And compare them in a different way.


                  Thankyou

                  Comment


                    #10
                    Originally posted by NinjaTrader_ChelseaB View Post
                    With the code shown, you are trying to plot the last received ask tick's volume while the primary bar is open, is this correct?
                    So if the primary bar is 1 minute, you want the last tick received during that minute, is this correct?
                    And you want to plot the volume of that single last received tick for that 1 minute bar, is this correct?


                    Hi ChelseaB,


                    Thankyou for your patience.


                    I'm mainly interested in tick charts. Specifically 1 tick. So this means the primary bar is not really open. I suspect this is where my problem is.


                    I have the previous screenshot here. Basically I want my indicator to be able to access the fluctuations in ask/bid volume.



                    So i might have three plots (different colours)


                    Plot0[0] = askVolume[0];
                    Plot1[0] = bidVolume[0];
                    Plot2[0] = lastVolume[0];




                    I was only plotting them so I could verify that the values are correct.



                    Click image for larger version

Name:	CryptoVolume2.jpg
Views:	1
Size:	170.6 KB
ID:	889139

                    Comment


                      #11
                      Hello Rastus,

                      You don't have to set a plot to see that the values are correct. You can print to the output window anytime you want to understand behavior.

                      Below is a link to a forum post that demonstrates using prints to understand behavior.


                      Use prints often and always.

                      I was not able to confirm, using the example I have provided you and taking the same steps in the video are you getting different behavior?

                      The last and ask ticks are going to be sent at different times. This means that the volume isn't going to necessarily match when you are updating the primary plot with values being received at sporadic times.

                      If you add the indicator to a 1 tick ask chart, the volume will match because its updating at the same time, meaning the last received ask tick is plotted when the last received ask tick was received (and not when the last last tick was received).

                      Below is a link to a video showing with the script I have provided you I see no differences in what the added series is plotting and printing and what the VOL indicator is showing.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Hello ChelseaB,



                        Originally posted by NinjaTrader_ChelseaB View Post
                        I was not able to confirm, using the example I have provided you and taking the same steps in the video are you getting different behavior?

                        Yes this works perfectly. Thankyou.




                        Originally posted by NinjaTrader_ChelseaB View Post

                        The last and ask ticks are going to be sent at different times. This means that the volume isn't going to necessarily match when you are updating the primary plot with values being received at sporadic times.

                        This is what I've been trying to do...
                        Update the plot for either of the three tick events.


                        In your code, the prints update for each tick event. I was trying to extrapolate this to plots.
                        It seems plots only update for the primary tick event.
                        I will have to find another way.


                        Thankyou for your work.

                        Comment


                          #13
                          Hello Rastus,

                          This is correct, plots are only synchronized to the primary series.
                          Chelsea B.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Barry Milan, Yesterday, 10:35 PM
                          5 responses
                          16 views
                          0 likes
                          Last Post NinjaTrader_Manfred  
                          Started by DanielSanMartin, Yesterday, 02:37 PM
                          2 responses
                          13 views
                          0 likes
                          Last Post DanielSanMartin  
                          Started by DJ888, 04-16-2024, 06:09 PM
                          4 responses
                          13 views
                          0 likes
                          Last Post DJ888
                          by DJ888
                           
                          Started by terofs, Today, 04:18 PM
                          0 responses
                          11 views
                          0 likes
                          Last Post terofs
                          by terofs
                           
                          Started by nandhumca, Today, 03:41 PM
                          0 responses
                          8 views
                          0 likes
                          Last Post nandhumca  
                          Working...
                          X