Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Wizard - How add vertical lines

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

    Strategy Wizard - How add vertical lines

    I am a newbie. How can I add verical line on a stochastic chart from top to bootom if some condtions are met. I am able to creat condition and add a diamond on the price chart. But failed to add a vertical line on the stochastic chart itself. I tried adding the vertical line from the wizard, but nothing shows up on the price chart or the indicator chart.

    Any help will be much appreciated

    #2
    Nice Person,

    To draw on the indicator panel you will have to open up the Stochastics indicator code and add DrawOnPricePanel = false to the Initialize() method. Then you would have to add code to draw the lines. Strategies are always added to panel 1 which is why you need to do it directly in the indicator if you want it on the indicator panel.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Strategy Wizard - How add vertical lines

      I added DrawOnPricePanel = false; into code as follows. while compiling

      I get error message "
      The name 'DrawOnPricePanel' does not exist in the current context"

      I must be doing something incorrect. but I don't know what?


      Here is the code

      protectedoverridevoid Initialize()
      {

      Add(Stochastics(
      7, 14, 3));
      Add(Stochastics(
      7, 14, 3));
      DrawOnPricePanel =
      false;
      CalculateOnBarClose =
      true;

      }
      protectedoverridevoid OnBarUpdate()
      {

      if (CrossAbove(Stochastics(7, 14, 3).D, Stochastics(7, 14, 3).K, 3))
      {
      DrawVerticalLine(
      "My vertical lineblue" + CurrentBar, 0, Color.Blue);
      }

      Comment


        #4
        Nice Person,

        This has to be done from the indicator code, not the strategy code.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          Nice Person,

          This has to be done from the indicator code, not the strategy code.
          Hello Josh ... I tried adding this code but can not compile it .. it gives similar error ... is there any sample code which I could emulate ... Basically I want to draw a vertical line on a stochastic indicator chart if the "K" crossses above the "D" value and the K is above D for three bars. I tried many times times but I could not do because the coding is not my forte. Thanks in advance for your help.

          Comment


            #6
            Please provide exact code you have and the exact error message. Thank you.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Error on editing the indicator

              Detailed steps and error message :



              Edit NInja Scripts
              Open Schocastics
              While trying to add a code got a message


              Changes will be lost becasue you can not save system indicator.

              I Ignored it



              Added "DrawOnPricePanel = false;" line after following block of codes

              protected override void Initialize()
              {
              Add(new Plot(Color.Green, "D"));
              Add(new Plot(Color.Orange, "K"));

              Add(new Line(Color.DarkViolet, 20, "Lower"));
              Add(new Line(Color.YellowGreen, 80, "Upper"));

              den = new DataSeries(this);
              nom = new DataSeries(this);
              ==>> DrawOnPricePanel = false;

              }

              Now pressed compile the code


              Now received a message - Error on generating indicator.

              Many lines of errors appeared in red below like

              indicator \@adl.cs - The name indicator does not exist in current context CS0103 - Click for info line 145 coloum 20

              etc etc

              Comment


                #8
                Please double click on that error and copy paste the code line that is highlighted. Thank you.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  I reinstalled the Ninja Trader and now the errors are gone.

                  I edited the stochastics Indicator as follows and compiled as Stochastics1
                  ================================================== =====

                  protected override void Initialize()
                  {
                  Add(new Plot(Color.Green, "D"));
                  Add(new Plot(Color.Orange, "K"));

                  Add(new Line(Color.DarkViolet, 20, "Lower"));
                  Add(new Line(Color.YellowGreen, 80, "Upper"));

                  den = new DataSeries(this);
                  nom = new DataSeries(this);
                  DrawOnPricePanel = false; // Added by me

                  }



                  Then I created a strategy using stochastics1 indicator.
                  =========================================

                  protected override void Initialize()
                  {
                  Add(Stochastic01(7, 14, 3));
                  Add(Stochastic01(7, 14, 3));

                  CalculateOnBarClose = true;
                  }




                  protected override void OnBarUpdate()
                  {
                  // Condition set 1
                  if (CrossAbove(Stochastic01(7, 14, 3).K, Stochastic01(7, 14, 3).D, 1))
                  {
                  DrawVerticalLine("My vertical line" + CurrentBar, 0, Color.Blue);
                  }
                  }


                  Now I used replay data . The stochastics indicator appears but the vertical lines ate not there.


                  What am I missing here. Will appreciate help.

                  Comment


                    #10
                    Nice Person, are there any errors in your logs (right-most tab of Control Center)? The code you posted looks fine, and when I tested it out I got many vertical lines.
                    Attached Files
                    AustinNinjaTrader Customer Service

                    Comment


                      #11
                      I have attached the log image ... there are no errors.

                      Few more points ....
                      When I use other drawing objects like arrow or diamond, it does show on the price panel.

                      My aim is to get the objects on the indicator panel itself, and not on the price panel.

                      Requesting fort your help.

                      Is it possible that I can call someone on support line and perhaps then the matter will be sorted out in few minutes. Just an idea.
                      Thanks
                      Attached Files

                      Comment


                        #12
                        Nice Person, to get the line to draw only on the indicator panel, you just need to specify DrawOnPricePanel = false in the Initialize() section of your indicator.
                        Attached Files
                        AustinNinjaTrader Customer Service

                        Comment


                          #13
                          Here is the code from the indicator which includes the special line also (DrawOnPricePanel = false. Still, when I use this indicator no lines appear on the indicator panel. I see that in your case the lines are appearing. Can you attach the complete indicator code which is working with you, so that I can copy that and load it. I am a newbie, so it is quite possible that I am making some silly mistakes.


                          protected override void Initialize()
                          {
                          Add(new Plot(Color.Green, "D"));
                          Add(new Plot(Color.Orange, "K"));

                          Add(new Line(Color.DarkViolet, 20, "Lower"));
                          Add(new Line(Color.YellowGreen, 80, "Upper"));

                          den = new DataSeries(this);
                          nom = new DataSeries(this);
                          DrawOnPricePanel = false;

                          }


                          protected override void OnBarUpdate()
                          {
                          nom.Set(Close[0] - MIN(Low, PeriodK)[0]);
                          den.Set(MAX(High, PeriodK)[0] - MIN(Low, PeriodK)[0]); // PeriodK = Kperiod

                          K.Set(100 * SUM(nom, Smooth)[0] / (SUM(den, Smooth)[0] == 0 ? 1.0 : SUM(den, Smooth)[0])); // Smooth = SlowKperiod
                          D.Set(SMA(K, PeriodD)[0]); // PeriodD = SlowDperiod
                          }

                          Comment


                            #14
                            Hi there, please take a look at the attached indicator. It is very simple and hopefully it gets you heading in the right direction.

                            You can download it and then import it from File -> Utilities -> Import NinjaScript.
                            Attached Files
                            AustinNinjaTrader Customer Service

                            Comment


                              #15
                              Thanks a lot Austin ... it was great ... When I added this indicator code file in NT it showed a new indicator panel and shows only the K line. I want that the vertical line appears in master panel of Stochastics indicator. So I changed the panel number in the properties. After this change the vertical line show in the stochastics Panel. But the scaling on the right hand side for the "draw vertical line" indicator is very high (more than 1000) and that completley supresses the stochastics line which has teh scaling only from 0 to 100. I am using "stochastics (7,14,2)" indicator. How can I force the "draw vertical line" indicator to follow same scaling like Stochastics indicator. Thanks in advance for your help.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, Yesterday, 05:17 AM
                              0 responses
                              54 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              130 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              72 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              44 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              49 views
                              0 likes
                              Last Post TheRealMorford  
                              Working...
                              X