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

How to draw a line on top of RSI (second panel ) in an automated strategy

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

    How to draw a line on top of RSI (second panel ) in an automated strategy

    Hello,
    I have an automated strategy where I am working mostly with RSI.

    I want to be able to draw lines that are tilted and to connect the highest values of two or more consecutive RSI peaks.

    In this regard, I managed to get the number of bar of the first tip and its respective peak RSI value, and the number of bar and peak value of the second RSI tip.

    For example I have

    1st High:
    Session Bar 293
    RSI 73.5

    2nd High
    Session Bar 385
    RSI 69.5


    I want to use the above data to draw a line and connect the two dots, while charting it on the panel where the RSI is being drawn.

    Any help will be much appreciated.

    Thanks.
    Last edited by nikolaalx; 09-07-2015, 08:33 AM.

    #2
    Originally posted by nikolaalx View Post
    Hello,
    I have an automated strategy where I am working mostly with RSI.

    I want to be able to draw lines that are tilted and to connect the highest values of two or more consecutive RSI peaks.

    In this regard, I managed to get the number of bar of the first tip and its respective peak RSI value, and the number of bar and peak value of the second RSI tip.

    For example I have

    1st High:
    Session Bar 293
    RSI 73.5

    2nd High
    Session Bar 385
    RSI 69.5


    I want to use the above data to draw a line and connect the two dots, while charting it on the panel where the RSI is being drawn.

    Any help will be much appreciated.

    Thanks.
    Put
    Code:
    DrawOnPricePanel = false;
    in the Initialize() method, then use DrawLine() to draw the line where needed.

    ref: http://ninjatrader.com/support/helpG...pricepanel.htm

    Comment


      #3
      I am trying to use the following code:

      protected override void Initialize()
      {
      Add(RSI(RSIPeriod, 3));
      CalculateOnBarClose = true;
      RSI(RSIPeriod, 3).Panel = 2;
      RSI(RSIPeriod, 3).DrawOnPricePanel = false;
      }


      And then to draw the line:

      RSI(RSIPeriod, 3).DrawLine("LowPivot"+lowcnt, (CurrentBar - BarOfFirstLow), RSIFirstLow, 0, RSIThirdLow, Color.Green);


      However when I do the backtest, there are no drawn objects on my chart...?

      Any idea why this might be happening?

      Thanks.

      Comment


        #4
        Originally posted by nikolaalx View Post
        I am trying to use the following code:

        protected override void Initialize()
        {
        Add(RSI(RSIPeriod, 3));
        CalculateOnBarClose = true;
        RSI(RSIPeriod, 3).Panel = 2;
        RSI(RSIPeriod, 3).DrawOnPricePanel = false;
        }


        And then to draw the line:

        RSI(RSIPeriod, 3).DrawLine("LowPivot"+lowcnt, (CurrentBar - BarOfFirstLow), RSIFirstLow, 0, RSIThirdLow, Color.Green);


        However when I do the backtest, there are no drawn objects on my chart...?

        Any idea why this might be happening?

        Thanks.
        What is the error in your log?

        Comment


          #5
          Hi,
          I don't get any errors. I don't see any drawn lines on my screen either.

          I want to emphasize that I am trying on backresting

          Comment


            #6
            Since no one hasn't responded, I decided to bump the thread again with a specific question :

            Is it normal for lines not to be drawn on the indicator panel, when doing backresting? Or it makes no difference?

            I assume it is not normal, but still decided to specifically ask, since I don't get any errors and I don't see any drawn lines.

            I added Print outputs which verify the event trigger is taking place successfully.

            Comment


              #7
              Originally posted by nikolaalx View Post
              Since no one hasn't responded, I decided to bump the thread again with a specific question :

              Is it normal for lines not to be drawn on the indicator panel, when doing backresting? Or it makes no difference?

              I assume it is not normal, but still decided to specifically ask, since I don't get any errors and I don't see any drawn lines.

              I added Print outputs which verify the event trigger is taking place successfully.
              I honestly do not remember if drawings show up on Backtest. I would have to get back into test mode to find out. sorry.

              Comment


                #8
                Thanks, we'll once you do, please let me know.

                In the meantime it would be very helpful to see the input of a staff member on this question..

                Comment


                  #9
                  Hello,

                  Originally posted by nikolaalx View Post
                  I am trying to use the following code:

                  RSI(RSIPeriod, 3).DrawLine("LowPivot"+lowcnt, (CurrentBar - BarOfFirstLow), RSIFirstLow, 0, RSIThirdLow, Color.Green);
                  I tested the code and do see this specific usage does not work in the backtest.

                  You can use Drawing tools, for example in a strategy if you used something like:
                  Code:
                  protected override void OnBarUpdate()
                  {
                  	if(CurrentBar < 10) return;
                  	DrawLine("LowPivot"+1, 0, Close[0], 10, Close[0], Color.Green);
                  }
                  You would see the resulting line in the backtest chart however, the way you are trying to draw the line I believe is not working regarding the reference being used.

                  Instead the correct way would be to create a duplicate of the RSI indicator that draws this line from the indicator its self. The strategy would add the indicator which draws the line and no extra code would be needed in the strategy regarding the line. So long as you add the DrawOnPricePanel = false; into the duplicate, the object should appear in the correct panel.

                  I look forward to being of further assistance.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    I just double tested the code by running the strategy while in real time mode and it seems to draw the lines.

                    Strange that it does not draw them in backtest.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by yertle, Today, 08:38 AM
                    1 response
                    5 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by love2code2trade, Yesterday, 01:45 PM
                    3 responses
                    22 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by trilliantrader, Today, 08:16 AM
                    2 responses
                    6 views
                    0 likes
                    Last Post trilliantrader  
                    Started by samish18, Today, 08:31 AM
                    1 response
                    2 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Started by Creamers, 09-08-2023, 10:26 AM
                    6 responses
                    157 views
                    0 likes
                    Last Post JonyGurt  
                    Working...
                    X