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

Simple Total FootPrint Bid x Ask

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

    #16
    I'm coming.back from work...sorry for delay. I have used a.wizard creator of ninja and I added only the function OnMarketData. At Home I will add other screen and more details

    Comment


      #17
      Originally posted by NinjaTrader_Cal View Post
      Ketron82,

      The screenshot you sent shows compile errors but not for the indicator in question. The errors are actually point towards another indicator called ASKBIDPRICE.CS

      I would open that file and compile that code.
      I would use this function
      Code:
      	protected override void OnMarketData(MarketDataEventArgs e)
      {
          // Print some data to the Output window
          if (e.MarketDataType == MarketDataType.Last) 
                Print("Last = " + e.Price + " " + e.Volume);
       
          else if (e.MarketDataType == MarketDataType.Ask)
               Print("Ask = " + e.Price + " " + e.Volume);
          else if (e.MarketDataType == MarketDataType.Bid)
               Print("Bid = " + e.Price + " " + e.Volume);
      }
      and I have made a Wizard Indicator (ASKBIDPRICE : Indicator) to set a basical setting and next I added this function in the code.

      in C++ I have a main program and the subfunction and I recall subfunction from the main......in c# for ninja should be the same...or not?

      Comment


        #18
        Ketron82,

        Just to clarify, are you still receiving an error for the OnMarketData() for the ASKBIDPRICE?
        Cal H.NinjaTrader Customer Service

        Comment


          #19
          I think that I made conceptual error becuase I simply follow the WIZARD and at the end I click GENERATE but I get error. Could I have some settings wrong in NinjaCompiler?
          I post all my simply step:

          1) http://clip2net.com/s/5V9KFp
          2) http://clip2net.com/s/5V9M4H
          3) http://clip2net.com/s/5V9Obd
          4) http://clip2net.com/s/5V9RTM
          5) http://clip2net.com/s/5V9SOu
          6) http://clip2net.com/s/5V9Yug

          P.s. If I solve It....like I do in C++ or MQL....I will add the funcrtion OnMarketData() with only a print command (for begin) to put some value in the OutputWindow.

          Many Many thanks and sorry for my elementary english
          Last edited by ketron82; 10-09-2013, 08:55 AM.

          Comment


            #20
            Ketron82,

            Can you please send me a ticket to support[at]ninjatrader[dot]com with ATTN Cal in the subject line and a reference to this post in the body.
            Cal H.NinjaTrader Customer Service

            Comment


              #21
              The compiling problem was that Ninja compile all the file not compilet yet. With NinjaTrader_Cal that helped me...I removed the other incomplete indicator and the problem has disappeared.

              Many thanks again to NinjaTrader_Cal

              Now....I will continue experiment and I will post news on this thread
              Last edited by ketron82; 10-09-2013, 02:52 PM.

              Comment


                #22
                Well...I started test
                For now....I would simply cumulate ask volume and bid vol.
                I simply have to compare last price with ask or bid price...and so:
                if Last Price==Ask Price --> Volume of last price is ASK
                if Last Price==Bid Price --> Volume of last price is BID

                and I made this code that working but have some problem yet.

                Code:
                #region Using declarations
                using System;
                using System.ComponentModel;
                using System.Diagnostics;
                using System.Drawing;
                using System.Drawing.Drawing2D;
                using System.Xml.Serialization;
                using NinjaTrader.Cbi;
                using NinjaTrader.Data;
                using NinjaTrader.Gui.Chart;
                #endregion
                
                // This namespace holds all indicators and is required. Do not change it.
                namespace NinjaTrader.Indicator
                {
                    /// <summary>
                    /// Enter the description of your new custom indicator here
                    /// </summary>
                    [Description("Enter the description of your new custom indicator here")]
                    public class TEST : Indicator
                    {
                        #region Variables
                        // Wizard generated variables
                        // User defined variables (add any user defined variables below)
                        public DataSeries price;
                		public DataSeries volume;
                		public long volask;
                		public long volbid;
                		public long vol;
                		public double prezzo;
                		public int count;
                		
                		#endregion
                
                        /// <summary>
                        /// This method is used to configure the indicator and is called once before any bar data is loaded.
                        /// </summary>
                        protected override void Initialize()
                        {
                            Overlay				= false;
                			double[] price;
                			int[] volume;
                			volask=0;
                			volbid=0;
                			prezzo=0;
                        }
                
                        /// <summary>
                        /// Called on each bar update event (incoming tick)
                        /// </summary>
                        protected override void OnBarUpdate()
                        {
                            // Use this method for calculating your indicator values. Assign a value to each
                            // plot below by replacing 'Close[0]' with your own formula.
                
                		  
                			
                		}
                        
                			protected override void OnMarketData(MarketDataEventArgs e)
                {
                    // Print some data to the Output window
                    if (e.MarketDataType == MarketDataType.Last) 
                         { Print("Last = " + e.Price + " " + e.Volume /*+ "// current ask = "+ GetCurrentAsk() + " current bid = "+ GetCurrentBid()*/);
                	        prezzo=e.Price;
                			vol=e.Volume;
                //			if(prezzo==GetCurrentAsk())
                //			{volask=e.Volume+volask;
                //		     Print(" ###### ASK ######## " + prezzo + "  " + volask);
                //			} 
                //			if(prezzo==GetCurrentBid())
                //			{volbid=e.Volume+volbid;
                //		     Print(" ###### BID ######## " + prezzo + "  " + volbid);
                //			} 
                			
                			
                	     } 
                	else if (e.MarketDataType == MarketDataType.Ask)
                		//Print("Ask = " + e.Price + " " + e.Volume);
                			{ if(prezzo==e.Price && vol!=0)
                				{
                					volask=volask+vol;
                		     		Print(" ###### ASK ######## Prezzo Last= " + prezzo + " ## Prezzo Ask " + e.Price + " ## Volume ASK= " + volask);
                				vol=0;
                				}
                			} 
                	else if (e.MarketDataType == MarketDataType.Bid)
                		//Print("Bid = " + e.Price + " " + e.Volume);
                			{ if(prezzo==e.Price  && vol!=0)
                				{
                					volbid=volbid+vol;
                		     		Print(" ###### BID ######## Prezzo Last= " + prezzo + " ## Prezzo Bid " + e.Price + " ## Volume BID= " + volbid);
                				vol=0;
                				}
                			} 
                	
                	
                	
                	
                	
                }
                        #region Properties
                
                        #endregion
                    }
                }
                
                #region NinjaScript generated code. Neither change nor remove.
                // This namespace holds all indicators and is required. Do not change it.
                namespace NinjaTrader.Indicator
                {
                    public partial class Indicator : IndicatorBase
                    {
                        private TEST[] cacheTEST = null;
                
                        private static TEST checkTEST = new TEST();
                
                        /// <summary>
                        /// Enter the description of your new custom indicator here
                        /// </summary>
                        /// <returns></returns>
                        public TEST TEST()
                        {
                            return TEST(Input);
                        }
                
                        /// <summary>
                        /// Enter the description of your new custom indicator here
                        /// </summary>
                        /// <returns></returns>
                        public TEST TEST(Data.IDataSeries input)
                        {
                            if (cacheTEST != null)
                                for (int idx = 0; idx < cacheTEST.Length; idx++)
                                    if (cacheTEST[idx].EqualsInput(input))
                                        return cacheTEST[idx];
                
                            lock (checkTEST)
                            {
                                if (cacheTEST != null)
                                    for (int idx = 0; idx < cacheTEST.Length; idx++)
                                        if (cacheTEST[idx].EqualsInput(input))
                                            return cacheTEST[idx];
                
                                TEST indicator = new TEST();
                                indicator.BarsRequired = BarsRequired;
                                indicator.CalculateOnBarClose = CalculateOnBarClose;
                #if NT7
                                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
                #endif
                                indicator.Input = input;
                                Indicators.Add(indicator);
                                indicator.SetUp();
                
                                TEST[] tmp = new TEST[cacheTEST == null ? 1 : cacheTEST.Length + 1];
                                if (cacheTEST != null)
                                    cacheTEST.CopyTo(tmp, 0);
                                tmp[tmp.Length - 1] = indicator;
                                cacheTEST = tmp;
                                return indicator;
                            }
                        }
                    }
                }
                
                // This namespace holds all market analyzer column definitions and is required. Do not change it.
                namespace NinjaTrader.MarketAnalyzer
                {
                    public partial class Column : ColumnBase
                    {
                        /// <summary>
                        /// Enter the description of your new custom indicator here
                        /// </summary>
                        /// <returns></returns>
                        [Gui.Design.WizardCondition("Indicator")]
                        public Indicator.TEST TEST()
                        {
                            return _indicator.TEST(Input);
                        }
                
                        /// <summary>
                        /// Enter the description of your new custom indicator here
                        /// </summary>
                        /// <returns></returns>
                        public Indicator.TEST TEST(Data.IDataSeries input)
                        {
                            return _indicator.TEST(input);
                        }
                    }
                }
                
                // This namespace holds all strategies and is required. Do not change it.
                namespace NinjaTrader.Strategy
                {
                    public partial class Strategy : StrategyBase
                    {
                        /// <summary>
                        /// Enter the description of your new custom indicator here
                        /// </summary>
                        /// <returns></returns>
                        [Gui.Design.WizardCondition("Indicator")]
                        public Indicator.TEST TEST()
                        {
                            return _indicator.TEST(Input);
                        }
                
                        /// <summary>
                        /// Enter the description of your new custom indicator here
                        /// </summary>
                        /// <returns></returns>
                        public Indicator.TEST TEST(Data.IDataSeries input)
                        {
                            if (InInitialize && input == null)
                                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
                
                            return _indicator.TEST(input);
                        }
                    }
                }
                #endregion
                In the Output Window I saw that sometime....last price is not equal askprice or bid price and I don't know why.




                Can someone help me to modify the code?

                P.s. Next step after have solved this problem is to make experiment with array (dataseries) to start a structure to archive footprint in row and column.

                TNX to ALL
                Last edited by ketron82; 10-10-2013, 06:13 AM.

                Comment


                  #23
                  when onmarketdata is called....it means that a time and sales changed....or not?
                  So...how is the sequence?
                  I make testing but I think that I make conceptual error...!

                  Comment


                    #24
                    I made other tests but I cannot solve this problem....with this simple function, in the Output Windows I sometime read that "last price" is not equal at askprice or bid price....and this is strange.



                    Any ideas?


                    Code:
                    protected override void OnMarketData(MarketDataEventArgs e)
                    			{	
                        // Print some data to the Output window
                        if (e.MarketDataType == MarketDataType.Last) 
                             { 
                    			//Print("### Last = " + e.Price + " " + e.Volume +  " Bid Price= " + GetCurrentBid() + "  Ask Price= " + GetCurrentAsk());
                    			
                    		
                    		 }	
                    
                    			
                    			
                    	     
                    //	else if (e.MarketDataType == MarketDataType.Ask)
                    //		{
                    //        Print("Ask = " + e.Price + " " + e.Volume);
                    //	  
                    //		}	
                    //	else if (e.MarketDataType == MarketDataType.Bid)
                    //		{
                    //	    Print("Bid = " + e.Price + " " + e.Volume);
                    //	    
                    //	    }
                    	
                    //Print("Posizione = " + vol + "\n\n");
                    	
                    			}
                    Last edited by ketron82; 10-10-2013, 01:14 PM.

                    Comment


                      #25


                      This is the screenshot where I compare MarketDelta (iqfeed) and Ninja (iqfeed).
                      I think that there is some problem using getcurrentask() or getcurrentbid() in onmarketdata() function....I make a conceptual error but I haven't found a correct logical working of onmarketdata()

                      How is a best way to use onmarketdata() ?

                      I made other test without getcurrentask and getcurrentbid but using

                      else if (e.MarketDataType == MarketDataType.Ask)

                      but something go wrong however.

                      Any ideas?

                      Comment


                        #26
                        Ketron82,

                        OnMarketData() is a method used to call with ask, bid, last prices in that nature.

                        When a tick comes in this method will get called and calculate any actions that you have in the method.

                        As such, you can have the OnMarketData() draw an arrow when a particular data comes in, like a bid price.

                        Example -
                        Code:
                        protected override OnMarketData(MarketDataEventArgs e)
                        {
                             if (e.MarketDataType == MarketDataType.Bid)
                             {
                                 //Draw Object here
                             }
                        }
                        http://www.ninjatrader.com/support/h...aeventargs.htm
                        Cal H.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by techgetgame, Today, 11:42 PM
                        0 responses
                        1 view
                        0 likes
                        Last Post techgetgame  
                        Started by sephichapdson, Today, 11:36 PM
                        0 responses
                        1 view
                        0 likes
                        Last Post sephichapdson  
                        Started by bortz, 11-06-2023, 08:04 AM
                        47 responses
                        1,612 views
                        0 likes
                        Last Post aligator  
                        Started by jaybedreamin, Today, 05:56 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post jaybedreamin  
                        Started by DJ888, 04-16-2024, 06:09 PM
                        6 responses
                        19 views
                        0 likes
                        Last Post DJ888
                        by DJ888
                         
                        Working...
                        X