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

e.Option does not contain definition

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

    e.Option does not contain definition

    hi guys i try to print e.Option but when i do it return me error not contain definition of e.Option
    why ?
    thankz

    #2
    Hello faustf,

    Where did the e variable come from? Are you using an override or what is the context that you are asking about?

    If the error states that Option is not defined in the object e that is very likely correct. You are either not using the correct syntax for the type of object you wanted or that type of object doesn't have a property called Option and you need something else.

    I would need more specific details here about what code is being used to know what should or should not be available for the e object.

    For additional context, this is not a NinjaScript error but is a C# error. You can learn more about this type of error by searching google for the error message.



    I look forward to being of further assistance.


    JesseNinjaTrader Customer Service

    Comment


      #3
      this is my script
      #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 TEST1 : Indicator
      {
      #region Variables
      // Wizard generated variables
      private int myInput0 = 1; // Default setting for MyInput0
      // User defined variables (add any user defined variables below)
      #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()
      {
      Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
      Overlay = false;
      }

      /// <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.
      Plot0.Set(Close[0]);
      }
      protected override void OnMarketData(MarketDataEventArgs e)
      {
      // Print some data to the Output window

      if (e.MarketDataType == MarketDataType.Last)
      //Print("Last = " + e.Price + " " + e.Volume);

      Print("DEM MADE LAST"+ e.MarketDataType + ";" + e.Operation + ";" + e.Position + ";" + e.Price + ";" + e.Volume);
      else if (e.MarketDataType == MarketDataType.Ask)
      // Print("Ask = " + e.Price + " " + e.Volume);
      Print("DEM MADE ASK"+ e.MarketDataType + ";" + e.Operation + ";" + e.Position + ";" + e.Price + ";" + e.Volume);

      else if (e.MarketDataType == MarketDataType.Bid)
      // Print("Bid = " + e.Price + " " + e.Volume);
      Print("DEM MADE BID"+ e.MarketDataType + ";" + e.Operation + ";" + e.Position + ";" + e.Price + ";" + e.Volume);

      }
      #region Properties
      [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
      [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
      public DataSeries Plot0
      {
      get { return Values[0]; }
      }

      [Description("")]
      [GridCategory("Parameters")]
      public int MyInput0
      {
      get { return myInput0; }
      set { myInput0 = Math.Max(1, value); }
      }
      #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 TEST1[] cacheTEST1 = null;

      private static TEST1 checkTEST1 = new TEST1();

      /// <summary>
      /// Enter the description of your new custom indicator here
      /// </summary>
      /// <returns></returns>
      public TEST1 TEST1(int myInput0)
      {
      return TEST1(Input, myInput0);
      }

      /// <summary>
      /// Enter the description of your new custom indicator here
      /// </summary>
      /// <returns></returns>
      public TEST1 TEST1(Data.IDataSeries input, int myInput0)
      {
      if (cacheTEST1 != null)
      for (int idx = 0; idx < cacheTEST1.Length; idx++)
      if (cacheTEST1[idx].MyInput0 == myInput0 && cacheTEST1[idx].EqualsInput(input))
      return cacheTEST1[idx];

      lock (checkTEST1)
      {
      checkTEST1.MyInput0 = myInput0;
      myInput0 = checkTEST1.MyInput0;

      if (cacheTEST1 != null)
      for (int idx = 0; idx < cacheTEST1.Length; idx++)
      if (cacheTEST1[idx].MyInput0 == myInput0 && cacheTEST1[idx].EqualsInput(input))
      return cacheTEST1[idx];

      TEST1 indicator = new TEST1();
      indicator.BarsRequired = BarsRequired;
      indicator.CalculateOnBarClose = CalculateOnBarClose;
      #if NT7
      indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
      indicator.MaximumBarsLookBack = MaximumBarsLookBack;
      #endif
      indicator.Input = input;
      indicator.MyInput0 = myInput0;
      Indicators.Add(indicator);
      indicator.SetUp();

      TEST1[] tmp = new TEST1[cacheTEST1 == null ? 1 : cacheTEST1.Length + 1];
      if (cacheTEST1 != null)
      cacheTEST1.CopyTo(tmp, 0);
      tmp[tmp.Length - 1] = indicator;
      cacheTEST1 = 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.TEST1 TEST1(int myInput0)
      {
      return _indicator.TEST1(Input, myInput0);
      }

      /// <summary>
      /// Enter the description of your new custom indicator here
      /// </summary>
      /// <returns></returns>
      public Indicator.TEST1 TEST1(Data.IDataSeries input, int myInput0)
      {
      return _indicator.TEST1(input, myInput0);
      }
      }
      }

      // 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.TEST1 TEST1(int myInput0)
      {
      return _indicator.TEST1(Input, myInput0);
      }

      /// <summary>
      /// Enter the description of your new custom indicator here
      /// </summary>
      /// <returns></returns>
      public Indicator.TEST1 TEST1(Data.IDataSeries input, int myInput0)
      {
      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.TEST1(input, myInput0);
      }
      }
      }
      #endregion

      Comment


        #4
        Hello faustf,

        I don't see where you used the e.Option in this code. If you are using OnMarketData that is not a property of the MarketDataEventArgs object. What option are you trying to access or what are you trying to do?



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

        Comment


          #5
          another questions when i print e.Price if price is 1.52623 is ok if price is 1.50000 , it print me 1.5 is possible normalize a double ?

          Comment


            #6
            Hello,

            Yes you can format numbers in C#, that specifically is not going to be something which would be documented with NinjaScript. If you wanted to round it you can use Math.Round: https://docs.microsoft.com/en-us/dot..._System_Int32_

            If you otherwise want to trim the number of decimal places without rounding you can do a quick search on google for "C# trim decimal places" for some examples of how to do that.


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

            Comment


              #7
              mat round dont do what i ask ,
              with mat round if you have a number 1.525255252525225255255552225 you can round at 1.52525 , but if price is 1.50000 and you cal by e.Price return 1.5 and if you do math round 1.5 , 5 not add 0000 but return 1.5 f....

              Comment


                #8
                Hello faustf,

                Are you trying to format the number in some way?

                it sounds like you may want a string and not a number here if you want the remainder to have 0's added if the value is not as many decimals. 1.5 and 1.50000 are the same number so logically that would work the same in any conditions, if you are trying to display this in some way you would likely need a string or to format the value instead of rounding it.

                If you are unable to resolve the issue based on the new information I would suggest to include details on what your use case for this number is so that I can better understand what you want to do.


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

                Comment


                  #9
                  when i think at trading and platform , like NJ or Sierrchart or many other for Future directly connected with data feed , i immagine fast exchange data platform to datafeed , after......... try also to create some script (c# very hard for biginner , easy language no ??ok) , and Develop for Add 2 or 3 or 4 or 5 zero after dot , you must lose time to e.Price = convert to string count how many number after dot and after this if < 5 insert 0 to 5' digit if you do this many time , probably decrease performance of your script , i think a method e.Price should return all digit , because is a method for trading platform , not method for general prupose, but iam old ...... thankz








                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Mongo, Today, 11:05 AM
                  4 responses
                  14 views
                  0 likes
                  Last Post Mongo
                  by Mongo
                   
                  Started by traderqz, Today, 12:06 AM
                  7 responses
                  14 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by Skifree, Today, 03:41 AM
                  5 responses
                  13 views
                  0 likes
                  Last Post Skifree
                  by Skifree
                   
                  Started by traderqz, Yesterday, 09:06 AM
                  5 responses
                  35 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by guillembm, Today, 11:25 AM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X