Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Executed contract Ask/Bid indicator

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

    Executed contract Ask/Bid indicator

    Hey everybody,

    I would to have an indicator which shows the numbers of executed contract at the ask and the number of executed contract at the bid within a bar. I just would like to know what's wrong with this code :

    Code:
    public class MyCustomIndicator : Indicator
    	{
    		protected override void OnStateChange()
    		{
    			
    			
    			if (State == State.SetDefaults)
    			{
    				Description							= @"Enter the description for your new custom Indicator here.";
    				Name								= "MyCustomIndicator";
    				Calculate							= Calculate.OnBarClose;
    				IsOverlay							= false;
    				DisplayInDataBox					= true;
    				DrawOnPricePanel					= true;
    				DrawHorizontalGridLines				= true;
    				DrawVerticalGridLines				= true;
    				PaintPriceMarkers					= true;
    				ScaleJustification					= NinjaTrader.Gui.Chart.ScaleJustification.Right;
    				//Disable this property if your indicator requires custom values that cumulate with each new market data event. 
    				//See Help Guide for additional information.
    				IsSuspendedWhileInactive			= true;
    				
    				AddPlot(Brushes.ForestGreen, "Volume Ask");
    				AddPlot(Brushes.Red, "VolumeBid");
    			}
    			else if (State == State.Configure)
    			{
    				        AddDataSeries("AAPL", BarsPeriodType.Minute, 1, MarketDataType.Ask);
    						AddDataSeries("AAPL", BarsPeriodType.Minute, 1, MarketDataType.Bid);
    
    			}
    		}
    
    		protected override void OnBarUpdate()
    		{
    			 VolumeAsk[0] = Volume[0][1];
    			 VolumeBid[0]= Volume[0][2];
    		}
    	}
    	}
    Thanks a lot !

    #2
    Hello,

    Can you tell us a bit about what is going wrong with your script, and how it is not functioning as expected? That will provide us with a starting point to help you achieve your goal.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Thanks for answering !

      Well, as NT8 and NT7 langage are quite different I don't know exactly what's wrong in the script, but when I display the indicator nothing is showing up (look at the picture), and there is nothing written in the log.
      Attached Files

      Comment


        #4
        Hello,

        Thank you for the reply.

        Can you open the New -> NinjaScript Output window and then reload the indicator, is there an error listed?

        If there are no errors, can you instead provide an export of the script so I have the variables needed to run this? You can export by going to Tools -> Export -> NinjaScript.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hey Jess, here you can find the ninjascript. Thanks !

          Just would like to show the volume of executed contracts at the bid and the volume of executed contracts at the ask.
          Attached Files

          Comment


            #6
            Hello,

            Thank you for providing the script, this better shows what happened.

            I see in the script you are currently not plotting but just setting variables with the values you had defined:

            private double VolumeAsk;
            private double VolumeBid;

            VolumeAsk = Volume[0];
            VolumeBid= Volume[0];

            These would simply be double numbers but do not have anything to do with the actual plotting. In OnBarUpdate you just set these variables but no plotting ever is done to plot the values:

            Otherwise you have correctly added the series, although there is no historical Ask or Bid data for greater than 1 tick, so 1 minute would not produce any results where 1 tick would. You would need to update the AddDataSeries to the following:

            AddDataSeries("AAPL", BarsPeriodType.Tick, 1, MarketDataType.Ask);
            AddDataSeries("AAPL", BarsPeriodType.Tick, 1, MarketDataType.Bid);

            For the plotting, you could generally use something like the following code to plot the values, I did note that there is some issue happening with the Volumes collection currently which I have submitted to development for review. As of currently this would report 0 but should report the volume for each tick.

            if(BarsInProgress == 0 && CurrentBars[1] > 0 && CurrentBars[2] > 0)
            {
            Values[0][0] = Volumes[0][0];
            Values[1][0] = Volumes[1][0];
            }


            As stated this has been submitted for review, so this currently would not work correctly using the Added series. One alternative for the time being would be to use the Tick Replay feature and instead use OnMarketData() which now can work historically: http://ninjatrader.com/support/helpG...ick_replay.htm

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thanks Jesse it's very clear !

              Well, what's the title of the Volume collection issue topic ? I don't find it, it's just to know when this issue will be fixed

              Thanks !

              Comment


                #8
                Hello,

                I submitted the request under "Ask and Bid series report 0 volume in NinjaScript." but I don't have any further details on the request at this point, If I get any further updates on the item I will post them here.

                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Hey Jesse, any news to get the delta of an asset ? If no, should I expect to wait days/weeks or months lol ?

                  Comment


                    #10
                    Hi,

                    Just ran across this thread and a quick read might indicate the code isn't exactly correct. (Probably will not fix the problem, but is technically correct):

                    The code:
                    Code:
                    if(BarsInProgress == 0 && CurrentBars[1] > 0 && CurrentBars[2] > 0)
                     {
                     Values[0][0] = Volumes[0][0];
                     Values[1][0] = Volumes[1][0];
                     }
                    This shows Volumes[0]&[1], I believe these should be [1] & [2] as the primary bar (on the chart) will be [0].

                    Primary Bar Series (Chart) -> Volumes[0]
                    ASK Bar Series "AAPL" -> Volumes[1]
                    BID Bar Series "AAPL" -> Volumes[2]

                    Just a thought, sorry to poke my head in if I read something wrong.

                    Comment


                      #11
                      Hey MC, thanks for answering !

                      Well I let someone from the support agrees but I think you're right.
                      Unfortunately, it doesn't fix the issue :/ But thanks !!

                      Comment


                        #12
                        Originally posted by After View Post
                        Hey MC, thanks for answering !

                        Well I let someone from the support agrees but I think you're right.
                        Unfortunately, it doesn't fix the issue :/ But thanks !!
                        After, I may have a solution for you. I'm not sure what the current state of your code is after playing with it for a few days, but please take a look at the attached indicator, which is successfully plotting both the Bid and Ask volume historically and in real time on my machine.

                        Please let me know if this script does not work on your side. If it doesn't, then there may be something else at play.
                        Attached Files
                        Dave I.NinjaTrader Product Management

                        Comment


                          #13
                          Hey Dave,

                          Thanks ! Unfortunately, your script doesn't work on my computer (screen), what should I do ?

                          Thanks a lot !
                          Attached Files

                          Comment


                            #14
                            It looks like the issue is resolved, but the plots are not plotting on your end. Are you receiving any errors in the NinjaScript Output window or the Log grid in the Control Center?
                            Dave I.NinjaTrader Product Management

                            Comment


                              #15
                              I don't get any error in the log, but I didn't find how to display the output windows ?

                              By the way I checked your code and the only "big difference" seems to take data from a 1 minut chart, but if it works on your side it should works on mine..

                              Thanks for helping

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by hazylizard, Today, 08:38 AM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by geddyisodin, Today, 05:20 AM
                              2 responses
                              16 views
                              0 likes
                              Last Post geddyisodin  
                              Started by Max238, Today, 01:28 AM
                              5 responses
                              43 views
                              0 likes
                              Last Post Max238
                              by Max238
                               
                              Started by giulyko00, Yesterday, 12:03 PM
                              3 responses
                              13 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by habeebft, Today, 07:27 AM
                              1 response
                              16 views
                              0 likes
                              Last Post NinjaTrader_ChristopherS  
                              Working...
                              X