Limiting trades after close of previous trade

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #153905 quote
    IRPIRP
    Participant
    New

    In automated trading, is it possible to instruct the PRT system not to enter a trade after a certain time has elapsed counting from the time the last trade was closed?

    Also, is there any link to help in setting up a trailing stop?

    Many thanks,

    I. Petrie

    #153906 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    You can search the forum for TRAILING STOP and you’ll be returned many links to code and posts. Nicolas’code is at https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/ (lines 17-56 are ready to be added to your code as is).

    This code will allow you to stop trading for MaxBars bars (not tested):

    ONCE TradeON = 1
    ONCE Count   = 0
    ONCE MaxBars = 20           //Number of bars to wait before trading again
    IF Count > 0 THEN
       Count = Count + 1
       IF Count >= MaxBars THEN
          Count   = 0
          TradeON = 1
       ENDIF
    ENDIF
    IF StrategyProfit <> StrategyProfit[1] THEN
       Count   = 1
       TradeON = 0
    ENDIF
    IF LongConditions AND TradeON THEN
       BUY 1 Contract AT Market
    ENDIF

    TradeON must be added to your conditions to enter a trade.

Viewing 2 posts - 1 through 2 (of 2 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

Limiting trades after close of previous trade


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
IRP @irp Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzirobertogozzi
5 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/16/2020
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...