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 samish18, Today, 01:01 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by WHICKED, Today, 12:56 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by cre8able, Today, 01:16 PM
    0 responses
    3 views
    0 likes
    Last Post cre8able  
    Started by chbruno, 04-24-2024, 04:10 PM
    2 responses
    47 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by WHICKED, Today, 12:45 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X