Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 02-16-2008, 01:08 AM   #1

Join Date: Jan 2008
Posts: 3
Ignore this user

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.
johni is offline  
Reply With Quote
Old 02-16-2008, 09:16 AM   #2

Join Date: Feb 2007
Location: US
Posts: 314
Ignore this user

Thanks: 86
Thanked 206 Times in 89 Posts

Re: Allocating Trading Day Number

Code:
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.

]
thrunner is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
Number of Markets to Trade ant Beginners Forum 44 01-17-2009 06:17 AM
Normal expected move for x economic number walterw Market Analysis 7 06-03-2007 04:53 AM

All times are GMT -4. The time now is 11:39 AM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.