Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Finding MIN Value without using MIN indicator

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

    Finding MIN Value without using MIN indicator

    Hello,
    I would like to know if there is another possible way to get the minimum value of a Series.
    The problem i'm facing right now is that the MIN Indicator code use for loop
    I'm searching for very long periods (14400+) which eats up my memory in backtest.

    hope someone can assist.

    #2
    Hello bugo11,

    Thanks for your post.

    Yes, if you use MIN() and do a look back to the beginning of the data series, on each new bar, that would be very inefficient.

    When a script is added to a chart, it will process on all of the bars starting at the beginning of the data series and run all the way to the latest bar.

    I would suggest writing an indicator that will process each bar once and simply compare the value to the lowest previously found and if lower to then save as the new low. When the indicator reaches the right edge you would have your answer.

    Here is an example, using the Low price series


    private double myLow = double.MaxValue; // create with the maximum possible value

    In OnBarUpdate()

    if (Low[0] < myLow)
    {
    myLow = Low[0]; // assign the current bar low to the variable myLow.
    }




    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    72 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    152 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    100 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    288 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X