Go Back   Traders Laboratory > Trading Resources > Trading Indicators > Coding Forum

Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Bookmarks
del.icio.us StumbleUpon Google Digg Facebook Furl Reddit Netscape

 
LinkBack Thread Tools Display Modes Language
  #1 (permalink)  
Old 02-16-2008, 01:08 AM
johni johni is offline
Registered Trader

 
Join Date: Jan 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Allocating Trading Day Number

Hi,

Anyone can help to translate the following Metastock code into TS2000i compatiable code?

The indicator allocate a number to each trading day and reset to zero following a new month.

========================= ========================= ====
{ User input }
EOM:=Input("Final month's end: [1]True, [2]Current (dynamic)",1,2,1);

{ Choice of Static/Dynamic last EOM signal }
EOM:=If(EOM=2,Cum(1)=Last Value(Cum(1)),
DayOfMonth()=31);

{ Start of month }
nuMonth:=Month()<>Ref(Mon th(),-1) OR Cum(1)=2;

{ End of month }
monthEnd:=PeakBars(1,
-(nuMonth OR Cum(IsDefined(nuMonth))=1 ),1)=0
OR EOM;

{ Plot signals in own window }
nuMonth;-monthEnd

BarsSince(nuMonth)
========================= ========================= =====

Regards.

Reply With Quote
  #2 (permalink)  
Old 02-16-2008, 09:16 AM
thrunner thrunner is offline
Registered Trader

 
Join Date: Feb 2007
Posts: 154
Thanks: 50
Thanked 34 Times in 17 Posts
Re: Allocating Trading Day Number

if Month( date ) <> Month( CalcDate( date, iff( DayOfWeek( d ) <> 5, 1, 3 ) ) ) then print( date ) ;
Quote:
The CalcDate function adds and subtracts days from a reference date. The reference date is a numeric value in the EasyLanguage date format: YYYMMDD (Year Month Day).

For example, 1030101 = Jan. 1st, 2003 or 9906015 = June 15, 1999

Since EasyLanguage and Chart Analysis use this special date format, it is sometimes difficult to add or subtract some number of days from the EasyLanguage date. For example, if you wanted to subtract 15 days from Jan 1, 2003, you might try 1030101 – 15, which would result in an invalid date, CalcDate solves this by returning the correct and valid date of 1021216

Syntax
CalcDate(RefDate,DaysChan ge)

Returns (Integer)
A numeric value the represents the date in EasyLanguage format for the current bar.

]

Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Normal expected move for x economic number walterw Market Analysis 7 06-03-2007 04:53 AM
Number of Markets to Trade ant Beginners Forum 43 10-22-2006 06:07 AM


All times are GMT -4. The time now is 07:11 PM.

 


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59