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

Average Volume

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

    Average Volume

    Can you tell me what I would need to add to the following code to recognize when volume has been below average over the past 10 bars.

    if (CumulativeCurrentVolume(0)[0] < VOLMA(100)[1])
    Do something

    Also, where can I find a referance basic code that is used in Ninja Script like !=, ==, {}, return;, etc...

    Thank you,

    #2
    Originally posted by Jeff 15 View Post
    Can you tell me what I would need to add to the following code to recognize when volume has been below average over the past 10 bars.

    if (CumulativeCurrentVolume(0)[0] < VOLMA(100)[1])
    Do something
    I'd do something like this:

    Code:
    counter = 0;
    if (Volume[0] < VOLMA(100)[0])
       ++counter; //increment counter by 1
    else
       counter = 0;
    if (counter >= 10) {
       // volume has been below average for the last 10 bars.
    }
    Of course, you have to make sure counter is properly declared as an integer elsewhere in your indicator.
    Also, where can I find a referance basic code that is used in Ninja Script like !=, ==, {}, return;, etc...
    See the documentation. The version 6 help guide at the support center has a language reference. See http://www.ninjatrader.com/webnew/support.htm or pick up any book on C# (or Java).
    -Alex

    Comment


      #3
      Jeff,

      As far as basic reference code for operators in your first post,

      I found this helpful...




      RJay
      Last edited by RJay; 07-28-2008, 07:56 AM.
      RJay
      NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

      Comment


        #4
        Error on Multi-time frame stategy

        Thanks for all your help guys. I have another question on a Multi time frame strategy I cant seem to get fixed. Attached is some of the code I have so far. Ive tried everything I can think of. Maybe you can see what Im missing or point me in the right direction.
        Thanks

        Attached Files

        Comment


          #5
          Several bugs:
          - probably should read Highs instead of High etc. (if you want to do a multi series strategy)
          - you need to put brackets around your "paired" EnterLong statements like
          Code:
          if (condition)
          {
                EnterLong(...);
                EnterLong(...);
          }
          There likely are a bunch more errors in your code. You need to click on each click which will bring you to the erroneous line where you can fix the bug.

          Comment


            #6
            Volume counter

            I am currently working on a volume alert and using the attached code originally from post # 2 (Thanks to anachronist). I am having trouble with "counter" being recognized. Can you give me hint on where I may find some info on the "counter" and why it is not being recognized. Thank you,
            Attached Files

            Comment


              #7
              Unfortunately we are unable to provide support down to the level of actual C# coding basics. However here is hint: any variable you use in C#/NinjaScript, needed to defined. In your case your variable "counter" needed to defined e.g. like this:
              Code:
              private double counter;
              As last resort a certified NinjaScript consultant would be at help: http://www.ninjatrader.com/webnew/pa...injaScript.htm

              Comment


                #8
                Originally posted by Jeff 15 View Post
                I am currently working on a volume alert and using the attached code originally from post # 2 (Thanks to anachronist). I am having trouble with "counter" being recognized. Can you give me hint on where I may find some info on the "counter" and why it is not being recognized. Thank you,
                You're welcome. I didn't mention declarations and initializations in my previous example because it is assumed that folks in this forum are already familiar with C#. As stated in the previous reply, you must declare the variable counter before you use it. In the "variables" section of your code (near the top) you need the statement:

                private int counter;

                In the "initialization" section, you can put

                counter = 0;

                for the first initialization.

                This isn't the place to get tutored on C# programming. I highly recommend you buy a good book on the subject or look at any number of online resources for teaching yourself C#. If you have questions about programming as it relates to NinjaTrader specifically, and not general C# programming, then this is where you ask.
                -Alex
                Last edited by anachronist; 07-31-2008, 10:28 AM.

                Comment


                  #9
                  Great advice from Alex

                  Thanks Alex,

                  I got a C# book, and after only a couple chapters I already understand a whole lot more.
                  Thank you for the advice,
                  Jeff

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by jclose, Today, 09:37 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post jclose
                  by jclose
                   
                  Started by WeyldFalcon, 08-07-2020, 06:13 AM
                  10 responses
                  1,413 views
                  0 likes
                  Last Post Traderontheroad  
                  Started by firefoxforum12, Today, 08:53 PM
                  0 responses
                  10 views
                  0 likes
                  Last Post firefoxforum12  
                  Started by stafe, Today, 08:34 PM
                  0 responses
                  10 views
                  0 likes
                  Last Post stafe
                  by stafe
                   
                  Started by sastrades, 01-31-2024, 10:19 PM
                  11 responses
                  169 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Working...
                  X