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

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.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by mjairg, 07-20-2023, 11:57 PM
    3 responses
    213 views
    1 like
    Last Post PaulMohn  
    Started by TheWhiteDragon, 01-21-2019, 12:44 PM
    4 responses
    544 views
    0 likes
    Last Post PaulMohn  
    Started by GLFX005, Today, 03:23 AM
    0 responses
    3 views
    0 likes
    Last Post GLFX005
    by GLFX005
     
    Started by XXtrader, Yesterday, 11:30 PM
    2 responses
    12 views
    0 likes
    Last Post XXtrader  
    Started by Waxavi, Today, 02:10 AM
    0 responses
    7 views
    0 likes
    Last Post Waxavi
    by Waxavi
     
    Working...
    X