• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Volume Up / Down based on Close

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

    Volume Up / Down based on Close

    I'd like to change the VolumeUpDown indicator, which is based on comparing the current bar's open with the current bar's close, to comparing current bar's close and previous bar's close.

    I thought it's a simple change:

    protected override void OnBarUpdate()
    {
    if (Close[0] > Close[1]) // changed from: if (Close[0] >= Open[0])
    {
    Values[0].Set(Volume[0]);
    Values[1].Reset();
    }
    else
    {
    Values[1].Set(Volume[0]);
    Values[0].Reset();
    }
    }

    I got a clean compile but no volume shows up. I don't understand why.

    Please take a look and let me know I have done wrong.

    Thanks,

    Richard

    #2
    Hi Richard168,

    Check the log tab of control center for error messages. You're likely running into this issue here:
    http://www.ninjatrader.com/support/f...ead.php?t=3170

    You can resolve by preventing script from accessing invalid values on the first bar in series.

    if (CurrentBar < 1) return; //add to top line in OnBarUpdate().
    Ryan MNinjaTrader Customer Service

    Comment


      #3
      Hi Ray,

      Thanks very much for your help. Your suggestion works.

      Richard

      Comment


        #4
        Originally posted by Richard168 View Post
        I'd like to change the VolumeUpDown indicator, which is based on comparing the current bar's open with the current bar's close, to comparing current bar's close and previous bar's close.

        I thought it's a simple change:

        protected override void OnBarUpdate()
        {
        if (Close[0] > Close[1]) // changed from: if (Close[0] >= Open[0])
        {
        Values[0].Set(Volume[0]);
        Values[1].Reset();
        }
        else
        {
        Values[1].Set(Volume[0]);
        Values[0].Reset();
        }
        }

        ....
        I used the above quoted code too with the intention of having a green volume bar for an up bar and red volume bar for a down bar, however, I still didnt get any difference from the default indicator.

        As you may know the default indicator doesnt only print up green bars and down red bars but sometimes also prints green down bars and red up bars.

        Please help me with the changes I want.

        Also if you know of a volume indicator doing what I want, please give me a link. I have searched but in vein
        Last edited by ramos04; 03-03-2017, 05:08 AM.

        Comment


          #5
          Hello ramos04,

          Thank you for your post.

          The VolumeUpDown should only plot green up and red down based on the default settings. Can you provide a screenshot of this not being the case?

          What happens when you use the code from this thread? Can you provide a screenshot of this as well?

          To send a screenshot with Windows 7 or newer I would recommend using Window's Snipping Tool.

          Click here for instructions: http://windows.microsoft.com/en-us/w...#1TC=windows-8

          Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.

          Click here for detailed instruction: http://take-a-screenshot.org/

          I look forward to your response.
          Last edited by NinjaTrader_PatrickH; 03-07-2017, 10:52 AM.
          Patrick H.NinjaTrader Customer Service

          Comment


            #6
            I look forward to your response.
            Thanks for your timely response. Sorry for delayed response, been so occupied offline.

            The VolumeUpDown should only plot green up and red down based ont eh default settings. Can you provide a screenshot of this not being the case?
            Refer to the first attachment

            What happens when you use the code from this thread? Can you provide a screenshot of this as well?
            Refer to the second attachment
            Attached Files

            Comment


              #7
              Hello ramos04,

              Thank you for your response.

              I am not seeing the same behavior on my end. Would it be possible to schedule a remote session with you?

              Please write in to 'platformsupport[at]ninjatrader[dot]com' with 'ATTN: Patrick H' in the subject line and a reference to this thread. Please provide a time window and a phone number we may reach you at in your email.

              I look forward to assisting you further.
              Patrick H.NinjaTrader Customer Service

              Comment


                #8
                I am not seeing the same behavior on my end. Would it be possible to schedule a remote session with you?
                Yes. Will be contacting you as directed.

                Comment


                  #9
                  Coming from a Meta Trader 4 (MT4) background, the volume there is calculated based on the volume close ie green for a volume bar that closes higher than the previous and red for a volume bar closing below the previous bar. This is not necessarily the case with the default VolumeUpDown NT7 indicator, and am also not knowledgeable enough to technically explain why it (VolumeUpDown) can print green up volume bars and green down volume bars and the same with red volume bars.

                  NinjaTrader_PatrickH developed me a VolumeUpDown2 and also allowed me to share it. It does what is described above that MT4 can do.

                  Enjoy
                  Attached Files
                  Last edited by ramos04; 03-09-2017, 11:20 PM.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by w0lverine, Today, 03:57 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post w0lverine  
                  Started by digibob, Today, 02:47 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post digibob
                  by digibob
                   
                  Started by NinjaCustomer, Today, 12:57 AM
                  1 response
                  4 views
                  0 likes
                  Last Post NinjaCustomer  
                  Started by lancasterstephen, Today, 12:09 AM
                  1 response
                  5 views
                  0 likes
                  Last Post lancasterstephen  
                  Started by liltr3d, Yesterday, 10:52 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post liltr3d
                  by liltr3d
                   
                  Working...
                  X