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

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.
    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by thanajo, 05-04-2021, 02:11 AM
        3 responses
        467 views
        0 likes
        Last Post tradingnasdaqprueba  
        Started by Christopher_R, Today, 12:29 AM
        0 responses
        10 views
        0 likes
        Last Post Christopher_R  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        166 responses
        2,236 views
        0 likes
        Last Post sidlercom80  
        Started by thread, Yesterday, 11:58 PM
        0 responses
        4 views
        0 likes
        Last Post thread
        by thread
         
        Started by jclose, Yesterday, 09:37 PM
        0 responses
        9 views
        0 likes
        Last Post jclose
        by jclose
         
        Working...
        X