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.
Force exit at specific time of the day in Chart trading
- 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
Hello my2108,
You can try the following signal in addition to your existing signals.
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;
- 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
If im on an hourly time frame the close would be at the end of the hour right?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;
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?
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Force exit at specific time of the day in Chart trading
Your chart resolution is your analysis resolution.
- 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
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
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
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Force exit at specific time of the day in Chart trading
You are welcome.. . .
Thanks for all the work you have put into your posts very helpful
ps. How to post code -- see post #1 and post #2
viewtopic.php?t=11713
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Force exit at specific time of the day in Chart trading
One trick you can try is to set your session end time at X minutes before the actual time.