Not logged in
Viewing 5 posts - 1 through 5 (of 5 total)

Forums>StrategyQuant>General Discussion>How to close all positions at custom date?

  • #255117|
    Participant
    2 Posts

    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.

    #255124
    tomas262
    Administrator
    1158 Posts

    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
    );
    
    }
    #255127
    Participant
    2 Posts

    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.

    • This reply was modified 1 week, 2 days ago by  sh be.
    • This reply was modified 1 week, 2 days ago by  sh be.
    #255138
    Customer
    321 Posts

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

    You want to be a profitable algotrader? Sharing of final strategies with real traders just started. Fill in this FORM. 1500+ final SQ3 and SQX strategies for members running on demo accounts DEMO ACCS. We provide also strategies for indices - DAX and DOW JONES, because we have realtick data from brokers.

    #255173
    tomas262
    Administrator
    1158 Posts

    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

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

You must be logged in to reply to this topic.