• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Chart Marker Drawing How to select via OnStartup

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

    Chart Marker Drawing How to select via OnStartup

    I am trying to simplify and improve on using DrawArrowUp, DrawDot, DrawText, etc by being able to define which marker draw will be used and being able to set it in the OnStartUp() instead of having to check which draw to use in the OnBarUpdate();

    Selecting different EMA's can be accomplished using IDataSeries as in the attached Example. Is there a way this can be done with DrawArrowUp,DrawDot, etc???


    // Example
    public class MyCustomIndicator : Indicator
    {
    #region Variables

    private int myMAperiod = 10; // Default setting for MyInput0

    private IDataSeries myMA;
    private myMAType myMovAvg = myMAType.EMA;
    public enum myMAType { EMA,SMA,WMA,VWMA };

    #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 OnStartUp()
    {

    switch (MyMovAvg)
    {
    case myMAType.EMA:
    myMA = (EMA(Input, MyMAperiod));
    break;
    case myMAType.SMA:
    myMA = (SMA(Input, MyMAperiod));
    break;
    case myMAType.WMA:
    myMA = (WMA(Input, MyMAperiod));
    break;
    case myMAType.VWMA:
    myMA = (VWMA(Input, MyMAperiod));
    break;

    }
    }
    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(myMA[0]);
    }
    Attached Files

    #2
    Hello TraderJesse,

    Thank you for your post.

    I can't think of a way to do this as we would need to tell NinjaTrader to draw, and there really isn't a means to do so if we use an enum.

    I would recommend going the route of creating an enum that calls your own custom plotting by overriding the Plot method. For an example please go to Tools > Edit NinjaScript > Indicator > CustomPlotSample.
    Patrick H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by ajay8000, Yesterday, 11:31 PM
    5 responses
    19 views
    0 likes
    Last Post NinjaTrader_Marco  
    Started by simjs, Yesterday, 11:23 PM
    0 responses
    5 views
    0 likes
    Last Post simjs
    by simjs
     
    Started by akuntysh, Yesterday, 10:41 PM
    0 responses
    4 views
    0 likes
    Last Post akuntysh  
    Started by Wolf1, Yesterday, 08:26 PM
    0 responses
    7 views
    0 likes
    Last Post Wolf1
    by Wolf1
     
    Started by pparmley, Yesterday, 04:30 PM
    0 responses
    9 views
    0 likes
    Last Post pparmley  
    Working...
    X