Closing operations Friday night at 22:00h

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #42862 quote
    Juan Salas
    Participant
    Master

    Dear all,

    I have coded the closing of my operations in my system on Friday night at 22:00h to avoid having open position during weekends and expose those positions to weekends gaps and charges from the broker.

    I have opted for the command QUIT, but I am not sure if that will stop the system or just will close the operation until Monday at 00:00h

    I am including the code and would appreciate any comments or even suggestions or alternative options.

    Thanks so much.

    Juan

    // Days of the week
    IF DayOfWeek = 0 OR Dayofweek = 6 THEN
    tradeok = 0
    ELSE
    tradeok = 1
    ENDIF
    
    // Friday 22:00 STOP operations
    IF Dayofweek = 5 AND TIME = 220000 THEN
    QUIT
    ENDIF
    #42947 quote
    Juan Salas
    Participant
    Master

    Hi,

    I am answering myself, :))

    I think that:

    IF Dayofweek = 5 THEN

    DEFPARAM Flatafter = 220000

    ENDIF

    #42948 quote
    Juan Salas
    Participant
    Master

    Hi,

    It doesn’t work. DEFPARAM can’t be used like that.

    Any suggestions???

    (Reminder: I want to close the operations on Friday night at 220000, but I want the system to run from Monday to Friday without interruption)

    Thanks in advance,

    Juan

    #42949 quote
    robertogozzi
    Moderator
    Master

    Try this one (I did not):

    IF DayOfWeek = 5 AND time = 220000 THEN
       SELL      AT MARKET
       EXITSHORT AT MARKET
    ENDIF
    

    You close any trade, either LONG or SHORT at the time you want, on the day you want to.

    You can’t use DEFPARAM in conditional statements, it’s an unchangeable directive to ProOrder, not an instruction.

    #42951 quote
    Juan Salas
    Participant
    Master

    Hi Roberto,

    Gracie mille. I will try it right now and will let you know the results.

    Juan

    #42954 quote
    Juan Salas
    Participant
    Master

    Hi Roberto,

    It works. I have also added something to avoid launch any operation after 22:0000 on Friday.

    // Friday 22:00 Close ALL operations.
    IF DayOfWeek = 5 AND time = 220000 THEN
    SELL      AT MARKET
    EXITSHORT AT MARKET
    ENDIF
    
    Fridaynight = Dayofweek = 5 AND time>220000
    

    Oil Market close at around 23:00, and reopens after 00:00 everyday. At least at this hour there is a gap or inactivity everyday, but sometimes close before. In some cases I have noticed that cease all the trading around 220000, so just to be safe I have decided to set up closing operations on Friday at 22:00.

    After that I noticed in the backtest that the system bought at 22:45 on Friday in two occasions, causing in one of them a gap of 243 points until Monday. So to avoid any involuntary buying or selling after 22:00 I have included the Fridaynight (doesn’t sound very professional, but it works 😉

    Thanks again,

    Juan

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Closing operations Friday night at 22:00h


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Juan Salas @juan-salas Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by Juan Salas
8 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/10/2017
Status: Active
Attachments: No files
Logo Logo
Loading...