• 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 Jurase, Today, 06:47 PM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_EricB  
    Started by GTBrooks, Today, 05:53 PM
    0 responses
    1 view
    0 likes
    Last Post GTBrooks  
    Started by jeronymite, Today, 04:50 PM
    0 responses
    5 views
    0 likes
    Last Post jeronymite  
    Started by daigo1, Today, 04:41 PM
    0 responses
    11 views
    0 likes
    Last Post daigo1
    by daigo1
     
    Started by Harrylwd4, Today, 03:15 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Working...
    X