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 ChrisR, Yesterday, 09:24 PM
    3 responses
    16 views
    0 likes
    Last Post ChrisR
    by ChrisR
     
    Started by balltrader, Today, 10:06 AM
    6 responses
    29 views
    1 like
    Last Post QuantKey_Bruce  
    Started by Attila, 03-07-2023, 09:47 AM
    4 responses
    31 views
    0 likes
    Last Post BartMan
    by BartMan
     
    Started by BartMan, Today, 03:59 PM
    0 responses
    14 views
    0 likes
    Last Post BartMan
    by BartMan
     
    Started by QuantKey_Bruce, 03-29-2023, 02:31 PM
    10 responses
    43 views
    0 likes
    Last Post BartMan
    by BartMan
     
    Working...
    X