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:	300
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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        81 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        41 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        64 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        66 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        54 views
        0 likes
        Last Post CarlTrading  
        Working...
        X