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

MTF Volume Question

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

    MTF Volume Question

    A friend decided to take NT8 for a test drive and he sent me question that I have no answer for.

    On an ES 500 Volume Chart with a Secondary Series of 1 Volume we could never get the the two Series to Balance. In other words, when tracking the volume on the 1 Volume Series if never adds up to 500 which is the Primary Volume chart. The attached image is a png of the output window showing that the numbers do not balance. Maybe it is my computer or possibly I am suffering from a colossal case of Saturday morning cranial flatulence.

    Any suggestions to cure this issue?

    PHP Code:

        
    public class MTFVolumeQuestion Indicator
        
    {

            private 
    double  BIP_1_VolumeCounter;

            protected 
    override void OnStateChange()
            {
                if (
    State == State.SetDefaults)
                {
                    
    Description                                    = @"Enter the description for your new custom Indicator here.";
                    
    Name                                        "MTFVolumeQuestion";
                    
    Calculate                                    Calculate.OnEachTick;
                    
    IsOverlay                                    false;
                    
    DisplayInDataBox                            true;
                    
    DrawOnPricePanel                            true;
                    
    DrawHorizontalGridLines                        true;
                    
    DrawVerticalGridLines                        true;
                    
    PaintPriceMarkers                            true;
                    
    ScaleJustification                            NinjaTrader.Gui.Chart.ScaleJustification.Right;
                    
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                    //See Help Guide for additional information.
                    
    IsSuspendedWhileInactive                    true;
                    
    AddPlot(Brushes.Orange"VolumePlot");
                }
                else if (
    State == State.Configure)
                {
                    
    AddDataSeries(Data.BarsPeriodType.Volume1);
                }
                else if (
    State == State.DataLoaded)
                {
                    
    ClearOutputWindow();
                }
            }

            protected 
    override void OnBarUpdate()
            {
                if(
    BarsInProgress == 0)
                {
                    Print(
    string.Format("\r\nBIP_0 Volume {0}     BIP_1_VolumeCounter {1}",  Volume[0], BIP_1_VolumeCounter ));

                    if(
    IsFirstTickOfBar)
                    {
                        
    //    Reset the BIP 1 (1 Volume) BIP_1_VolumeCounter to 0.
                        
    BIP_1_VolumeCounter 0;
                        Print(
    string.Format("BIP 0:   **** FirstTickOfBar {0:hh:mm:ss:fff tt}   BIP_1_VolumeCounter  {1,4}"Times[0][0], BIP_1_VolumeCounter  ));
                    }
                }
                if(
    BarsInProgress == 1)
                {
                    
    //Keep a running total of volume based on the 1 Volume Chart
                    
    BIP_1_VolumeCounter += Volume[0];

                    
    //    This prints to many Lines.
                    //    OutputWindow Error: You have reached the maximum threshold of the NinjaScript Output window. Some of your output messages have been suppressed.
                    //    Can Uncomment and Print just the last few Bars
    //                Print(string.Format("BIP 1:   {0:hh:mm:ss:fff tt}   Vol 1:  {1,4}    BIP_1_VolumeCounter {2,3}  ", Time[0], Volume[0], BIP_1_VolumeCounter  ));
                
    }            
            }

            
    #region Properties

            
    [Browsable(false)]
            [
    XmlIgnore]
            public 
    Series<doubleVolumePlot
            
    {
                
    get { return Values[0]; }
            }
            
    #endregion

        

    Attached Files
    Last edited by TAJTrades; 01-12-2019, 09:44 AM.

    #2
    Hello TAJTrades,

    I'm doing further research and creating a demonstration.

    I appreciate your patience.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello TAJTrades,

      Building using individual ticks is very complicated and there are many considerations.

      The main consideration is that if ticks or primary bars have the same time stamp, NinjaTrader doesn't know in what sequence to process that tick (either before or after the primary).


      An example script that does a pretty good job building with a 1 tick series can be found here.


      With Volume bars this is more complicated. With Volume bars NinjaTrader will be splitting the volume from ticks between different bars and will also be splitting the volume with the primary bars as well. This can cause two primary bars to have the same time stamp and it becomes more likely that the split volume from a tick may not be processed in the expected sequence before or after the primary bar processes.
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by mmenigma, Yesterday, 03:25 PM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by kujista, Today, 05:44 AM
      0 responses
      7 views
      0 likes
      Last Post kujista
      by kujista
       
      Started by ZenCortexCLICK, Today, 04:58 AM
      0 responses
      9 views
      0 likes
      Last Post ZenCortexCLICK  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      172 responses
      2,281 views
      0 likes
      Last Post sidlercom80  
      Started by Irukandji, Yesterday, 02:53 AM
      2 responses
      18 views
      0 likes
      Last Post Irukandji  
      Working...
      X