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

variable days

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

    variable days

    I want to make one variable of the days this formula

    ===================================
    if (ToTime(Time[0]) >= ToDay(2007, 3, 12)
    && ToTime(Time[0]) < ToDay(2007, 6, 6)
    && EMA(14)[0] > EMA(50)[0]
    )
    {
    EnterLong(1, "LongZ");
    }

    =====================================
    private string EnterDatein = "2007, 3, 12;" ;
    private string EnterDatefn = "2007, 6, 12;" ;

    if these are the variable ones

    how I replace to them in the formula?

    Thanks

    #2
    Assuming you are coding this manually via the NinjaScript Editor, I would create a DateTime variable instead of a string variable.

    Under the "Variables" section:

    Code:
    private DateTime enterDate = DateTime.Today;
    then under the "Properties" section:

    Code:
    /// <summary>
    /// </summary>
    [Description("Enter date")]
    [Category("Parameters")]
    public DateTime EnterDate
    {
        get { return enterDate; }
        set { enterDate = value; }
    }
    * Note that the variable name is different than the property name since the first letter's case is different.

    This parameter will now show up as a date selection when running a strategy.

    You can then compare such as:

    Code:
    if (ToDay(Time[0]) >= ToDay(EnterDate))
        EnterLong();
    RayNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by geddyisodin, 04-25-2024, 05:20 AM
    8 responses
    60 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    4 responses
    3,287 views
    1 like
    Last Post jgualdronc  
    Started by Option Whisperer, Today, 09:55 AM
    0 responses
    5 views
    0 likes
    Last Post Option Whisperer  
    Started by halgo_boulder, 04-20-2024, 08:44 AM
    2 responses
    22 views
    0 likes
    Last Post halgo_boulder  
    Started by mishhh, 05-25-2010, 08:54 AM
    19 responses
    6,189 views
    0 likes
    Last Post rene69851  
    Working...
    X