code for previous low

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #136835 quote
    Probbo63
    Participant
    New

    Hi

    Apologies as I’m sure this is a simple piece of code but I can’t seem to work it out.

    I would like to code for the previous low, but not over a particular number of bars. just however long that previous low is before current price. I’ll then use that to create a signal at 20$% above that. I’ve tried to use:

    LOWEST [n] (low) but I can’t work out how to allow the flexibility of the time parameter.

    Thank you for your help.

    #136838 quote
    robertogozzi
    Moderator
    Master

    n can be 254 bars maximum, be it on a 1-minute or a 1-week TF.

    #136904 quote
    Probbo63
    Participant
    New

    Hi

    Many thanks. I do understand that, but is there a way I can code for a previous low rather than set a ‘LOWEST’ point determined by a number of bars. Depending on how many bars you set, these 2 methods can give different results. The previous low could be only a few bars before the current bar or it could be 200 bars before, so I don’t want to restrict to a set number of bars. It sounds simple but I’m not sure how to do it.

     

    Many thanks

    #136909 quote
    robertogozzi
    Moderator
    Master

    Once you have used

    MyLow = LOWEST[254](low)

    to know what price that LOW is, you need an iteration (loop) to scan bars beackwards till you find the right one, which can be 4 or 253 bars away:

    MyLow = lowest[254](low)
    FOR i = 0 TO 253
       IF low[i] = MyLow THEN
          BREAK
       ENDIF
    NEXT

    at the end of the FOR…NEXT loop variable i (counter) will retain the index value of the bar retaining that low, can be 0 if it’s the current bar (LOW[0] or LOW) or any other value up to 253.

    #136913 quote
    Probbo63
    Participant
    New

    That’s great Roberto, many thanks for your time and help.

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

code for previous low


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
Probbo63 @probbo63 Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by Probbo63
5 years, 8 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 06/22/2020
Status: Active
Attachments: No files
Logo Logo
Loading...