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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        49 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        141 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        160 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        96 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        275 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X