Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Close from specific times of prior day and present day

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

    Close from specific times of prior day and present day

    I want to code a strategy with these conditions:

    Price at 2pm yesterday is greater than price at 10am yesterday.
    Price at 6am today is greater than price at 2pm yesterday.

    Once I know how to do that I can probably figure out the rest of it.

    Thanks

    #2
    Hello RickyTicky,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    The conditions would look like the following:
    Code:
    			// set the close of 10 AM yesterday to a double
    			if(ToTime(Time[0]) == ToTime(10,0,0) && Time[0].Day == DateTime.Now.AddDays(-1).Day)
    			{
    				tenAMClose = Close[0];
    			}
    			// set the close of 2 PM yesterday to a double
    			if(ToTime(Time[0]) == ToTime(14,0,0) && Time[0].Day == DateTime.Now.AddDays(-1).Day)
    			{
    				twoPMClose = Close[0];
    			}
    			// compare the two doubles for yesterday's closes
    			if(twoPMClose > tenAMClose)
    			{
    				// do something
    			}
    			// compare today's close at 6 AM to yesterday's at 2 PM
    			if(ToTime(Time[0]) == ToTime(6,0,0) && Close[0] > twoPMClose)
    			{
    				// do something
    			}
    For information on ToTime() please visit the following link: http://www.ninjatrader.com/support/h...nt7/totime.htm
    For information on Time please visit the following link: http://www.ninjatrader.com/support/h...s/nt7/time.htm

    Please let me know if I may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by t.kelly4149, Today, 05:36 PM
    1 response
    5 views
    0 likes
    Last Post bltdavid  
    Started by SilverSurfer1, Today, 06:29 PM
    0 responses
    14 views
    0 likes
    Last Post SilverSurfer1  
    Started by trader3000a, Today, 01:06 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_ShawnB  
    Started by marcus2300, Today, 11:45 AM
    3 responses
    30 views
    0 likes
    Last Post marcus2300  
    Started by pel11, Today, 11:06 AM
    0 responses
    12 views
    0 likes
    Last Post pel11
    by pel11
     
    Working...
    X