• 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

How to find Lowest Bar value within a range of bars ?

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

    How to find Lowest Bar value within a range of bars ?

    I need to find the lowest bar within a range for ex: from index 2 to index 8 and current bar index is 0.

    I couldn't use LowestBar() method since it by default takes into account starting index as 0. Please suggest which method can be used in this situation ?




    Last edited by sachin shetty; 07-11-2020, 08:51 PM.

    #2
    Hello sachin shetty,

    Thanks for your post and welcome to the NinjaTrader forums!

    If you are looking for the lowest price I would suggest using the MIN() method where you can specify the Low data series, the number of bars to process and the start bar (Bars ago index). Using your example would be: myLowPrice = MIN(Low, 6)[2].

    If you need the lowest bars ago then I would suggest a for loop to interate over the range of bars and compare the low price. Something like:

    Code:
             
                    double lowprice = double.MaxValue;  // set initally to highest double type value
                    double lowbarsAgo = 0;
    
                    for (int i = 2; i < 9; i++)
                    {
                        if (Low[i] < lowprice)  // is low is less than previous low price
                        {
                            lowprice = Low[i];  // save new lower price
                            lowbarsAgo = i;     // save the bars ago value
                        }
                    }
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by jeronymite, Yesterday, 09:26 PM
    0 responses
    6 views
    0 likes
    Last Post jeronymite  
    Started by ttodua, 08-08-2020, 06:45 AM
    2 responses
    17 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by franco12364, Yesterday, 08:08 PM
    2 responses
    11 views
    0 likes
    Last Post franco12364  
    Started by smcllr, Yesterday, 06:10 PM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by lupearadu, Yesterday, 01:58 PM
    7 responses
    38 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X