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

How to get the Buys and Sells Series from BuySellVolume()?

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

    How to get the Buys and Sells Series from BuySellVolume()?


    Hi,

    I would like to calculate the SMA of Buys from BuySellVolume, I tried the following but and it gave me error, seems BuySellVolume().Buys is not a series.



    Value[0] = SMA(BuySellVolume().Buys, 12)



    So how can I acheive this? thanks.


    #2
    Hello kelefei,

    Below is a link to the help guide with sample code.


    Be sure to look up any system indicator in the help guide for its method overload signatures and a code sample of the usage.

    Buys is a series. That part of the code you have appears fine to me.

    SMA() returns a series and Value[0] is a double.. Were you intending to return the most recent value of the SMA to the to plot series?
    If so, you need a barsAgo index.
    Value[0] = SMA(BuySellVolume().Buys, 12)[0];

    Are you sure you added a plot with AddPlot() for Value collection to exist?

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      This syntax is correct now:
      Value[0] = SMA(BuySellVolume().Buys, 12)[0];

      However, it only show me the value for most recent bar and no any historial data (all zero).

      I have already checked tick replay box and buysellvolume indicators works fine.

      So am I missed something in the script?

      Thanks.

      Comment


        #4
        Hello kelefei,

        May I confirm you have followed the direction in the help guide on Developing for Tick Replay in the 'Calling a Tick Replay indicator from another Indicator or Strategy' section?


        From the help guide:
        "you either need to store the reference in State.DataLoaded"

        Code:
        TickReplayIndicator myTickReplayIndicator = null;
        Code:
        else if (State == State.DataLoaded)
        {​
        // Store a reference to the Tick Replay indicator before State.Historical
        // Doing so ensures the hosted indicator will run through Tick Replay
        myTickReplayIndicator = TickReplayIndicator();​
        }
        Code:
        protected override void OnBarUpdate()
        {
        // Access the stored reference which calculates through
        // historical Tick Replay data and print the value as expected
        Print(myTickReplayIndicator[0]);
        }

        Using this for the BuySellVolume:

        In the scope of the class
        Code:
        private BuySellVolume myBSV;
        In State.DataLoaded:
        Code:
        myBSV = BuySellVolume();
        In OnBarUpdate:
        Code:
        Print(string.Format("{0} | myBSV.Buys[0]: {1}", Time[0], myBSV.Buys[0]));
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        4 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        40 views
        0 likes
        Last Post alifarahani  
        Started by Waxavi, Today, 02:10 AM
        1 response
        18 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by Kaledus, Today, 01:29 PM
        5 responses
        15 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X