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

Reconstruct 1 tick

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

    Reconstruct 1 tick

    Hi,

    I was looking to reconstruct a 1 tick chart with VOL indicator. If the VOL of the current bar is grater than 5 hold that value and keep adding if the values are grater than 5 until. For example:

    tick1 - 7
    tick2 - 5
    tick3 - 10
    tick4 - 4

    the sum of the above should be 22 because it’s calculating anything above 5.

    Would something like the below work:

    if (VOL[0] >= 5)
    {
    largevolume++;
    Print …. +largevolume;
    }
    else if (VOL[0] < 5)
    {
    largevolume = 0;
    }

    #2
    Hello AgriTrdr,

    Thank you for your post.

    From the code provided, it looks like it should perform what you are describing.

    If the current value of the VOL indicator is greater than or equal to 5, it will increment your largevolume variable.
    Else if the current value of VOL is less than 5, largevolume is reset to 0.

    Just as a heads up, our support generally can't answer questions like "does this look right", we would redirect you to try the script and make sure it does what you asked of it. Testing the script is a very important part of the strategy creation process so that squarely falls on the developer to make sure it works as planned.

    If you have tested the script out and it does not working as you're expecting, we can assist you in the debugging process.

    If you need further assistance please let us know.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Hi Gaby,

      thanks for your response. I tested the above and I realize what it’s doing is that it’s acting as a “counter” rather than summing the values of VOL indicator. So every time the VOL is above 5, until it goes below 5, it’ll print and let me know how many times the VOL was above 5. How would I get the sum of the VOL?

      Thanks

      Comment


        #4
        Hello AgriTrdr,

        largevolume++ will just increment this variable by 1. If you want to add the the current value of the VOL indicator to largevolume, you would need to do something like this:

        Code:
        largevolume = largevolume + VOL[0];

        or

        Code:
        largevolume += VOL[0];
        Please let us know if you have any further questions.
        Gaby V.NinjaTrader Customer Service

        Comment


          #5
          Thank you! It's working exactly how I wanted it to.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by edward_steve12, Today, 02:25 AM
          0 responses
          2 views
          0 likes
          Last Post edward_steve12  
          Started by joseph_kuruvilla12, Today, 01:01 AM
          0 responses
          6 views
          0 likes
          Last Post joseph_kuruvilla12  
          Started by joseph_kuruvilla12, Today, 12:40 AM
          0 responses
          4 views
          0 likes
          Last Post joseph_kuruvilla12  
          Started by joseph_kuruvilla12, Today, 12:13 AM
          0 responses
          5 views
          0 likes
          Last Post joseph_kuruvilla12  
          Started by stafe, 07-19-2024, 01:32 PM
          3 responses
          40 views
          0 likes
          Last Post stafe
          by stafe
           
          Working...
          X