Announcement

Collapse
No announcement yet.

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;

    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?

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        574 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        332 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        553 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X