NexusFi: Find Your Edge


Home Menu

 





first day of the week/month - requesting last day of the week/month


Discussion in NinjaTrader

Updated
    1. trending_up 4,452 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

first day of the week/month - requesting last day of the week/month

  #1 (permalink)
 SARdynamite 
Belgium
 
Experience: Advanced
Platform: SaxoTrader
Broker: SaxoBank
Trading: ESTX
Posts: 289 since Dec 2009
Thanks Given: 243
Thanks Received: 110

If it can help anybody, here are bits of code to detect first day of month and more complicated, first day of week, isolating holidays and misc. session closed.

in declarations don't forget

 
Code
using System.Globalization;
month


 
Code
CultureInfo ciCurr = CultureInfo.CurrentCulture;
int  weekNumsessionprec =  ciCurr.Calendar.GetWeekOfYear(Bars.GetSessionBar(1).Time,  CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
int  weekNumcurrentsession = 
ciCurr.Calendar.GetWeekOfYear(Bars.GetSessionBar(0).Time,  
CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
week
 
Code
if(weekNumsessionprec!=weekNumcurrentsession )
I'd like to know if you guys have a trick to detect this time, the LAST day of the week/month (excluding sessions closed, holidays, weekends), which is more trouble...

Why ? because I like to display my pivots as soon as I've got the close of the last day, in order to think about the potential trades for upcoming week or month.

Thanks already

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Request for MACD with option to use different MAs for fa …
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
58 thanks
Battlestations: Show us your trading desks!
50 thanks
NexusFi site changelog and issues/problem reporting
47 thanks
GFIs1 1 DAX trade per day journal
32 thanks
What percentage per day is possible? [Poll]
31 thanks

  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


Here is a method from the pivot indicator, for a DateTime time it returns the last day of the week and the last day of the month.


 
Code
                            
private DateTime RoundUpTimeToPeriodTime(DateTime timePivotRange pivotRange)
{
if (
pivotRange == PivotRange.Weekly)
{
DateTime periodStart time.AddDays((- (((int) time.DayOfWeek) + 1) % 7));
return 
periodStart.Date.AddDays(System.Math.Ceiling(System.Math.Ceiling(time.Date.Subtract(periodStart.Date).TotalDays) / 7) * 7).Date;
}
else if (
pivotRange == PivotRange.Monthly)
{
DateTime result = new DateTime(time.Yeartime.Month1); 
return 
result.AddMonths(1).AddDays(-1);
}
else
return 
time;

If you want to add holidays, you need an array which contains all relevant holiday dates. May I point again to the SessionPivots indicator for NT7. I had exactly the same problems.

Reply With Quote
The following 3 users say Thank You to Fat Tails for this post:
  #4 (permalink)
 SARdynamite 
Belgium
 
Experience: Advanced
Platform: SaxoTrader
Broker: SaxoBank
Trading: ESTX
Posts: 289 since Dec 2009
Thanks Given: 243
Thanks Received: 110

Thank you so much. It had me locked from evolving for a long time.
I'll dive into it tonight or tommorrow. Thanks again.

Started this thread Reply With Quote





Last Updated on July 15, 2010


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts