Force exit at specific time of the day in Chart trading

Questions about MultiCharts and user contributed studies.
my2108
Posts: 12
Joined: 06 Aug 2018
Has thanked: 1 time

Force exit at specific time of the day in Chart trading

Postby my2108 » 21 Jul 2020

HI,

As titled, I wonder if there is any thing I can do to exit all my position under chart trading at specific time of the day?
I understand I could do it in easy language if I am executing one of my strategy...

hope someone could advise.

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: Force exit at specific time of the day in Chart trading

Postby Svetlana MultiCharts » 29 Jul 2020

Hello my2108,

You can try the following signal in addition to your existing signals.

Code: Select all

if time >= 1242 or time <= 1243 then begin sell this bar at close; buytocover this bar close; end;

User avatar
abeherrera
Posts: 6
Joined: 23 Feb 2021
Has thanked: 1 time
Been thanked: 1 time

Re: Force exit at specific time of the day in Chart trading

Postby abeherrera » 25 Feb 2021

Hello my2108,

You can try the following signal in addition to your existing signals.

Code: Select all

if time >= 1242 or time <= 1243 then begin sell this bar at close; buytocover this bar close; end;
If im on an hourly time frame the close would be at the end of the hour right?
However if wanted to end it before the bar closed, would i have to program my strategy on the min time frame to be able to exit at 12:43, or would the code above still work?

Thanks in advance!

Im asking because I tried implementing the code above and it epically failed for me. However it was only back tested on the study.

Would this code work if it were live?

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

Re: Force exit at specific time of the day in Chart trading

Postby TJ » 26 Feb 2021

Your chart resolution is your analysis resolution.

User avatar
abeherrera
Posts: 6
Joined: 23 Feb 2021
Has thanked: 1 time
Been thanked: 1 time

Re: Force exit at specific time of the day in Chart trading

Postby abeherrera » 26 Feb 2021

I understand but just sucks because I will have to write more code if I want to get out 10 min before the market closes everyday. there should be a reserved word for this or something.

However the code you gave is very helpful to be able to exit on the time base on time of my computer, I will first have to get familiar with it & play with this in demo before goin live. Since it cant be used in a backtesting environment.

Code by TJ @ viewtopic.php?t=10811

input:

Last.Order.Time(1555);



if CurrentTime >= Last.Order.Time then

begin

SELL ...

BUYTOCOVER ...

end;

Thanks for all the work you have put into your posts very helpful

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

Re: Force exit at specific time of the day in Chart trading

Postby TJ » 26 Feb 2021

. . .

Thanks for all the work you have put into your posts very helpful
You are welcome.

ps. How to post code -- see post #1 and post #2
viewtopic.php?t=11713

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

Re: Force exit at specific time of the day in Chart trading

Postby TJ » 26 Feb 2021

One trick you can try is to set your session end time at X minutes before the actual time.


Return to “MultiCharts”