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 Brevo, Today, 01:45 AM
    0 responses
    3 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    3 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    239 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    384 views
    1 like
    Last Post Gavini
    by Gavini
     
    Started by oviejo, Today, 12:28 AM
    0 responses
    6 views
    0 likes
    Last Post oviejo
    by oviejo
     
    Working...
    X