Trading hours

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #120205 quote
    marcuscn
    Participant
    Junior

    Hi!

    I would like to code my system for a specific time. I want my system to only trade between 09300 – 2200 so for that  i use:

    DEFPARAM FLATBEFORE = 093000
    DEFPARAM FLATAFTER = 220000

    But i also want it to pause between 1400-1600 in the middle of the day and close positions if i have any open. How do i code this?

    Thanks

    #120208 quote
    TempusFugit
    Participant
    Veteran

    With this code the open positions will close at those hours

    NOTRADE = TIME>=140000 AND TIME<=160000
    
    IF ONMARKET AND NOTRADE THEN
    SELL AT MARKET
    EXITSHORT AT MARKET
    ENDIF

    And for not starting any trade at those hours you need to add “AND NOT NOTRADE” at the conditions of your entries

    marcuscn thanked this post
    #120212 quote
    robertogozzi
    Moderator
    Master
    IF OnMarket THEN
       IF Time >= 220000 OR (Time >= 140000 AND Time <= 160000) THEN //close open positions
          SELL      AT MARKET
          EXITSHORT AT MARKET
       ENDIF
    ENDIF
    TradeON = (time >= 093000 AND Time <= 220000) AND (Time < 140000 AND Time > 160000) //Only trade outside these time ranges
    IF MyConditions AND Not OnMarket AND TradeON THEN
       BUY/SELLSHORT 1 CONTRACT AT MARKET
    ENDIF

    (not tested)

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

Trading hours


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
marcuscn @marcuscn Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by robertogozzi
5 years, 11 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/22/2020
Status: Active
Attachments: No files
Logo Logo
Loading...