Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MIN and double

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

    MIN and double

    Hello!
    I am trying to calculate the minimum of the duration of the last 10 candles, without adding an additional series. Is there similar to MIN() that doesn't get error?
    Thanks!​


    TimeSpan time1 = Time[0] - new DateTime(1970,1,1,0,0,0);
    TimeSpan time2 = Time[1] - new DateTime(1970,1,1,0,0,0);
    double diff=(double)time1.TotalSeconds-(double)time2.TotalSeconds;
    double diff2=0.00;
    double diff3=0.00;

    if (Bars.IsFirstBarOfSession)
    {
    diff2=diff2;
    }

    else
    {
    diff2= diff;
    }

    diff3 = MIN(diff2, 10);​

    #2
    Hello agustinarolon,

    Thanks for your post.

    I see that you are creating double variables and passing in the double variable 'diff2' into the MIN() method.

    The MIN() method requires a Series<double> variable to be used instead of a double variable. Also, you should specify the barsAgo value you want to access the information for when calling the MIN() method. The correct MIN() syntax noted in the help guide can be seen below.

    MIN(ISeries<double> input, int period)[int barsAgo]

    This means that you would need to create a Series<double> variable instead of a regular double variable, assign the value to the Series<double> variable, and use that Series<double> when calling the MIN() method.

    See this help guide page for more information about creating Series<double> variables and sample code: https://ninjatrader.com/support/help...t8/seriest.htm

    See this help guide page for more information about MIN() and sample code: https://ninjatrader.com/support/help...inimum_min.htm

    Please let me know if I may assist further.
    <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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    56 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    132 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    73 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X