Open and close trades strictly based on time

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #91288 quote
    ShitforbrainsShitforbrains
    Participant
    Average

    Hi,

    It’s shitforbrains here again, sorry for the noob question. I’ve looked around but have not found any code that would allow me to run a system that opens a long or short position strictly based on the time of day. For example “go long or short at 09:00 and close trade at 13:00 if neither limit or stop is hit”. It would also help a lot if I could define which weekdays the system is allowed to take trades.

    Any help?

    Regards,

    #91308 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go:

    TradeON = (DayOfWeek >= 0 AND DayOfWeek <= 5)
    IF time = 090000  AND TradeON AND Not OnMarket THEN
       BUY 1 CONTRACT AT MARKET
    ENDIF
    IF TIME = 130000 AND OnMarket THEN
       SELL AT MARKET
    ENDIF

    For Short trades just replace BUY with SELLSHORT and SELL with EXITSHORT.

    Shitforbrains and randelissimo thanked this post
    #91346 quote
    ShitforbrainsShitforbrains
    Participant
    Average

    Thanks a lot!

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Open and close trades strictly based on time


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/13/2019
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...