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

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:


    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 M.NinjaTrader 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.

          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.

              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 gemify, 11-11-2022, 11:52 AM
                  6 responses
                  803 views
                  2 likes
                  Last Post ultls
                  by ultls
                   
                  Started by ScottWalsh, Today, 04:52 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post ScottWalsh  
                  Started by ScottWalsh, Today, 04:29 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post ScottWalsh  
                  Started by rtwave, 04-12-2024, 09:30 AM
                  2 responses
                  22 views
                  0 likes
                  Last Post rtwave
                  by rtwave
                   
                  Started by tsantospinto, 04-12-2024, 07:04 PM
                  5 responses
                  70 views
                  0 likes
                  Last Post tsantospinto  
                  Working...
                  X