Hi all,
if i am trading at a 3 min chart autotrade, and the session close time is 161500, how can i set the autotrade close all position automatically at 161430?
Thanks.
Autotrade Close all position at end of session
Re: Autotrade Close all position at end of session
Have a look at following link:Hi all,
if i am trading at a 3 min chart autotrade, and the session close time is 161500, how can i set the autotrade close all position automatically at 161430?
Thanks.
viewtopic.php?f=1&t=8025&p=37134#p37134
viewtopic.php?f=5&t=7834
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Autotrade Close all position at end of session
You can use "setexitonclose" code word,it works properly but in real time action the conditions are not always met.
There are two conditions that should be met:
Session end and a simultaneous with session end tick.
The second condition is not always met unfortunately, this can happen if the market is slow and the position won’t close.
You can achieve your goal by using this script.
You need to apply it as a separate strategy.
As an input you need to specify the time when you need to close the position, for example 163725 – is 16:37:25.
There are two conditions that should be met:
Session end and a simultaneous with session end tick.
The second condition is not always met unfortunately, this can happen if the market is slow and the position won’t close.
You can achieve your goal by using this script.
You need to apply it as a separate strategy.
Code: Select all
[intrabarordergeneration = true]
input: TimeClosePosition(0);
if (currenttime_s >= TimeClosePosition) then
Begin
RecalcLastBarAfter(1);
sell ("EOD_LX") next bar market;
buytocover("EOD_SX") next bar market;
End;
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Autotrade Close all position at end of session
most brokers require the last order to be submitted 3 minutes before closing time.
setexitonclose can be used in backtesting,
but in real life, it will generate a market order for the opening of next session.
setexitonclose can be used in backtesting,
but in real life, it will generate a market order for the opening of next session.
Re: Autotrade Close all position at end of session
Thanks All,
Luckily, the market i am trading is fast and many transcation, i think the script can help. Thanks.
Luckily, the market i am trading is fast and many transcation, i think the script can help. Thanks.