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

VWAP Reset workaround?

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

    VWAP Reset workaround?

    What's the workaround to changing "TradingHours tradingHoursInstance" part of the code to have it reset to different specified sessions such as weekly, monthly, certain trading hours? I just have it set by default as "Bars.Tradinghours" this has a strategy calculate off of globex reset or ETH if I'm not mistaken.

    What would I need to change "Tradinghours" section to for it to calculate VWAP starting on Sunday Open for a weekly calculation instead of a daily reset every 24 hrs?

    Would it be like "Bars.Weekly"?

    A snippet of the code is shown below.

    Can you give an example that would calculate weekly at the start of Globex on Sunday?

    Any guidance would be appreciated.

    Code:
    OrderFlowVWAP1  = OrderFlowVWAP(Close, NinjaTrader.NinjaScript.Indicators.VWAPResolution.Standard, [B]Bars.Tradinghours[/B], NinjaTrader.NinjaScript.Indicators.VWAPStandardDeviations.None, 1, 2, 3);
    Last edited by TradingLoss; 06-30-2022, 02:47 PM.

    #2
    Hello TradingLoss,

    Please see the following on how to set the reset interval:

    Code:
    vwapSession = OrderFlowVWAP(VWAPResolution.Standard, Bars.TradingHours, VWAPStandardDeviations.Three, 1, 2, 3);
    vwapWeek = OrderFlowVWAP(VWAPResolution.Standard, Bars.TradingHours, VWAPStandardDeviations.Three, 1, 2, 999);
    vwapWeek.ResetInterval = VWAPResetInterval.Week;
    vwapWeek.SD3Multiplier = 3;
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,

      I tried to put that into my code so the strategy would calculate off it and I get a compile error "VWAPResetinterval" does not exist in the current context. Do I have to predefine this
      Code:
      vwapWeek.ResetInterval = VWAPResetInterval.Week;
      at the beginning of the code (example below)? Is there a way to integrate that weekly reset calculation to the "OrderFlowVWAP1" part of my code so my strategy calculates off the weekly VWAP instead of the daily?

      Is there a way to integrate this vwapWeek.ResetInterval = VWAPResetInterval.Week;

      into this line of code?

      OrderFlowVWAP1 = OrderFlowVWAP(Close, NinjaTrader.NinjaScript.Indicators.VWAPResolution. Standard, Bars.TradingHours, VWAPresetinterval. NinjaTrader.NinjaScript.Indicators.VWAPStandardDev iations.None, 1, 2, 3);

      Your current edit kind of throws off my strategy when compiling, unfortunately.

      Code:
      public class testVWAPstrategy : Strategy
      {
      private bool DayOk;
      private double Accumulation;
      private OrderFlowVWAP [B]OrderFlowVWAP1[/B];
      [B]private vwapWeek.ResetInterval;[/B]
      Upon trying to add that above it gives an error as well.

      Code:
      }
      else if (State == State.DataLoaded)
      {
      OrderFlowVWAP1 = OrderFlowVWAP(Close, NinjaTrader.NinjaScript.Indicators.VWAPResolution. Standard, Bars.TradingHours, NinjaTrader.NinjaScript.Indicators.VWAPStandardDev iations.None, 1, 2, 3);
      
      vwapSession = OrderFlowVWAP(VWAPResolution.Standard, Bars.TradingHours, VWAPStandardDeviations.Three, 1, 2, 3);
      vwapWeek = OrderFlowVWAP(VWAPResolution.Standard, Bars.TradingHours, VWAPStandardDeviations.Three, 1, 2, 999);
      vwapWeek.ResetInterval = VWAPResetInterval.Week;
      vwapWeek.SD3Multiplier = 3;
      
      AddChartIndicator(OrderFlowVWAP1);
      }


      Originally posted by NinjaTrader_Jesse View Post
      Hello TradingLoss,

      Please see the following on how to set the reset interval:

      Code:
      vwapSession = OrderFlowVWAP(VWAPResolution.Standard, Bars.TradingHours, VWAPStandardDeviations.Three, 1, 2, 3);
      vwapWeek = OrderFlowVWAP(VWAPResolution.Standard, Bars.TradingHours, VWAPStandardDeviations.Three, 1, 2, 999);
      vwapWeek.ResetInterval = VWAPResetInterval.Week;
      vwapWeek.SD3Multiplier = 3;

      Comment


        #4
        Hello TradingLoss,

        That code works on my end, are you sure you have the correct using statements in your strategy? I would suggest to generate a new strategy and then use that for testing.

        The code I provided is just using a different variable name, the take away from my prior post is that to use a reset interval you need to use the property ResetInterval on your indicators variable. If you used OrderFlowVWAP1 for the variable name then you would replace vwapWeek with OrderFlowVWAP1.

        I would suggest to undo any changes that you made and re try using just the property ResetInterval, you don't need to define new variables to use that code.

        Code:
        [B]OrderFlowVWAP1[/B].ResetInterval = VWAPResetInterval.Week;
        JesseNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello TradingLoss,

          That code works on my end, are you sure you have the correct using statements in your strategy? I would suggest to generate a new strategy and then use that for testing.

          The code I provided is just using a different variable name, the take away from my prior post is that to use a reset interval you need to use the property ResetInterval on your indicators variable. If you used OrderFlowVWAP1 for the variable name then you would replace vwapWeek with OrderFlowVWAP1.

          I would suggest to undo any changes that you made and re try using just the property ResetInterval, you don't need to define new variables to use that code.

          Code:
          [B]OrderFlowVWAP1[/B].ResetInterval = VWAPResetInterval.Week;
          Ok, Jesse, I'll give that a try. Thanks again.

          Comment


            #6
            Hello Support,

            I am trying to understand how to implement this code into an indicator.

            I am trying to build a simple indicator that would output the value between VWAP and a deviation line based on the Monthly reset interval.

            I am somewhat tracking the code edits above... but not sure where to put the code below to cause the indicator values to be calculated from the Monthly VWAP but on a 1 min chart.

            I am using the help guide code as my base. I added the tick data series.


            // Prints the first upper standard deviation value using a tick resolution off of trading hours of the Data Series
            double VWAPStdDevUp1 = OrderFlowVWAP(VWAPResolution.Tick, Bars.TradingHours, VWAPStandardDeviations.Three, 1, 2, 3).StdDev1Upper[0];
            Print("The current VWAP with a tick resolution on " + Bars.TradingHours.ToString() + " is " + VWAPStdDevUp1.ToString());​


            The suggested code addition was:

            OrderFlowVWAP1.ResetInterval = VWAPResetInterval.Week;


            Do I set that variable for my double in my sample code block "VWAPStdDevUp1" above the code block that sets the double value and then insert somewhere in the code block that sets the value of VWAPStdDevUp1?

            Thanks


            Comment


              #7
              Hello MattD888,

              The code shown for the reset interval goes in State.DataLoaded where you create your indicator. The code in post 3 shows where that code goes in relation to the indicator syntax.

              JesseNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by MacDad, 02-25-2024, 11:48 PM
              7 responses
              158 views
              0 likes
              Last Post loganjarosz123  
              Started by Belfortbucks, Today, 09:29 PM
              0 responses
              7 views
              0 likes
              Last Post Belfortbucks  
              Started by zstheorist, Today, 07:52 PM
              0 responses
              7 views
              0 likes
              Last Post zstheorist  
              Started by pmachiraju, 11-01-2023, 04:46 AM
              8 responses
              151 views
              0 likes
              Last Post rehmans
              by rehmans
               
              Started by mattbsea, Today, 05:44 PM
              0 responses
              6 views
              0 likes
              Last Post mattbsea  
              Working...
              X