Wait 20 bars before taking next signal

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #104007 quote
    BC
    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
    robertogozzi
    Moderator
    Master

    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
    BC
    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.

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 BC
6 years, 7 months ago.

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