Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Indicators

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

    Strategy Indicators

    I would like to display 2 indicators from within a strategy:

    1. RSI(14) and RSI(3) on panel 2
    2. ADX(20) on panel 3

    Initialize() code:

    Add(StrategyPlot(0));
    Add(StrategyPlot(
    1));
    // Set the color for the indicator plots
    StrategyPlot(0).Plots[0].Pen.Color = Color.Green;
    StrategyPlot(
    0).Plots[1].Pen.Color = Color.Black;
    StrategyPlot(
    1).Plots[0].Pen.Color = Color.Purple;
    // Set the panel which the plots will be placed on. 1 = price panel, 2 = panel under the price panel, etc.
    StrategyPlot(0).PanelUI = 2;
    StrategyPlot(
    1).PanelUI = 3;

    OnBarUpdate():

    StrategyPlot(0).Values[0].Set(RSI(14,3)[0]);
    StrategyPlot(
    0).Values[1].Set(RSI(3,3)[0]);
    StrategyPlot(
    1).Value.Set(ADX(14)[0]);

    This doesnt work?

    #2
    mballagan,

    You do not need to do anything with StrategyPlot(). Please see this: http://www.ninjatrader-support2.com/...ead.php?t=3228
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Strategy Indicator

      Thanks for the link.

      I wrote the following code:

      CalculateOnBarClose = false;

      Add(RSI(
      14,3));

      RSI(
      14,3).Panel=1;
      RSI(
      14,3).Lines[0].Pen.Color = Color.Green;

      Add(RSI(
      3,3));

      RSI(
      3,3).Panel=1;
      RSI(
      3,3).Lines[0].Pen.Color = Color.Black;

      Which produces the attached image. Both main RSI lines are green rather than one green and the other black?
      Attached Files

      Comment


        #4
        mballagan,

        You did not set the correct value. If you want to change the RSI plots you need to be changing the color of Plots[] and not Lines[]. Lines[] are just the 30-70 lines and Plots[] are the actual RSI ones.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Strategy Indicator

          I changed the code to:

          Add(RSI(14,3));

          RSI(
          14,3).Panel=1;
          RSI(
          14,3).Plots[0].Pen.Color = Color.Green;

          Add(RSI(
          3,3));

          RSI(
          3,3).Panel=1;
          RSI(
          3,3).Plots[0].Pen.Color = Color.Black;

          as you specified and its worked, many thanks.

          Comment


            #6
            RSI lines

            How do I change the values of horizontal lines on an RSI plot from code?

            This works fine:

            Add(RSI(14,1));

            RSI(
            14,1).Panel=1;
            RSI(
            14,1).Plots[0].Pen.Color = Color.Green;

            I tried the following addition but doesnt seem to work:

            RSI(14,1).Lines[0].Value = 0;
            RSI(
            14,1).Lines[1].Value = 50;

            So changing from default 30/70 values to 0/50.

            Comment


              #7
              Please ensure you start a new instance of the strategy. It should work.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Indicators

                Your suggestion worked thanks.

                The RSI indicator has a smoothing parameter. If I want to turn off the smoothing would I use RSI(14,0) ? So 0 for the smoothing value.

                Comment


                  #9
                  This is the part that uses the smooth parameter:

                  double rsiAvg = (2.0 / (1 + Smooth)) * rsi + (1 - (2.0 / (1 + Smooth))) * Avg[1];

                  Using a 0 will reduce it.
                  Josh P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by CarlTrading, Yesterday, 09:41 PM
                  1 response
                  15 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by CarlTrading, Today, 02:41 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post CarlTrading  
                  Started by CaptainJack, Yesterday, 11:44 PM
                  0 responses
                  13 views
                  0 likes
                  Last Post CaptainJack  
                  Started by CarlTrading, 03-30-2026, 11:51 AM
                  0 responses
                  32 views
                  0 likes
                  Last Post CarlTrading  
                  Started by CarlTrading, 03-30-2026, 11:48 AM
                  0 responses
                  31 views
                  0 likes
                  Last Post CarlTrading  
                  Working...
                  X