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

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:


                    Zachary G.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by funk10101, Today, 12:02 AM
                    1 response
                    10 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by GLFX005, Today, 03:23 AM
                    1 response
                    6 views
                    0 likes
                    Last Post NinjaTrader_Erick  
                    Started by nandhumca, Yesterday, 03:41 PM
                    1 response
                    12 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by The_Sec, Yesterday, 03:37 PM
                    1 response
                    11 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by vecnopus, Today, 06:15 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post vecnopus  
                    Working...
                    X