Announcement

Collapse
No announcement yet.

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 Hwop38, 05-04-2026, 07:02 PM
    0 responses
    161 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    310 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    245 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    350 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    179 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X