Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator works on time but not on tick or volume

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

    Indicator works on time but not on tick or volume

    I have been using Visual studio to try find this OnBarUpdate issue. I have a -1 index that is out of range.

    It works on minute charts but when I test on non time frame charts I get the error. The error is setting the plot

    MyPlot[0] = Bollinger(2, 14).Middle[0]


    The system is set to Calculate = Calculate.OnEachTick;

    f (BarsInProgress == 1 && CurrentBars[1] > 20 && IsFirstTickOfBar == true)
    {

    MyPlot[0] = Bollinger(2, 14).Middle[0];


    the 2 questions are the following

    1. On Currentbar is there a way to make sure you have enough CurrentBars to run?

    2. If this is set to Calculate.OnEachTick; do I get my logic at index 1 or index 0 because IsFirstTickOfBar == true;
    This plot is just a line.

    #2
    Hello ballboy11,

    Is MyPlot set to return a plot from the Values collection added with AddPlot()?

    Can you set other values to this series and print this value?

    If you call Print(Bollinger(2, 14).Middle[0]); does this print or error?

    This depends on the indexes being used.

    If you have a barsAgo value you are planning to use, you can ensure that CurrentBars[0] && CurrentBars[1] are both greater than that value.

    if (CurrentBars[0] > myBarsAgoValue && CurrentBars[1] > myBarsAgoValue)
    {
    Print(Time[myBarsAgoValue]);
    }

    When in real-time with Calculate.OnEachTick, barsAgo 0 will be the currently open building bar. barsAgo 1 will be the most recent fully closed bar.
    If you set a value any time while that bar is open that will be the value used, even if this is on the first tick.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    81 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    66 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X