Error with Lowest[n] / Highest[n]

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #182745 quote
    albertox
    Participant
    New

    Hi all,

     

    I am trying to define a condition referring to the Historic Low of a value (taking into account the limitation of 1024 candles). Lowest[1023](Low).

    The problem arises whith stocks that have traded fewer candles than those indicated in the Lowest command (i.e. IPO occured less than 1023 candles ago). Whith such stocks, ProScreener will directly ignore them ​​from the result, even if all conditions are correct. Note: This problem occurs in Lowest, Highest and other commands that involve earlier candles.

     

    I have simplified a code below for the sake of the example.

    c1 = Close > 1.5
    c2 = Close < 1.55
    
    HistoricLow = Lowest[160](Low)
    
    c3 = HistoricLow > 0
    
    Screener [c1 and c2 and c3] 
    

    The first two conditions are intended to narrow down the list and only show a specific stock (LDA – Linea Directa) that has been trading in the Spanish market only for a few sessions. This ProScreener should only apply to Stocks in Spain for simplicity, but feel free to do you own testings.

    Then third condition states that the lowest traded value during the last 160 candles must be greater than 0 (obviously the condition will be correct). But because LDA to date has only traded 156 sessions, despite the fact that the 3 conditions are correct, it will not appear in the ProScreener result. If you introuce Lowest[100](Low) however, it will work fine.

    Do you know if  there is a way to fix this error, maybe with a different code?

    I thought about something like: MIN (sessions traded, 1023) but I have not been able to find a way to identify the number of sessions traded to date.

    Thanks.

    #182768 quote
    robertogozzi
    Moderator
    Master

    Try this one:

    c1 = Close > 1.5
    c2 = Close < 1.55
    HistoricLow = low
    For i = 1 TO 160       //or 1023 with PRT Premium
       HistoricLow = min(HistoricLow,low[i])
    Next
    c3 = HistoricLow > 0   //c3 will always be true
    Screener [c1 and c2 and c3]
    albertox thanked this post
    #182772 quote
    albertox
    Participant
    New

    Grand master Roberto!

     

    Fantastic solution.

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

Error with Lowest[n] / Highest[n]


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
albertox @albertox Participant
Summary

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

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 12/02/2021
Status: Active
Attachments: No files
Logo Logo
Loading...