Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting EMA on RSI

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

    Plotting EMA on RSI

    Ive searched the forums and found links to the help guide for this but there old links. Can you please direct me?

    #2
    Actually, instead can you tell me what im doing wrong in the section of code below. I have the RSI setup to plot a different color based on over or under 50 which works fine, but trying to add an EMA but the line doesn't show up. It seems to just adjust the RSI line instead...

    protectedoverridevoid Initialize()
    {
    Add(
    new Plot(Color.FromKnownColor(KnownColor.LimeGreen), PlotStyle.Line, "Bull"));
    Add(
    new Plot(Color.FromKnownColor(KnownColor.DarkGray), PlotStyle.Line, "Neutral"));
    Add(
    new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Line, "Bear"));
    CalculateOnBarClose =
    true;
    Overlay =
    false;

    Plots[
    0].Min = 50.5;
    Plots[
    1].Max = 50.5;
    Plots[
    1].Min = 49.5;
    Plots[
    2].Max = 49.5;
    }

    protectedoverridevoid OnBarUpdate()
    {
    if (CurrentBar < Period) return;

    double average = EMA(RSI(period, 3), Fast) [0];

    Bull.Set(average);
    Neutral.Set(average);
    Bear.Set(average);
    }

    Comment


      #3
      Hello zachj,

      Thank you for your post.

      This is expected, from the code you provided as it is only altering the plot based on the EMA with the input of RSI and period Fast.

      With just this code, the line you see if the EMA of the RSI, not the RSI.
      CameronNinjaTrader Customer Service

      Comment


        #4
        Is there a link u can direct me to..i have very limited coding knowledge.

        I assume i would do something like..
        Double value RSI(...
        Double average EMA(RSI(...

        Comment


          #5
          zachj,

          Unfortunately I do not have a link to assist you.

          However, you are on the right track. You will need to create a new Plot for your RSI line and the calculation for your RSI line.

          Example:
          Code:
          protected override void Initialize()
                  {
                      Add(new Plot(Color.FromKnownColor(KnownColor.LimeGreen), PlotStyle.Line, "Bull"));
                      Add(new Plot(Color.FromKnownColor(KnownColor.DarkGreen), PlotStyle.Line, "Neutral"));
                      Add(new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Line, "Bear"));
                      [B]Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "RSIPlot"));[/B]
                      Overlay                = false;
                      
                      Plots[0].Min = 50.5;
                      Plots[1].Max = 50.5;
                      Plots[1].Min = 49.5;
                      Plots[2].Max = 49.5;
                  }
          
                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
                      
                      if (CurrentBar < Period) 
                          return;
                      
                      double average = EMA(RSI(Period, 3), Fast) [0];
                      
                      [B]double rsiline = RSI(Period, 3)[0];[/B]
                      
                      // Use this method for calculating your indicator values. Assign a value to each
                      // plot below by replacing 'Close[0]' with your own formula.
                      Bull.Set(average);
                      Neutral.Set(average);
                      Bear.Set(average);
                      [B]RSIPlot.Set(rsiline);[/B]
                  }
          You will also need to expand the Properties region to include the following:

          Code:
                  [Browsable(false)]
                  [XmlIgnore()]
                  public DataSeries RSIPlot
                  {
                      get { return Values[3]; }
                  }

          Note that you can also use the New Indicator Wizard to create plots.
          CameronNinjaTrader Customer Service

          Comment


            #6
            Perfect! thank you

            Comment

            Latest Posts

            Collapse

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