Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Set the Value of Trading hours in My Custom Volume Profile

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

    Set the Value of Trading hours in My Custom Volume Profile

    Hello good day, I am creating my own Volume Profile Tool and I have already integrated the Trading Hours option into it, but I would like to know how I can set the value of the selected Trading hour I mean, I want that it to works within my Volume Profile, I know that this can be done in the Data series --> Trading hours, but I want that the Trading hours works within my Volume Profile just like the Order Flow Volume Profile that comes integrated with Ninja Trader does, can you give me a clue how I can do it? In my image I show you that I already have the Trading Hours ComboBox in my Volume profile, Thank you.

    My Volume profile Tool Trading Hours:

    Click image for larger version

Name:	Captura de pantalla 2024-06-12 165819.png
Views:	172
Size:	16.6 KB
ID:	1307024


    #2
    Hello icebergdelphi,

    Thank you for your post.

    You will need to add a series that uses the Trading hours template you want, and then use that data series as the input series for the indicator that you want using the data shaped by that trading hours template.



    AddDataSeries(string instrumentName, BarsPeriod barsPeriod, string tradingHoursName)

    Please let us know if you have any further questions. ​

    Comment


      #3
      Thank you Gaby, I tried that before and nothing happened, is strange because I was reading about DataSeries... Do I need something else to do? Thank you.

      By The way I am using this section to Implement the AddDataseries..
      else if (State == State.Configure)
      Last edited by icebergdelphi; 06-13-2024, 09:01 AM.

      Comment


        #4
        Are you seeing any errors in the Log tab of the Control Center?

        Are you using the added data series for your indicator's calculations?

        Keep in mind that this will not actually change the primary data series' trading hours template (the chart your strategy is applied to), that can only be changed from the Data Series properties directly in the chart.

        Comment


          #5
          Hello Gaby, My Log Tab is not showing issues all is Ok, let me send what I got in my code:


          if (State == State.SetDefaults)
          {
          Description = @"Volume Profile: Plots a horizontal Lines with Levels Sessions.";
          Name = "VolumeProfileLevelSessions";
          IsChartOnly = true;
          IsOverlay = false;
          DisplayInDataBox = false;
          DrawOnPricePanel = true;

          VolProfileTradingHours = TradingHours.Get(TradingHours.SystemDefault);
          PeriodIntervalResolution = 1;
          ValueArea = 70;​

          Rest of the code..........

          And in the (State == State.Configure) Section:

          Currently I am using this: (I see in NinjaTrader help that there are a different syntaxs for the script
          AddDataSeries(string instrumentName, BarsPeriodType periodType, int period)
          My Code:AddDataSeries(Instrument.FullName, BarsPeriodType.Tick, PeriodIntervalResolution);

          But I want to Know if this is the equivalent plus adding my TradingHours:

          AddDataSeries(string instrumentName, BarsPeriod barsPeriod, string tradingHoursName)
          My New Code: AddDataSeries(Instrument.FullName,new BarsPeriod { BarsPeriodType = BarsPeriodType.Tick,Value=PeriodIntervalResolution },VolProfileTradingHours.Name);




          PHP Code:
           else if (State == State.Configure)
                      {
                          Calculate = Calculate.OnEachTick;
                          //AddDataSeries(Instrument.FullName, BarsPeriodType.Tick, PeriodIntervalResolution);
                          AddDataSeries(Instrument.FullName,new BarsPeriod { BarsPeriodType = BarsPeriodType.Tick,Value=PeriodIntervalResolution},VolProfileTradingHours.Name);
          
                          Profiles = new List<VolumeProfileData>();
                          Profiles.Add(new VolumeProfileData() { StartBar = 0 });
                      }&#8203; 
          
          Even adding a change in My new code , the VolProfileTradingHours is not affecting my Volume profile



          Last edited by icebergdelphi; 06-13-2024, 04:00 PM.

          Comment


            #6
            Hello icebergdelphi,

            Thank you for your response.

            My apologies, unfortunately you would not be able to load a trading hours template using AddDataSeries in this way. This would be considered trying to load a data series dynamically, which is not supported:

            "Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided.​"

            Additionally, please note the following:

            "If your NinjaScript object is using AddDataSeries() allowing to specify a tradingHoursName, please keep in mind that: An indicator / strategy with multiple DataSeries of the same instrument will only process realtime OnBarUpdate() calls when a tick occurs in session of the trading hour template of all added series. Any ticks not processed will be queued and processed as a tick comes in for all subsequent DataSeries."

            This means your script will prevent OBU from being called for any times outside of the two selected templates. For example, if your chart uses ETH hours but your added series uses RTH hours OBU is only going to be called for the RTH hours which are within the ETH hours.

            These notes are from the Help Guide on AddDataSeries():​




            Unfortunately the code for Order Flow Volume Profile is not open source, so we don't have visibility on how the code uses the selected trading hours.

            You could try using the user-defined trading hours to make your custom own time conditions.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            557 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            545 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X