Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw in the chart

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

    Draw in the chart

    Hello,

    I am trying to draw a arrow and label in the chart based in the current and previous volume.
    For example if the SUM of the last 5 volume is > 300 I would like to draw a arrow in the current candle.

    The problem is I don't know how get the volume from the candles. I am trying with the below code only for the last 2 candles.

    double x = VOL()[0];
    double y = VOL()[1];
    double z = x+y;

    if (z<300){
    Plot0.Set(Close[0]);
    }

    I will apreciate your support.
    Regards.

    #2
    Hello Markines,

    Thank you for writing in and welcome to the NinjaTrader Support forum!

    To obtain volume from each bar, you'll want to use the Volume collection: https://ninjatrader.com/support/help...7/?volume2.htm

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      The same problem. It does not display anything.
      For example
      if (Volume[1] > Volume[0]){
      Plot0.Set(Close[0]);
      }

      Plot0 is a Dot and it is not displayed.

      Comment


        #4
        Hello Markines,

        Have you verified that your condition is becoming true?

        I would suggest adding a print statement before your if statement to check the values of the two volumes.

        Code:
        if (CurrentBar < 1)
             return;
        
        Print("Volume[0]: " + Time[0] + " " + Volume[0]);
        Print("Volume[1]: " + Time[1] + " " + Volume[1]);
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          That works. The results are correct in the output but still I cannot draw a label or line or whatever in the chart based in the volume

          I find out this msg in the output: Error on calling 'OnBarUpdate' method for indicator 'AAA2' on bar 1: Index was outside the bounds of the array

          Comment


            #6
            Hello Markines,

            Please attach your script to your reply.

            You can find your script within the Documents\NinjaTrader 7\bin\Custom\Indicator directory on your computer.
            Zachary G.NinjaTrader Customer Service

            Comment


              #7
              There you go.
              Attached Files

              Comment


                #8
                Hello Markines,

                Take a look within the Properties region, specifically within the Plot1 property.

                The property's get accessor is returning Values[2] on line 82. However, you only have two plots. This should be Values[1] instead.

                Each plot that you add in Initialize() will be indexed starting at 0. So, Plot0 is at 0 and Plot1 is at 1.
                Zachary G.NinjaTrader Customer Service

                Comment


                  #9
                  Thank you, that is works. About the second part? I would like to display a label on the chart. I have no idea how.

                  Comment


                    #10
                    Hello Markines,

                    If you wish to draw text or draw a line when the condition occurs, you can use the DrawText() and DrawLine() methods:

                    https://ninjatrader.com/support/help.../?drawtext.htm
                    https://ninjatrader.com/support/help.../?drawline.htm
                    Zachary G.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by farzibopsu, Today, 11:52 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post farzibopsu  
                    Started by exjayess, Today, 11:04 AM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_ShawnB  
                    Started by robertlaub, Today, 11:11 AM
                    1 response
                    3 views
                    0 likes
                    Last Post NinjaTrader_ShawnB  
                    Started by sdauteuil, Today, 10:28 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post sdauteuil  
                    Started by KirkHammett, Today, 08:11 AM
                    0 responses
                    7 views
                    0 likes
                    Last Post KirkHammett  
                    Working...
                    X