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

Why lines dont plot on chart

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

    Why lines dont plot on chart

    HI i simply want to show difference in ticks between two emas on chart. However my indicator lines dont show up on chart

    Code:
    {
            private double fastValue;
            private double slowValue;
            private double diff;
            private double ang;
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"Enter the description for your new custom Indicator here.";
                    Name                                        = "Angulation";
                    Calculate                                    = Calculate.OnBarClose;
                    IsOverlay                                    = true;
                    DisplayInDataBox                            = true;
                    DrawOnPricePanel                            = true;
                    DrawHorizontalGridLines                        = true;
                    DrawVerticalGridLines                        = true;
                    PaintPriceMarkers                            = true;
                    ScaleJustification                            = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                    //See Help Guide for additional information.
                    IsSuspendedWhileInactive                    = true;
                    FastEMA                    = 8;
                    SlowEMA                    = 34;
                    AddPlot(Brushes.Orange, "SEMA");
                    AddPlot(Brushes.DodgerBlue, "FEMA");
    
    
                }
                else if (State == State.Configure)
                {
                }
            }
    
            protected override void OnBarUpdate()
            {
                fastValue = EMA(Close,FastEMA)[0];
                slowValue = EMA(Close,SlowEMA)[0];
                diff = Math.Abs(fastValue - slowValue);
                ang = Math.Round(diff);
                Print(diff);
                Draw.TextFixed(this, "tag1", "Current Angulation " + ang.ToString(), TextPosition.BottomRight);​
    Code:
    #region Properties
            [NinjaScriptProperty]
            [Range(1, int.MaxValue)]
            [Display(Name="FastEMA", Order=1, GroupName="Parameters")]
            public int FastEMA
            { get; set; }
    
            [NinjaScriptProperty]
            [Range(1, int.MaxValue)]
            [Display(Name="SlowEMA", Order=2, GroupName="Parameters")]
            public int SlowEMA
            { get; set; }
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> SEMA
            {
                get { return Values[0]; }
            }
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> FEMA
            {
                get { return Values[1]; }
            }
            #endregion​
    Last edited by tkaboris; 03-01-2023, 11:58 AM.

    #2
    Hello tkaboris,

    You need to set the plots to the value you calculated. You can use the public properties for that:
    Code:
    SEMA[0] = theValueForThePlot; 
    FEMA[0] = theValueForThePlot;
    JesseNinjaTrader Customer Service

    Comment


      #3
      hmm. I actually just want to plot two emas, fast and slow
      if i insert this line indicator doesnt work
      SEMA[0] = fastValue;
      FEMA[0] = slowValue;​
      I generated this code from indicator template and it suppose to plot but it doensnt.. I am doing something wrong..

      Comment


        #4
        Hello tkaboris,

        To plot the EMA's you could use the fastValue and slowValue, that code would have to come after where fastValue and slowValue are set. You would have to compile and re apply the indicator to see that change.

        When you say that this was from a template what do you mean? There are currently no indicator templates that come with the platform, you can generate a new empty indicator by using the NinjaScript editor. Is that what you had done and then this is the code you wrote?

        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by futtrader, 04-21-2024, 01:50 AM
        4 responses
        41 views
        0 likes
        Last Post futtrader  
        Started by Option Whisperer, Today, 09:55 AM
        1 response
        11 views
        0 likes
        Last Post bltdavid  
        Started by port119, Today, 02:43 PM
        0 responses
        7 views
        0 likes
        Last Post port119
        by port119
         
        Started by Philippe56140, Today, 02:35 PM
        0 responses
        7 views
        0 likes
        Last Post Philippe56140  
        Started by 00nevest, Today, 02:27 PM
        0 responses
        7 views
        0 likes
        Last Post 00nevest  
        Working...
        X