Reply

How to close all positions at custom date?

4 replies

sh be

Subscriber, bbp_participant, 0 replies.

Visit profile

1 year ago #255117

Similar to Trading options ->“Exit on Friday”, I need close all positions at custom date,2019-01-15 17:00 and 2019-02-15 17:00 and 2019-03-15 17:00.

0

tomas262

Administrator, sq-ultimate, 684 replies.

Visit profile

1 year ago #255124

Hello,

currently this is not directly supported in StrategyQuant but we can consider adding a function like this. If you need this specific action to be managed by your EA (close positions on a specific day) it can be easily done by adding short code into your EA depending on platform you use. You can send me your EA code to support@strategyquant.com and I can show you how to easily do this

Just for an example how to add SQ EA exit rule to take an exit date into account:

datetime exitLongOn3rdMay=D'2020.05.03 21:00';

//------------------------
// Rule: Long exit on specific day & time
//------------------------

if ((TimeCurrent()==exitLongOn3rdMay) && sqMarketPositionIsLong(MagicNumber, "Any", "")) {

// Action #1
sqClosePosition(OrderLots(), // size: SQ.Formulas.CloseSize.FullPosition
MagicNumber, // magic number
"Any", // symbol
1, // direction
"" // comment
);

}

0

sh be

Subscriber, bbp_participant, 0 replies.

Visit profile

1 year ago #255127

Thank you for your help, can I use “StrategyQuant X platform codebase” to achieve this function?  In the futures market, for continuous contract backtesting, this custom date is very important.

0

hankeys

Customer, bbp_participant, community, 480 replies.

Visit profile

1 year ago #255138

you can add to code whatever you want, but your backtest will not be accurate anymore

You want to be a profitable algotrader? We started using StrateQuant software in early 2016. For now we have a very big knowhow for building EAs for every possible types of markets. We share this knowhow, apps, tools and also all final strategies with real traders. If you want to join us, fill in the FORM. 1500+ final SQX strategies for members running on demo accounts to verify the edge DEMO ACCS. We provide also strategies for indices - DAX, DOW JONES, NASDAQ, SP, UK, because we have realtick data from our brokers.

0

tomas262

Administrator, sq-ultimate, 684 replies.

Visit profile

1 year ago #255173

Hello,

yes, we could add this into SQX so on the “rollover day” the strategy would close all positions automatically while the platform will automatically roll the symbol over into next contract into next session. So the next day the strategy will open trades using the new contract. Currently you need to manage it manually but for most futures contracts you can just use “Exit on Friday”

For example if you consider index futures strategies like US e-minis/e-micros you can trade these with strategies that use “Exit on Friday”. The roll over day for index futures is considered to be the second Thursday in the contract month but you can easily trade that contract even on Friday since the volume is about fifty-fifty when compared to next contract. Next week Monday the strategy will be trading the new contract (the platform will roll the chart into next contract)

Next example – CL crude oil – you can modify the platform auto-rollover date to earlier (like 1 week earlier) to avoid getting into FND in the middle of a week and still use the “Exit on Friday” rule and trade next contract month since there is enough liquidity. For example – today’s volume Feb 20 contract – 549,698 and Mar 20 contract 268,955 …. while LTD for CL Feb 20 is 21st Jan 2020 so on Monday next week you would roll from CLG20 into CLH20

I do not think those 4 days in a year (US indexes) in which a position is “killed” prematurely on Friday and not held into next week as it was in backtest will make the backtest made using continuous contract worthless… I personally never hold an outright futures position into the weekend .. you never know when somebody in the world gets mad at weekend, blows something up and market goes roof top on Monday open. Recent example might be the crude oil 16th Sep 2019 .. gapped up 5,000 USD per contract

0

Viewing 5 posts - 1 through 5 (of 5 total)