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

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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    148 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Started by mattbsea, Today, 05:44 PM
    0 responses
    5 views
    0 likes
    Last Post mattbsea  
    Started by RideMe, 04-07-2024, 04:54 PM
    6 responses
    33 views
    0 likes
    Last Post RideMe
    by RideMe
     
    Started by tkaboris, Today, 05:13 PM
    0 responses
    5 views
    0 likes
    Last Post tkaboris  
    Started by GussJ, 03-04-2020, 03:11 PM
    16 responses
    3,282 views
    0 likes
    Last Post Leafcutter  
    Working...
    X