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

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 CortexZenUSA, Today, 12:53 AM
            0 responses
            1 view
            0 likes
            Last Post CortexZenUSA  
            Started by CortexZenUSA, Today, 12:46 AM
            0 responses
            1 view
            0 likes
            Last Post CortexZenUSA  
            Started by usazencortex, Today, 12:43 AM
            0 responses
            5 views
            0 likes
            Last Post usazencortex  
            Started by sidlercom80, 10-28-2023, 08:49 AM
            168 responses
            2,265 views
            0 likes
            Last Post sidlercom80  
            Started by Barry Milan, Yesterday, 10:35 PM
            3 responses
            11 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X