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

Trading between two dates

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

    Trading between two dates

    I can't figure out how code ninjatrader for trading between two dates

    Ex.

    from 1/1/2015 to 3/21/2015

    #2
    Hello,
    Thank you for your post.
    You would be able to create a Date filter using the properties of Time[0].Year, Time[0].Month and Time[0].Day.
    I have provided an example below of how you could accomplish this:

    Code:
    protected override void OnBarUpdate()
    {
    	if(Time[0].Year != 2015)
    		return;
    	if(Time[0].Month <= 3)
    		if(Time[0].Month == 3 && Time[0].Day > 21)
    			return;
    		else
    		{
    			EnterLong();
    		}
    	
    }
    Cody B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Belfortbucks, Today, 09:29 PM
    0 responses
    6 views
    0 likes
    Last Post Belfortbucks  
    Started by zstheorist, Today, 07:52 PM
    0 responses
    7 views
    0 likes
    Last Post zstheorist  
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    151 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Started by mattbsea, Today, 05:44 PM
    0 responses
    6 views
    0 likes
    Last Post mattbsea  
    Started by RideMe, 04-07-2024, 04:54 PM
    6 responses
    33 views
    0 likes
    Last Post RideMe
    by RideMe
     
    Working...
    X