Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Maximum and minimum prices of the last 10 periods

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

    Maximum and minimum prices of the last 10 periods

    I need to pass the max price and min price to variables.

    I read the following pages:




    The code would be this:

    ###################################

    int highestBarsAgo = HighestBar(High, 10);

    double highestPrice = High[highestBarsAgo];

    ###################################

    ###################################

    int lowestBar = LowestBar(Low, 10);

    double lowestPrice = Low[lowestBar];

    ###################################​​

    When running the strategy, it gives me the following error: (I attach a screenshot of the error message)​
    Attached Files

    #2
    Hello villarroel0401,

    Thanks for your post.

    Does the error message only appear when running the NinjaScript strategy that you created on a new blank chart window?

    In the strategy, are you using a CurrentBar or CurrentBars check to ensure that at least 10 bars have been processed in the data series you are accessing in the script?

    If not, please add a CurrentBar check to make sure that there are enough bars processed for the data series you are accessing.

    Make sure you have enough bars: https://ninjatrader.com/support/help...nough_bars.htm

    Prints should also be added to the script that print out the indexes you are accessing and the CurrentBar to see how that logic is evaluating. Note that the index you are accessing in the script cannot be larger than the CurrentBar index.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.
    https://ninjatrader.com/support/foru...121#post791121
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    598 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    343 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    556 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    555 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X