Close transaction at specific time

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #80801 quote
    africangunslinger
    Participant
    New

    Hi all,

    I am trying to code a autotrader that enters into a long position in Hong Kong 50 between certain times and which closes the transaction at a specific time.

    the enter long command wouldn’t work when putting down the IF statement in the following form ‘CurrentTime >= 10400 AND CurrentTime <= 030000 THAN (…)’.

    I therefore devised a trade counter that would make the code only execute a single trade.

    The entering into a trade seems to work, I now can’t get the closing of the trade to work, can anyone tell me what I am doing wrong?

    I am also trying to have the trade not attempt a close on saturday and sunday.

    maxorders=1
    daysForbiddenClose = DayOfWeek = 6 OR DayOfWeek = 7
    if intradaybarindex=0 then
    count = 0
    endif
    
    IF NOT LongOnMarket AND CurrentTime >= 104000 AND count<maxorders THEN
    BUY 1 CONTRACTS AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    If CurrentTime = 031500 AND not daysForbiddenClose THEN
    Sell at Market
    ENDIF
    
    //counting orders
    if onmarket and lastindex<>tradeindex then
    count=count+1
    lastindex=tradeindex
    endif
    
    
    #80807 quote
    Vonasi
    Moderator
    Master

    Welcome to the ProRealCode forums.

    I have moved your topic to the correct forum. You posted in a forum dedicated to PRT platform issues when your question was related to a ProOrder strategy. Please try to post in the correct forum with future topics.

    Also please use the ‘Insert PRT Code’ button when putting code in your posts as it makes it much easier for others to read. I have tidied up your post for you. 🙂

    #80808 quote
    Vonasi
    Moderator
    Master

    Regarding your question you will need to clarify what time frame you are working in.

    A candle with the time 031500 will only be present in certain time frames. For example there is no 031500 candle in the 1 hour time – only 030000 and 040000.

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

Close transaction at specific time


ProOrder: Automated Strategies & Backtesting

New Reply
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/18/2018
Status: Active
Attachments: No files
Logo Logo
Loading...