Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Merge two symbols (UVOL - DVOL)

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

    Merge two symbols (UVOL - DVOL)

    Hello guys,

    I am used to work with VOLD and would like to use it inside a strategy. Ninjatrader offers only UVOL and DVOL.
    Since VOLD is only the substraction of DVOL from UVOL I can calculate the current value - but I'd like to have a data series so I can have an EMA on the data.

    So within State.Configure I have
    AddDataSeries("^UVOL", BarsPeriodType.Minute, 1);
    AddDataSeries("^DVOL", BarsPeriodType.Minute, 1);

    and inside my strategy I can calculate the current VOLD value via:
    double VOLD = Closes[1][0] - Closes[2][0];

    As I do want to use some EMA's with VOLD I need more than the latest candle. Something like BarsArray.
    Could you point me into the right direction for that?

    Thanks
    Florian

    #2
    Hello schollf,

    You basically have what you need to do that, the only other step would be to add a Series<double> to store the subtraction you are doing. You could then pass that series to an EMA.



    You would essentially end up with code like this:

    Code:
    if(BarsInProgress == 0)
    {
       MyCustomSeriesName[0] = Closes[1][0] - Closes[2][0];
    ​   double ema = EMA(MyCustomSeriesName, 12)[0]; 
    }

    Comment


      #3
      Hello Jesse,

      thanks for the hinti with the custom series. I just tried to place the logic into a blank strategy. See screenshot.

      Click image for larger version

Name:	vold.png
Views:	297
Size:	72.1 KB
ID:	1254866

      The following error I do not understand in this context:

      Strategy 'VOLD': Error on calling 'OnBarUpdate' method on bar 950: Object reference not set to an instance of an object.​

      Did I miss something here?

      Comment


        #4
        Hello schollf,

        You need to create the series in OnStateChange, that is the link I provided it has a sample of how to set up a series on that page.



        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        39 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        124 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        64 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X