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 burtoninlondon, Today, 12:38 AM
    0 responses
    10 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    14 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    11 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Yesterday, 07:51 PM
    0 responses
    14 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,983 views
    3 likes
    Last Post jhudas88  
    Working...
    X