How to find the MAX valure of the last 10 to last 5 days?

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #253944 quote
    thomas2004ch
    Participant
    Average

    I can calculate the Amplitude between the highest and the lowest in the last 10 days as follow:

    MyHighest = highest[10]
    MyLowest = lowest[10]
    
    Ampli = MyHighest - MyLowest
    
    

    But if I want to calculate the Amplitude between the highest and the lowest between the last 20 and last 10 days. How to do?

    #253946 quote
    Iván González
    Moderator
    Master

    there are 2 ways:

     

    MyHighest = highest[10](high)[10]
    MyLowest = lowest[10](low)[10]
    
    Ampli = MyHighest - MyLowest
    
    myHi=0
    myLo=9999999
    for i=10 to 19 do
       if high[i]>myHi then
          myHi=high[i]
          myHix=barindex[i]
       endif
       if low[i]<myLo then
          myLo=low[i]
          myLox=barindex[i]
       endif
    next
    amp=myHi-myLo
    
    print amp as "Loop"
    print Ampli
    return
    
    robertogozzi thanked this post
    #253948 quote
    thomas2004ch
    Participant
    Average

    if the effect the same, the first way is much simple than the second one, right?

    #253951 quote
    Iván González
    Moderator
    Master

    Yes! first option

    #254520 quote
    thomas2004ch
    Participant
    Average

    Hi Ivan,

    To your code “MyHighest = highest[10](high)[10]”, what does the first 10 mean and what the second 10?  I can’t find this syntakt in the manual. 

    #254524 quote
    robertogozzi
    Moderator
    Master

    The 10 on the far left means that the search is for the highest price of the last 10 periods.
    The 10 on the far right means you want to retrieve what the scan reported 10 bars ago.

    MyHighest = highest[10](high)[10]

    It is equivalent to writing:

    MyHighest1 = highest[10](high)
    MyHighest2 = MyHighest1[10]

    I would like to point out that your line is NOT scanning for the highest price, but for the highest CLOSE, since you didn’t specify what to scan and so it defaults to CLOSE:

    MyHighest = highest[10](high) //MyHighest = highest[10] verwendet standardmäßig CLOSE
    Iván González thanked this post
    #254532 quote
    thomas2004ch
    Participant
    Average

    Thanks!

    In order to better understand what you said, here an example: Today is 13.12.2025. If I want to find the highst high between 01.12.25 and 05.12.2025, I have to do as follow?

    MyHighest = highest[5](high)[8]

    #254539 quote
    JS
    Participant
    Senior

    Hi,

    You are using the instruction syntax correctly; however, you need to take into account that the instruction works with bars rather than dates…

    The number of bars does not correspond one-to-one with calendar days due to holidays and weekends…

    A bar represents a trading day, and on holidays and weekends the market is closed…

    Iván González thanked this post
    #254549 quote
    thomas2004ch
    Participant
    Average

    Hi JS,

    Many thanks!

    JS thanked this post
    #254550 quote
    robertogozzi
    Moderator
    Master

    Thanks!

    In order to better understand what you said, here an example: Today is 13.12.2025. If I want to find the highst high between 01.12.25 and 05.12.2025, I have to do as follow?

    MyHighest = highest[5](high)[8]

    Your line retrieves the highest price in a 5-day range, starting from the 8th bar prior to the current day (see attached pic).

    Iván González thanked this post
    x-3.jpg x-3.jpg
    #254552 quote
    thomas2004ch
    Participant
    Average

    Hi Roberto,

    Your picture tells more than 1000 words. Many thanks! 🙂

    robertogozzi thanked this post
    #254553 quote
    JS
    Participant
    Senior

    Hi Roberto,

    I think the picture is not correct because December 6 and 7 fall on a weekend, so no bars are created on those days…

    Based on the actual trading bars…

    MyHighest = Highest[5](High)[6]

    #254554 quote
    robertogozzi
    Moderator
    Master

    That’s just an example not related to real data, as it’s a bit complicated to scan backwards for actual trading days before executing HIGHEST, etc…

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

How to find the MAX valure of the last 10 to last 5 days?


ProScreener: Market Scanners & Detection

New Reply
Author
Summary

This topic contains 12 replies,
has 4 voices, and was last updated by robertogozzi
2 months, 2 weeks ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 11/25/2025
Status: Active
Attachments: 1 files
Logo Logo
Loading...