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

How can I use Volumetric and DataSeries in AddOns?

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

    How can I use Volumetric and DataSeries in AddOns?

    I'm trying to share code between a strategy and indicator without having to duplicate it. It seems that AddOns is the way to do it. However, I can't seem to use them in AddOns.

    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.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.Gui.Tools;
    #endregion
    
    //This namespace holds Add ons in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.AddOns
    {
        public class MyCustomAddOn : NinjaTrader.NinjaScript.AddOnBase
        {
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"Enter the description for your new custom Add on here.";
                    Name                                        = "MyCustomAddOn";
                }
                else if (State == State.Configure)
                {
                    AddVolumetric(Instrument.FullName, BarsPeriodType.Range, 15, VolumetricDeltaType.BidAsk, 1);
                    AddDataSeries(Instrument.FullName, BarsPeriodType.Tick, 1);
                }
            }
        }
    }
    
    ​

    #2
    Hello tonystarks,

    Is the indicator hosted by a host strategy? (Meaning does the strategy call the indicator and add the indicator to the chart with AddDataSeries())?

    If not, typically we would recommend a partial class, however we would recommend a partial class separate for indicators than strategies. A partial class of NinjaScript may work, but you also may find not all objects and tools available to indicators and strategies are available.

    Below is a link to an example of a partial class.
    Explanation: I wrote a base class Indicator class that I'm using to inherit all my other indicators from. So this baseclass is defined as: namespace NinjaTrader.NinjaScript.Indicators.AssistedTrades { public class ATBaseIndicator: Indicator { ... } } And any other indicator is defined as: namespace NinjaTrader.NinjaScr


    With a custom addon class that is not a partial class, you will not be able to add data series directly.
    If you pass the instance of the indicator or strategy to a static addon method, you can use that instance to perform functions.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by samish18, Yesterday, 10:13 AM
    1 response
    23 views
    0 likes
    Last Post NinjaTrader_Eduardo  
    Started by Austiner87, Today, 05:02 PM
    0 responses
    5 views
    0 likes
    Last Post Austiner87  
    Started by tonynt, 05-21-2019, 06:27 AM
    10 responses
    530 views
    1 like
    Last Post fiendtrades  
    Started by awwenzovs, Today, 08:03 AM
    2 responses
    15 views
    0 likes
    Last Post NinjaTrader_Eduardo  
    Started by Ashkam, 04-29-2024, 09:28 AM
    4 responses
    44 views
    0 likes
    Last Post Ashkam
    by Ashkam
     
    Working...
    X