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

Newbie help with Draw on bar

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

    Newbie help with Draw on bar

    Here's a snip of the code:

    DrawSquare("HighVolume" + CurrentBar, 0, Close[0], Color.Blue

    It plots a square right on the bar if volume hits a certain level.

    That's close to what I want.

    How could I plot this square as soon as the volume hits the level and right at the price?

    I have an audio alert that alerts me as soon as the volume gets there but I'd love to see the square right at the PRICE of the bar when volume hits rather than at some high/low/close point.

    Thanks,

    v.

    #2
    Not sure I follow. Your code already does that. When a certain volume is reached it draws you a square at the current closing price.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh,

      Yes, it puts a square where the bar closes.

      I'd like it to put the square at the price point on the bar at the exact time that my volume level is reached.

      For example:

      On a tick chart, the bar may reach a total of 1000 contracts. At 500 contracts, for example, an audio alert goes "ding", but my square won't appear until the bar ends and at the closing price of the BAR not the specific price point when the level was reached. I used to have it plot below the bar. Now I'm wondering if the square, dot, etc. can appear on the bar at the exact time and at the exact price on the bar at the time that the level is reached. Sort of a visual block "time and sale" on the bar.

      ...if that's possible.

      Thanks
      V.

      Comment


        #4
        Please try running with CalculateOnBarClose = false. It will put it on the exact point. The Close[0] price of a building bar is the same as the latest price.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I have that set already and thought that would do it.

          Just for kicks, I went back and checked and all dots are at the bars closing price not the "volume point".

          Comment


            #6
            Historical bars will show at the close of the bar as expected. Historical bars do not contain any intrabar information. Only moving forward in real-time will you get the necessary information to process it the way you want.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              I know. :-)

              During real time on a 20 tick chart, these squares will only plot after the bar closes and at the closing price. There has to be a way to code this to say...plot NOW. :-) I'm not a programmer...I pieced this together and looked through the Help but don't see the language. Close[0] is plotting at tick bar close not when it reaches the volume level.

              Sorry for the hassle, but I thought for sure that someone would say...oh yeah, use Price[0] or something like that. It works fine in TS. I just don't know the wording in NT.

              V

              Comment


                #8
                Not following you. When using a real-time chart on real-time data setting CalculateOnBarClose = false will do it. Just run your logic against the correct thing. If you want to check volume, run your if-statements off of Volume[0] and then tell it to plot on Close[0] for latest price.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Here's another snippet:

                  /// <summary>
                  /// This method is used to configure the indicator and is called once before any bar data is loaded.
                  /// </summary>
                  protected override void Initialize()
                  {
                  CalculateOnBarClose = false;
                  Overlay = false;
                  PriceTypeSupported = false;
                  }

                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
                  // Use this method for calculating your indicator values. Assign a value to each
                  // plot below by replacing 'Close[0]' with your own formula.

                  if (Volume[0] > Alert1)
                  DrawDot("HighVolume" + CurrentBar, 0, Close[0], Color.White);
                  if (Volume[0] > Alert1)
                  PlaySound(@"C:\WINDOWS\Media\Windows XP Balloon.wav");
                  if (Volume[0] > Alert2)
                  DrawSquare("HighVolume" + CurrentBar, 0, Close[0], Color.Blue);
                  if (Volume[0] > Alert3)
                  DrawDiamond("HighVolume" + CurrentBar, 0, Close[0], Color.Gold);
                  if (Volume[0] > Alert3)
                  PlaySound(@"C:\Program Files\Kirby Alarm\Trade Alerts\High Volume Alert.wav.");
                  }


                  __________________________________________________ _____________

                  The plots DO show up on the bar when the volume alert hits, but they keep moving with the bar until price stops and then the dot stops at the close. I'm very sorry I didn't make that clear. What I'm looking for is:

                  Alert>>>Place dot>>>stop moving dot.

                  Sorry about that!
                  Thanks
                  v.

                  Comment


                    #10
                    Reason it keeps moving is because your if-statement is constantly true. You need to prevent it from being true after the first time

                    In Variables region of your code:
                    Code:
                    private bool drawn = false;
                    In OnBarUpdate:
                    Code:
                    if (Volume[0] > ____ && drawn == false)
                    {
                         DrawDot(...);
                         drawn = true;
                    }
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      THANKS!!!

                      That's why I titled it "Newbie..."

                      Another real quick one...

                      I'd like to plot a horizontal line at the cash open 9:30 AM EST.

                      Been doing this manually. Can you point me to an indicator that I could copy some code from?

                      The OHL confused the heck out of me.

                      I'd like it to plot across the screen starting at 9:30 bar open and then clear for the next day...and start over. Is that even possible?

                      Thanks again,

                      V.

                      Comment


                        #12
                        VinnyB, I replied to your other thread regarding your latest question.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Great...thanks Bertrand!

                          vin

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by ZenCortexCLICK, Today, 04:58 AM
                          0 responses
                          2 views
                          0 likes
                          Last Post ZenCortexCLICK  
                          Started by sidlercom80, 10-28-2023, 08:49 AM
                          172 responses
                          2,280 views
                          0 likes
                          Last Post sidlercom80  
                          Started by Irukandji, Yesterday, 02:53 AM
                          2 responses
                          17 views
                          0 likes
                          Last Post Irukandji  
                          Started by adeelshahzad, Today, 03:54 AM
                          0 responses
                          4 views
                          0 likes
                          Last Post adeelshahzad  
                          Started by Barry Milan, Yesterday, 10:35 PM
                          3 responses
                          13 views
                          0 likes
                          Last Post NinjaTrader_Manfred  
                          Working...
                          X