Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error Using Volumes()

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

    Error Using Volumes()

    Multi time frame strategy. Using Volumes(BarsArray[2])[0] > Volumes(BarsArray[2])[1])

    Getting error:
    Strategy\MyCustomStrategy.cs The name 'Volumes' does not exist in the current context CS0103 - click for info 67 215
    Strategy\MyCustomStrategy.cs The name 'Volumes' does not exist in the current context CS0103 - click for info 67 42

    Tried using Volume(BarsArray[2])[0] > Volume(BarsArray[2])[1])
    but got the same error.

    Not sure why Volumes is not working.

    #2
    Hello,

    Thank you for the post.

    I couldn't say why the error is being shown from this small of a sample but the use of Volumes is not correct either. The error would relate to not being able to find the inherited Volumes DataSeries, could you provide more context on where this code is being called from in your script?

    Regarding the use of Volumes, this is a DataSeries and not an Indicator so it cannot be used with Parenthesis ( ): http://ninjatrader.com/support/helpG...ghtsub=Volumes

    Volumes would need to be used like:

    Code:
    if (Volumes[0][0] > Volumes[1][0])
    where the first [0] is the BarsInProgress index and the second [0] is the BarsAgo.

    There is also the Volume indicator VOL which is more close to what you are currently trying as far as usage goes:

    int value = VOL()[0];





    I look forward to being of further assistance.

    Comment


      #3
      so

      Volumes[2][0] > Volumes[2][1]

      would compare current volume to previous volume of the 2nd instrument?

      Comment


        #4
        Hello,

        If by Second instrument you mean the Second added instrument from code, yes that would be correct.

        If you mean Second as in the instrument added after the primary instrument the index actually would be 1.

        If you have only 1 Add statement in your script, the Second added instrument after the primary would be Volumes[1][0]

        If you have 2 Add statements in your script, the Second added instrument from Code would be Volumes[2][0]

        Your primary instrument will always be index 0.

        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X