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?
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
if the effect the same, the first way is much simple than the second one, right?
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.
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
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]
JSParticipant
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…
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).
Hi Roberto,
Your picture tells more than 1000 words. Many thanks! 🙂
JSParticipant
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]
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…