Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Executed contract Ask/Bid indicator

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

    #16
    Please take a look at the Output Window via Tools > NinjaScript Output, and then reload the script. If there is anything preventing the script from plotting, you should see a message in that window. If you do not see anything after reloading NinjaScript with the Output Window open, then there may be something else occurring.
    Dave I.NinjaTrader Product Management

    Comment


      #17
      Thanks ! Well, still nothing. I installed NT8 yesterday and uploaded a new continuum sim connection to be sure everything was okay on this side.
      Attached Files

      Comment


        #18
        Is there any way you can export and attach the code in its current state on your machine? I'd like to take a look and see if anything stands out to me.
        Dave I.NinjaTrader Product Management

        Comment


          #19
          Sure, here you can find it

          Just tried with the new release, still the same result
          Attached Files

          Comment


            #20
            Can you please tell me which data provider you are connected to? In that script, we are adding two EURUSD data series, so if you are not connected to a forex data provider, then you should be able to resolve this by changing the instrument to a futures contract (or just adding Instrument.MasterInstrument.Name instead).
            Dave I.NinjaTrader Product Management

            Comment


              #21
              Oh might be the issue I'm with continuum !

              Code:
              AddDataSeries("FDAX 12-15", BarsPeriodType.Minute, 1, MarketDataType.Bid);
              AddDataSeries("FDAX 12-15", BarsPeriodType.Minute, 1, MarketDataType.Ask);
              Is this correct ?

              Comment


                #22
                Yes, that should do the trick for you.
                Dave I.NinjaTrader Product Management

                Comment


                  #23
                  Well it shows something now but results are very strange, look at the screen : totale volume = 121 (seems okay), bid volume = 1139 and ask volume =679 ?
                  Attached Files

                  Comment


                    #24
                    Hello,

                    Thank you for there reply.

                    I just wanted to confirm, are you asking about comparing the VOL or main series Volume to the Ask and Bid volumes?

                    In this case based on what is in the image, the Ask and Bid plots would represent the volume of operations for ask and bid. VOL indicator or charts Volume you are looking at would reference the Executed volume. The values in this case would not add up or could be very different values.

                    Please let me know if I may be of further assistance.

                    Comment


                      #25
                      Originally posted by NinjaTrader_Jesse View Post
                      I just wanted to confirm, are you asking about comparing the VOL or main series Volume to the Ask and Bid volumes?
                      .
                      Of course, I just want to get executed contract volume at the ask and executed volume contract at the bid. So VOL = executed contract = executed contract ASK (selling market orders volume) + executed contract BID (buying market orders volume).

                      So, any way to get the executed contract volume at the ask and at the bid ?

                      Comment


                        #26
                        Originally posted by After View Post
                        Of course, I just want to get executed contract volume at the ask and executed volume contract at the bid. So VOL = executed contract = executed contract ASK (selling market orders volume) + executed contract BID (buying market orders volume).

                        So, any way to get the executed contract volume at the ask and at the bid ?
                        You will need to enable "Tick Replay" to get this sort of precision from tick data.



                        Once enabled, you can program a script to check if the current execution price was at the ask, or the bid, and keep track of the volume there. You can take a look at some of the system indicators which employ similar techniques such as the BuySellVolume indicator:

                        MatthewNinjaTrader Product Management

                        Comment


                          #27
                          Thanks Matthew !
                          Last edited by After; 10-29-2015, 05:48 PM.

                          Comment


                            #28
                            Just to be clear: You need to use OnMarketData and use the Last Update and compare against the current Ask/Bid price fields in that updated object. Adding a Tick Data Series of market data type ask/bid does not contain the information you're after. Here is more information on developing for tick replay: http://ninjatrader.com/support/helpG...ick_replay.htm
                            MatthewNinjaTrader Product Management

                            Comment


                              #29
                              Oh okay so OnBarUpdate() won't work

                              I tried this based on the example but I don't get how to put it in work, could you tell me how plot the results and fixed the issue (replace MarketDataEventsArgs by what etc..) ? (important part in bold)

                              Thanks !!

                              Code:
                              #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 Indicators in this folder and is required. Do not change it. 
                              namespace NinjaTrader.NinjaScript.Indicators
                              {
                              	public class MarketDataBidAsk : Indicator
                              	{
                              
                              		
                              		private Series<double> CumuleAsk;
                              		private Series<double> CumuleBid;
                              		
                              		protected override void OnStateChange()
                              		{
                              			if (State == State.SetDefaults)
                              			{
                              				Description							= @"Enter the description for your new custom Indicator here.";
                              				Name								= "MarketDataBidAsk";
                              				Calculate							= Calculate.OnEachTick;
                              				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;
                              			}
                              			else if (State == State.Configure)
                              			{
                              CumuleAsk = new Series<double>(this, MaximumBarsLookBack.Infinite);
                              CumuleBid = new Series<double>(this, MaximumBarsLookBack.Infinite);
                              			}
                              		}
                              
                              		protected override void OnBarUpdate()
                              		{
                              			//Add your custom indicator logic here.
                              		}
                              		[B]
                              		protected override void OnMarketData(MarketDataEventsArgs marketDataUpdate)
                              		{
                              			
                              			if (marketDataUpdate.MarketDataType == MarketDataType.Last)
                              			{
                              				if (marketDataUpdate.Price >= marketDataUpdate.Ask)
                              				{
                              					CumuleAsk[0] = CumuleAsk[1] + 1;
                              				}
                              				
                              				else if (marketDataUpdate.Price <= marketDataUpdate.Bid)
                              				{
                              					CumuleBid[0]= CumuleBid[1] + 1;
                              				}
                              			}
                              		}
                              	}[/B]
                              }
                              
                              #region NinjaScript generated code. Neither change nor remove.
                              
                              namespace NinjaTrader.NinjaScript.Indicators
                              {
                              	public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
                              	{
                              		private MarketDataBidAsk[] cacheMarketDataBidAsk;
                              		public MarketDataBidAsk MarketDataBidAsk()
                              		{
                              			return MarketDataBidAsk(Input);
                              		}
                              
                              		public MarketDataBidAsk MarketDataBidAsk(ISeries<double> input)
                              		{
                              			if (cacheMarketDataBidAsk != null)
                              				for (int idx = 0; idx < cacheMarketDataBidAsk.Length; idx++)
                              					if (cacheMarketDataBidAsk[idx] != null &&  cacheMarketDataBidAsk[idx].EqualsInput(input))
                              						return cacheMarketDataBidAsk[idx];
                              			return CacheIndicator<MarketDataBidAsk>(new MarketDataBidAsk(), input, ref cacheMarketDataBidAsk);
                              		}
                              	}
                              }
                              
                              namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
                              {
                              	public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
                              	{
                              		public Indicators.MarketDataBidAsk MarketDataBidAsk()
                              		{
                              			return indicator.MarketDataBidAsk(Input);
                              		}
                              
                              		public Indicators.MarketDataBidAsk MarketDataBidAsk(ISeries<double> input )
                              		{
                              			return indicator.MarketDataBidAsk(input);
                              		}
                              	}
                              }
                              
                              namespace NinjaTrader.NinjaScript.Strategies
                              {
                              	public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
                              	{
                              		public Indicators.MarketDataBidAsk MarketDataBidAsk()
                              		{
                              			return indicator.MarketDataBidAsk(Input);
                              		}
                              
                              		public Indicators.MarketDataBidAsk MarketDataBidAsk(ISeries<double> input )
                              		{
                              			return indicator.MarketDataBidAsk(input);
                              		}
                              	}
                              }
                              
                              #endregion

                              Comment


                                #30
                                Hello,

                                Thank you for the question.

                                It looks like you have misspelled MarketDataEventArgs, you have Events rather than Event. After changing to:

                                MarketDataEventArgs

                                you should no longer have compile errors, this is in the Help guide if you would like to copy and paste or press F2 in the editor for a snippet.

                                For plotting, There are many examples in the built in indicators such as the SMA, this indicator is a simple example on plotting.

                                You can also find more information on plotting here:



                                I look forward to being of further assistance.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                672 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                379 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                111 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                577 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                582 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X