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

general question

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

    general question

    hi guys i want try to see this example


    Examples
    protected override void OnMarketDepth(MarketDepthEventArgs e)
    {
    // Print some data to the Output window
    if (e.MarketDataType == MarketDataType.Ask && e.Operation == Operation.Update)
    Print("The most recent ask change is " + e.Price + " " + e.Volume);
    }



    i have created this indicator
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.IO;
    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>
    /// Extracts the futures data
    /// </summary>
    [Description("Extracts the futures data")]
    public class DataFutures : Indicator
    {
    #region Variables
    // Wizard generated variables
    // User defined variables (add any user defined variables below)
    private int myInput0 = 1; // Default setting for MyInput0
    #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 = true;
    //Print("Test");
    }

    /// <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

    }



    protected override void OnMarketDepth(MarketDepthEventArgs e)
    {
    // Print some data to the Output window
    if (e.MarketDataType == MarketDataType.Ask && e.Operation == Operation.Update)
    Print("The most recent ask change is " + e.Price + " " + e.Volume);
    }


    #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 DataFutures[] cacheDataFutures = null;

    private static DataFutures checkDataFutures = new DataFutures();

    /// <summary>
    /// Extracts the futures data
    /// </summary>
    /// <returns></returns>
    public DataFutures DataFutures()
    {
    return DataFutures(Input);
    }

    /// <summary>
    /// Extracts the futures data
    /// </summary>
    /// <returns></returns>
    public DataFutures DataFutures(Data.IDataSeries input)
    {
    if (cacheDataFutures != null)
    for (int idx = 0; idx < cacheDataFutures.Length; idx++)
    if (cacheDataFutures[idx].EqualsInput(input))
    return cacheDataFutures[idx];

    lock (checkDataFutures)
    {
    if (cacheDataFutures != null)
    for (int idx = 0; idx < cacheDataFutures.Length; idx++)
    if (cacheDataFutures[idx].EqualsInput(input))
    return cacheDataFutures[idx];

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

    DataFutures[] tmp = new DataFutures[cacheDataFutures == null ? 1 : cacheDataFutures.Length + 1];
    if (cacheDataFutures != null)
    cacheDataFutures.CopyTo(tmp, 0);
    tmp[tmp.Length - 1] = indicator;
    cacheDataFutures = 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>
    /// Extracts the futures data
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.DataFutures DataFutures()
    {
    return _indicator.DataFutures(Input);
    }

    /// <summary>
    /// Extracts the futures data
    /// </summary>
    /// <returns></returns>
    public Indicator.DataFutures DataFutures(Data.IDataSeries input)
    {
    return _indicator.DataFutures(input);
    }
    }
    }

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    public partial class Strategy : StrategyBase
    {
    /// <summary>
    /// Extracts the futures data
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.DataFutures DataFutures()
    {
    return _indicator.DataFutures(Input);
    }

    /// <summary>
    /// Extracts the futures data
    /// </summary>
    /// <returns></returns>
    public Indicator.DataFutures DataFutures(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.DataFutures(input);
    }
    }
    }
    #endregion

    but return me many error
    someone can help me ?
    thankz

    #2
    Hello faustf,

    Thank you for the post.

    What error are you seeing? Was this a compile error or when you ran it?

    I see that the code can compile and I ran it but see no errors. Could you explain in more detail what the problem you are having is?

    As a side note, for future attachments you can attach the .cs file for the script instead of pasting the entire contents, the file resides in the folder: Documents\NinjaTrader 7\bin\Custom\Indicator

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

    Comment


      #3
      i have always this error
      ' does not contain a definition for 'MyInput0' and no extension method 'MyInput0' accepting a first argument of type 'NinjaTrader.I

      cs1061

      Comment


        #4
        Hello faustf,

        In what you provided I don't see an error, I also see that this can compile on my end. I would suggest to try and attach the file directly in case something was left out, otherwise because the file is just being started you may want to delete this and create a new indicator. The MyInput is a generic input that is generated in a new indicator by default, that by default will compile if you don't change or remove the code associated with it. You can also use the indicator wizard when you create the indicator to remove the input if it is not needed.

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

        Comment


          #5
          thankz i resolve

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by bmartz, 03-12-2024, 06:12 AM
          5 responses
          32 views
          0 likes
          Last Post NinjaTrader_Zachary  
          Started by Aviram Y, Today, 05:29 AM
          4 responses
          13 views
          0 likes
          Last Post Aviram Y  
          Started by algospoke, 04-17-2024, 06:40 PM
          3 responses
          28 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by gentlebenthebear, Today, 01:30 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by cls71, Today, 04:45 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X