Page 1 of 1

Time Exit at a Specific Time

Posted: Sep 04 2009
by Spaceant
Hi,

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

Sa

Posted: Sep 04 2009
by ABC
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

Posted: Sep 04 2009
by Spaceant
Thanks!

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

Sa

Posted: Sep 05 2009
by TJ
if time_s >= xxxx then

Posted: Sep 05 2009
by TJ
may i sugggest:

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

Image

Posted: Sep 05 2009
by TJ
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

Posted: Sep 05 2009
by Spaceant
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

Posted: Sep 05 2009
by Spaceant
... one more thing, can I backtest signals with IOG using MC 5.0 Gold? .. Or 5.5 beta?

Posted: Sep 05 2009
by TJ
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

Posted: Sep 05 2009
by TJ
... 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...

Posted: Sep 06 2009
by Spaceant
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

Posted: Sep 06 2009
by TJ
how about currenttime_s ?

Posted: Sep 06 2009
by TJ
download this PowerLanguage help file.
http://www.tssupport.com/multicharts/tu ... nguage.chm


look under Date and Time Routines.

Posted: Sep 07 2009
by Spaceant
TJ,

Thanks! It works

Sa

Posted: Sep 08 2009
by ppan
Will this method work if there is no new trade record after the specific time?

Posted: Sep 15 2009
by Andrew Kirillov
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.