Wait one candle

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #106798 quote
    umebonumebon
    Participant
    Average

    If my program exit a trade and I want it too wait for 1 or two candles (5min) before it take another position, how do I write that code?

    #106811 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    You have to:

    • set a flag to enable or disable trading, default=enable
    • set a counter, default=0
    • disable trading when you are OnMarket
    • start counting as soon as a trade exited (you are not OnMarket, but were OnMarket the previous bar)
    • reenable trading as the counter reaches the limit you require
    Once TradeON = 1     //1=enabled   0=disabled
    Once Counter = 0
    If OnMarket then
       TradeON = 0
       Counter = 0
    Endif
    If Counter >= 1 then
       Counter = Counter + 1
       If Counter >= 3 then   //reenable trading after 3 bars
          TradeON = 1
          Counter = 0
       Endif
    Endif
    If not OnMarket and OnMarket[1] then
       Counter = 1
       TradeON = 0
    Endif
    

    Add TRADEON to your conditions.

    Paul, Nicolas and umebon thanked this post
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

Wait one candle


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
umebon @umebon Participant
Summary

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

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