Detecting a RANGE

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #10324 quote
    robertogozzi
    Moderator
    Master

    I am trying to figure out how to write a piece of code to detect whether the last, say, 50 bars were in a range of less than 20 pips. In this case I would not enter any trade even if conditions are met.

    I wrote:

    IF range[50] < 20 THEN

    ……

    ENDIF

    But it seems not to work.

    Can anyone help me?  Thank you.

    #10338 quote
    Nicolas
    Keymaster
    Master

    What you need here is to determine the highest high and the lowest low of the last 50 bars, then test if their  difference is more or less 20 pips.

    hh = highest[50](high)
    ll = lowest[50](low)
    
    test = (hh-ll)<20*pipsize
    #10348 quote
    robertogozzi
    Moderator
    Master

    Thank you very much Nicolas, that’s exactly what I wanted.

    So what does RANGE[50] do?

    Thanks.

    #10365 quote
    Nicolas
    Keymaster
    Master

    Range returns the range of the selected bar only.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Detecting a RANGE


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

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

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