Checking if a Condition has occurred within N Periods

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #154359 quote
    CapnCrunch77
    Participant
    Junior

    Hello All,

    I’m trying to write a programme line entry whereby I want to execute a trade if a condition has been fulfilled with the last N periods (for example; if a cross of price over 100 MA line has occurred within X number of time frames).  Anyone able to provide guidane on how this condition can be expressed?

    Thanks!

    #154363 quote
    robertogozzi
    Moderator
    Master

    There you go:

    x = summation[10](condition)
    If x Then
     .
     .
    Endif
    CapnCrunch77 thanked this post
    #154371 quote
    CapnCrunch77
    Participant
    Junior

    Awesome, thanks Roberto!!!

    Follow up question, do you know how I could make this work with TIMEFRAME?  say for instance, I want to check this in a 10min chart and my default where I am running the programme is 5 min (i.e. I want the programme to trade only if condition X has een validated in 10min timeframe).

    #154374 quote
    robertogozzi
    Moderator
    Master

    You can use it as many times as needed, provided you name variabls differently among TF’s:

    Timeframe(10 minute,UpdateOnClose)
    x10 = summation[10](10-minute-condition)
    If x10 Then
     .
     .
    Endif
    Timeframe(default)
    xD = summation[10](default-TF-condition)
    If xD Then                               //or If xD AND x10 Then
     .
     .
    Endif
    Kovit thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Checking if a Condition has occurred within N Periods


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by robertogozzi
5 years, 2 months ago.

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