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 mkouitra, 10-23-2021, 04:40 PM
    17 responses
    1,959 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by Vietanhnguyen2hotmailcom, 05-03-2024, 10:29 AM
    4 responses
    27 views
    0 likes
    Last Post Vietanhnguyen2hotmailcom  
    Started by PhillT, 04-19-2024, 02:16 PM
    4 responses
    36 views
    0 likes
    Last Post PhillT
    by PhillT
     
    Started by ageeholdings, 05-01-2024, 05:22 AM
    5 responses
    38 views
    0 likes
    Last Post ageeholdings  
    Started by reynoldsn, Yesterday, 02:34 PM
    0 responses
    16 views
    0 likes
    Last Post reynoldsn  
    Working...
    X