Wait 20 bars before taking next signal

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #104007 quote
    BCBC
    Participant
    Master

    Hi PRT Master

    I stuck on below last command, anyone can help?

    ”if last trade was a loser, wait 20 bars before taking the next signal.”

    For first part, use POSITIONPERF(n) command can solve, but how about the last?

    #104008 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Use a flag, say TradeOn, to enter a trade and set it to 1 by default.

    When you suffer a loss clear TradeOn and save your bar ID, then when 20 bars have elapsed reset it to 1 to reenable trading.

    ONCE TradeOn = 1
    ONCE BarID   = 0
    IF STRATEGYPROFIT < STRATEGYPROFIT[1] THEN
       TradeOn = 0
       BarID   = BarIndex
    ENDIF
    IF BarID > 0 AND (Barindex - BarID) > 20 THEN
       BardID  = 0
       TradeOn = 1
    ENDIF
    IF YourConditions AND TradeOn THEN
       BUY/SELSHORT....
    ENDIF
    BC thanked this post
    #104049 quote
    BCBC
    Participant
    Master

    It work! Thanks Robertogozzi.

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

Wait 20 bars before taking next signal


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
BC @robin_chan Participant
Summary

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

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