• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Extract data from volumetric bars.

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

  • NinjaTrader_ChelseaB
    replied
    Hello franki,

    With the error:
    "Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart"

    This message indicates an invalid index was used.

    As one example, calling Close[1] when CurrentBar is 0 (the very first bar) will cause this error.

    The reason for this is because there will not be a bar ago, essentially there is not enough data at bar 0 to calculate to look a bar ago.

    The script will start from the far left of the chart at the very beginning where the CurrentBar will equal 0 and then start working to the right, calling each bar for OnBarUpdate();

    In this specific example, it would be needed to wait for the second bar to be built (from all series if there are multiple series added), to ensure that you have enough data to call a index 1 bar ago.

    This is especially important when multiple series are added to a single script as the data for all series may not start at the same time.

    Below are public links to the help guide on CurrentBar and CurrentBars.
    http://ninjatrader.com/support/helpG...currentbar.htm
    https://ninjatrader.com/support/help...urrentbars.htm


    Also, below is a link to a 3rd party educational site on C# as a reference.
    https://www.dotnetperls.com/indexoutofrangeexception

    Leave a comment:


  • franki
    replied
    Originally posted by NinjaTrader_ChelseaB View Post
    Hello franki,

    Is the script an indicator or strategy?
    Hello ChelseaB
    It is a modified and functional strategy has been taken as a template in this forum. (Unmanaged template)

    Originally posted by NinjaTrader_ChelseaB View Post
    To confirm, when checking the Enabled checkbox for the strategy it immediately becomes disabled?
    just a couple of seconds, it goes from calculating .... to "disable" when pressing the button to apply
    Originally posted by NinjaTrader_ChelseaB View Post
    Are there errors appearing in the Log tab of the Control Center?
    If so, what do these say.

    These are very specific conditions in the logic.

    Have you used prints to print all values for all variables and determined that the condition will evaluate as true?
    http://ninjatrader.com/support/forum...979#post510979
    The code thrown by log and by the window ninjascript Output is as follows

    Code:
    Strategy 'VolumetricTracked': Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index 
    with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a 
    value of 5 when there are only 4 bars on the chart
    Attached photograph of before adding bar code close [0]

    Sincerely I have no idea why this happens, I would greatly appreciate a solution as an example or reference documentation.
    Thank you.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello franki,

    Is the script an indicator or strategy?

    To confirm, when checking the Enabled checkbox for the strategy it immediately becomes disabled?

    Are there errors appearing in the Log tab of the Control Center?
    If so, what do these say.


    These are very specific conditions in the logic.

    Have you used prints to print all values for all variables and determined that the condition will evaluate as true?
    http://ninjatrader.com/support/forum...979#post510979

    Leave a comment:


  • franki
    replied
    Hello again, I managed to get the data I needed through a script, now I try to mark sequences with this code
    Code:
        protected override void OnBarUpdate()
            {
    
                if (BarsInProgress != 0)
    
    
                  if (Bars == null)
                          return;
                    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType barsType = Bars.BarsSeries.BarsType as     
                    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType;
                  if (barsType == null)
                    return;
    
                 if (  Open[1] > Close[1]
                               && Position.MarketPosition == MarketPosition.Flat
                    && barsType.Volumes[CurrentBar].BarDelta > -250
                    && barsType.Volumes[CurrentBar].MinSeenDelta > -250
                    && barsType.Volumes[CurrentBar].MaxSeenDelta == -10
                    ||Open[2] > Close[2]
                            && Position.MarketPosition == MarketPosition.Flat
                    && barsType.Volumes[CurrentBar].BarDelta > -250
                    && barsType.Volumes[CurrentBar].MinSeenDelta > -250
                    && barsType.Volumes[CurrentBar].MaxSeenDelta == -10
                    ||Open[1] > Close[1]
                              && Position.MarketPosition == MarketPosition.Flat
                    && barsType.Volumes[CurrentBar].BarDelta > -250
                    && barsType.Volumes[CurrentBar].MinSeenDelta > -250
                    && barsType.Volumes[CurrentBar].MaxSeenDelta == -25
                    ||Open[2] > Close[2]
                            && Position.MarketPosition == MarketPosition.Flat
                    && barsType.Volumes[CurrentBar].BarDelta > -250
                    && barsType.Volumes[CurrentBar].MinSeenDelta > -250
                    && barsType.Volumes[CurrentBar].MaxSeenDelta == -25
                    || Open[1] > Close[1]
                            && Position.MarketPosition == MarketPosition.Flat
                    && barsType.Volumes[CurrentBar].BarDelta  == barsType.Volumes[CurrentBar].MinSeenDelta
                    && barsType.Volumes[CurrentBar].MaxSeenDelta == -10
                    || Open[2] > Close[2]
                            && Position.MarketPosition == MarketPosition.Flat
                    && barsType.Volumes[CurrentBar].BarDelta  == barsType.Volumes[CurrentBar].BarDelta 
                    && barsType.Volumes[CurrentBar].MaxSeenDelta == -10
                    ||Open[1] > Close[1]
                            && Position.MarketPosition == MarketPosition.Flat
                    && barsType.Volumes[CurrentBar].BarDelta  == barsType.Volumes[CurrentBar].MaxSeenDelta 
                    && barsType.Volumes[CurrentBar].MaxSeenDelta == -25
                    || Open[2] > Close[2]
                            && Position.MarketPosition == MarketPosition.Flat
                    && barsType.Volumes[CurrentBar].BarDelta  == barsType.Volumes[CurrentBar].MinSeenDelta
                    && barsType.Volumes[CurrentBar].MaxSeenDelta == -25)
                    {
    
                    if ( Open[0] < Close[0]
                        && Position.MarketPosition == MarketPosition.Flat
                        && barsType.Volumes[CurrentBar].BarDelta > 250
                        && barsType.Volumes[CurrentBar].MaxSeenDelta > 250
                        && barsType.Volumes[CurrentBar].MinSeenDelta == 10
                        || Open[0] < Close[0]
                        && Position.MarketPosition == MarketPosition.Flat
                        && barsType.Volumes[CurrentBar].BarDelta > 250
                        && barsType.Volumes[CurrentBar].MaxSeenDelta > 250
                        && barsType.Volumes[CurrentBar].MinSeenDelta == 25
                        || Open[0] < Close[0]
                        && Position.MarketPosition == MarketPosition.Flat
                        && barsType.Volumes[CurrentBar].BarDelta == barsType.Volumes[CurrentBar].GetMaximumPositiveDelta() 
                        && barsType.Volumes[CurrentBar].MinSeenDelta == 10
                        || Open[0] < Close[0]
                        && Position.MarketPosition == MarketPosition.Flat
                        && barsType.Volumes[CurrentBar].BarDelta ==  barsType.Volumes[CurrentBar].GetMaximumNegativeDelta() 
                        && barsType.Volumes[CurrentBar].MinSeenDelta == 25)
                        {
                            Draw.Ellipse(this, "MyEllipse" + CurrentBar, 1, Low[0] -3 * TickSize, -1, High[0] +3 * TickSize, Brushes.Green);
                        }
                    }
    it compiles well, but the script does not get enabled

    What am I doing wrong?
    Thank you!

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello franki,

    While this information is not provided from the Volumetric bars themselves, you could build this in an indicator or strategy.

    The script is doing the equivalent of adding a 1 tick series and then using BarsArray[1].GetAsk() / .GetBid() to get the ask and bid that are stamped with the last data.

    I have an example named TnSVolume that does something similar and you may be able use this as a guide.
    http://ninjatrader.com/support/forum...265#post503265
    Last edited by NinjaTrader_ChelseaB; 11-28-2018, 01:45 PM.

    Leave a comment:


  • franki
    started a topic Extract data from volumetric bars.

    Extract data from volumetric bars.

    Hello ninjatrader team

    I have looked at all the documentation published about it and I can not find a solution.
    My intention is to extract a series of data from the volumetric bars to make comparisons with custom values, using a script or indicator
    These are the three lower cells on the left side, when they represent a value, be compared with custom values or parameters, as well as with the three upper cells on the right side in a volumetric bar.
    indicated in the attached image.

    I have taken references in
    https://ninjatrader.com/support/help...me_profile.htm
    https://ninjatrader.com/support/help..._flow_plus.htm
    https://ninjatrader.com/support/help...tric_bars2.htm
    https://ninjatrader.com/support/help...flow_vwap2.htm

    and also searches in the forum, and I have not found any way to extract the data.
    My question is: is there an example or some more specific documentation that says how to extract data from the volumetric bars to form a script or indicator oriented to this objective?

    thank you.

Latest Posts

Collapse

Topics Statistics Last Post
Started by gtheaded, Today, 03:47 PM
1 response
4 views
0 likes
Last Post NinjaTrader_Tyler  
Started by TAJTrades, Today, 03:25 PM
0 responses
5 views
0 likes
Last Post TAJTrades  
Started by DTSSTS, Today, 01:26 PM
0 responses
5 views
0 likes
Last Post DTSSTS
by DTSSTS
 
Started by RFrosty, Today, 01:20 PM
0 responses
15 views
0 likes
Last Post RFrosty
by RFrosty
 
Started by Newtrader101, Today, 12:59 PM
4 responses
12 views
0 likes
Last Post Newtrader101  
Working...
X