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 burtoninlondon, Today, 12:38 AM
    0 responses
    5 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    14 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    11 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Yesterday, 07:51 PM
    0 responses
    13 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,982 views
    3 likes
    Last Post jhudas88  
    Working...
    X