Time Exit at a Specific Time

Questions about MultiCharts and user contributed studies.
Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Time Exit at a Specific Time

Postby Spaceant » 04 Sep 2009

Hi,

With intrabarordergeneration, can I code an exit at a specific time, say 16:14:45, i.e at a precision upto second?

Sa

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Postby ABC » 04 Sep 2009

Spaceant,

in general you could do that. However as the code only gets executed when a tick comes in, I would make sure that you allow for the same time or later, just to be sure the exit is done when a tick comes in at 16:44:44 and the next at 16:44:46 only.

Regards,

ABC

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 04 Sep 2009

Thanks!

Can anyone give me a hand / clue to let me know what function I should use to code?

Sa

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 05 Sep 2009

if time_s >= xxxx then

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 05 Sep 2009

may i sugggest:

Building Winning Trading Systems with TS
http://www.amazon.com/Building-Winning- ... 904&sr=8-1

Image

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 05 Sep 2009

if that's too difficult for you, try this first:

Ask Mr. Easylanguage

http://www.amazon.com/Ask-Mr-Easylangua ... 079&sr=1-1


Image

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 05 Sep 2009

TJ,

Thanks, I just on't knwo that there is afunction call Time_S.

Well, I have just switched to use MC for months after using Metastock. I have tried to code the above idea, but have not tested in realtime. Please comment if there is any error.
[IntrabarOrderGeneration = True];

Inputs: TT(161445);
Vars: TExit(0);

TExit=Iff(Time_S>=TT,1,0);

If TExit=1 Then Sell ("LX") at Next bar at Close limit;
If TExit=1 Then Buy to Cover ("SX") at Next bar at Close limit;
I have not added the respective MarketPosition = 1 (or -1) for Sell and Buy to Cover, as I have tested for end of bar signal, that seems working without them, don't know why.

BTY, I've sent you a PM a long time ago. please check.

Sa

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 05 Sep 2009

... one more thing, can I backtest signals with IOG using MC 5.0 Gold? .. Or 5.5 beta?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 05 Sep 2009

TJ,

Thanks, I just on't knwo that there is afunction call Time_S.
...
Sa

time_s is a MultiCharts enhanced EasyLanguage.
It extends the time value to the seconds level.

You will find other _s keywords useful in your sub-minute analysis.
i.e. on tick charts, seconds charts, volume bar charts, etc.


examples of _s keywords
(there are more, this is not the complete list.)

tl_new_s
text_new_s
arw_new_s

CurrentTime_s
DateTime2ELTime_s
ElTimeToDateTime_s

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 05 Sep 2009

... I have tried to code the above idea, but have not tested in realtime. Please comment if there is any error.
[IntrabarOrderGeneration = True];

Inputs: TT(161445);
Vars: TExit(0);

TExit=Iff(Time_S>=TT,1,0);

If TExit=1 Then Sell ("LX") at Next bar at Close limit;
If TExit=1 Then Buy to Cover ("SX") at Next bar at Close limit;
...
Sa

looks good from here, but can't tell if it works...

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 06 Sep 2009

TJ or others,

well, the code seem not workingThe problem is that I am using 5-min chart while I want to have the time exit with an an accuracy upto second, say 9:13:45. I tried it but it seems have the exit on the beginning of the bar
of 9:15.

When I plot the following indicator on a 5-min chart at the time of 9:13:45 am.

Plot1(Time_s)

I indicators 91500, i.e. rounding up to the time as of the end-of-bar.

Time_S doesn't seem to able to count the time upto second in a 5-min chart, but every 5-min. Is that right or am I doing anything wrong?

Any trick that I can do to handle the code in a 5-min chart?

Sa

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 06 Sep 2009

how about currenttime_s ?
Last edited by TJ on 06 Sep 2009, edited 1 time in total.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 06 Sep 2009

download this PowerLanguage help file.
http://www.tssupport.com/multicharts/tu ... nguage.chm


look under Date and Time Routines.

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 07 Sep 2009

TJ,

Thanks! It works

Sa

ppan
Posts: 106
Joined: 31 Jan 2007
Has thanked: 2 times

Postby ppan » 08 Sep 2009

Will this method work if there is no new trade record after the specific time?

User avatar
Andrew Kirillov
Posts: 1589
Joined: 28 Jul 2005
Has thanked: 2 times
Been thanked: 31 times
Contact:

Postby Andrew Kirillov » 15 Sep 2009

With intrabarordergeneration, can I code an exit at a specific time, say 16:14:45, i.e at a precision upto second?

However as the code only gets executed when a tick comes in, I would make sure that you allow for the same time or later, just to be sure the exit is done when a tick comes in at 16:44:44 and the next at 16:44:46 only.

Will this method work if there is no new trade record after the specific time?
No, because it depends on the chart resolution. Note that the bar's time is used. So on 5-min chart you will get 161500; you need to use 1-sec chart.


Return to “MultiCharts”