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

Obtaining order flow VWAP value from additional data series within a strategy

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

    Obtaining order flow VWAP value from additional data series within a strategy

    Hi,

    I am developing a strategy which uses an additional data series. I want to be able to compare the position of the stock of the additional data series in relation to its order flow VWAP value.

    I have created a private double variable to store the value of the additional series order flow VWAP

    Code:
    private double additionalSeriesVwapVal;
    I have added the additional data series under State == State.Configure

    Code:
    AddDataSeries("ES 03-24", Data.BarsPeriodType.Minute, 5);
    I have added this code to OnBarUpdate()

    Code:
    if (BarsInProgress == 1)
        {
            additionalSeriesVwapVal = OrderFlowVWAP(VWAPResolution.Standard, TradingHours.String2TradingHours("US Equities RTH"), VWAPStandardDeviations.None, 1, 2, 3).VWAP[0];
        }​
    The problem I have is that the above line of code doesn't store the value from the order flow VWAP. I have tested capturing price data from the additional series by using Closes[1][0] and this works ok but for whatever reason I can't access the VWAp values.

    Is it not possible to use the order flow VWAP against an additional data series within a strategy? If it is possible, can you please provide me with some guidance.

    Thanks,

    Neil

    #2
    Hello Neil,

    Thank you for your post.

    You mentioned that the line of code doesn't store the value from the Order Flow VWAP. What value do you see in the output if you add a Print? For example:
    Code:
    if (BarsInProgress == 1)
    {
    Print(Time[0] + " BarsInProgress: " + BarsInProgress + " storing VWAP value: " + OrderFlowVWAP(VWAPResolution.Standard, TradingHours.String2TradingHours("US Equities RTH"), VWAPStandardDeviations.None, 1, 2, 3).VWAP[0]);
    additionalSeriesVwapVal = OrderFlowVWAP(VWAPResolution.Standard, TradingHours.String2TradingHours("US Equities RTH"), VWAPStandardDeviations.None, 1, 2, 3).VWAP[0];
    Print("VWAP value stored. additionalSeriesVwapVal: " + additionalSeriesVwapVal);
    }​​
    "Is it not possible to use the order flow VWAP against an additional data series within a strategy?"
    Yes, it is possible. There is syntax available that lets you specify the input series. You could use Closes[1][0] as you mentioned, or you could specify the BarsArray. For example:
    OrderFlowVWAP(ISeries<double> input, VWAPResolution resolution, TradingHours tradingHoursInstance, VWAPStandardDeviations numStandardDeviations, double sD1Multiplier, double sD2Multiplier, double sD3Multiplier)
    OrderFlowVWAP(BarsArray[1], VWAPResolution.Standard, BarsArray[1].TradingHours, VWAPStandardDeviations.Three, 1, 2, 3)

    This syntax information is listed in the help guide page here:


    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_Emily, thanks for your help, I've got it to work now. By mistake I had
      Code:
      if (BarsInProgress != 0) return;
      as my first line in OnBarUpdate() which was preventing me access the additional data series.

      Neil
      Last edited by burtoninlondon; 02-08-2024, 01:44 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by JoMoon2024, Today, 06:56 AM
      0 responses
      6 views
      0 likes
      Last Post JoMoon2024  
      Started by Haiasi, 04-25-2024, 06:53 PM
      2 responses
      17 views
      0 likes
      Last Post Massinisa  
      Started by Creamers, Today, 05:32 AM
      0 responses
      5 views
      0 likes
      Last Post Creamers  
      Started by Segwin, 05-07-2018, 02:15 PM
      12 responses
      1,786 views
      0 likes
      Last Post Leafcutter  
      Started by poplagelu, Today, 05:00 AM
      0 responses
      3 views
      0 likes
      Last Post poplagelu  
      Working...
      X