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

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
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by mishhh, 05-25-2010, 08:54 AM
    19 responses
    6,189 views
    0 likes
    Last Post rene69851  
    Started by gwenael, Today, 09:29 AM
    0 responses
    4 views
    0 likes
    Last Post gwenael
    by gwenael
     
    Started by Karado58, 11-26-2012, 02:57 PM
    8 responses
    14,830 views
    0 likes
    Last Post Option Whisperer  
    Started by Option Whisperer, Today, 09:05 AM
    0 responses
    2 views
    0 likes
    Last Post Option Whisperer  
    Started by cre8able, Yesterday, 01:16 PM
    3 responses
    11 views
    0 likes
    Last Post cre8able  
    Working...
    X