Strange Syntax when using DONCH()

Could someone please explain the following.

I wrote the following script some time back and I suspect was given help by the Optuma team. Unfortunately, I cannot remember the details of how the syntax works.

VAR1 = WEEK(DONCH());
VAR2 = WEEK();
VAR2[1] CrossesAbove VAR1[1]

This script is used in a weekly Time Frame.

I would like to know if the script is correct in regards to the use of the square brackets and also the use of ‘WEEK’ which precedes DONCH() in VAR1.

Removal of either ‘WEEK’ or the square brackets alters the way the script works (it makes it worse).

I would like to know what is happening. Use of Show Bars shows only a slight difference. All versions of script are stable when viewed as Show Bars and using Training Mode bar by bar.

Incidentally I am aware that the use of WEEK() in VAR2 denotes the closing price of a WEEK.

Any help would be greatly appreciated.

Cheers, Lester

Hi,

VAR1 is finding a Weekly value for the Donchian Channel.
VAR2 is finding the Weekly Close value.

The 3rd line is looking for instances where the previous weekly close crosses above the previous weeks Donchian Channel.

When time frame overrides like WEEK() are being used, it is usually because the script is being applied to a chart with a different time frame (like Daily).

Hi Matthew,
Thank you for your explanation.

Could you also please explain the difference between “VAR2” verses “VAR2[1]”?

Cheers, Lester

Hi,

VAR2 references the current value, where as VAR2[1] is the previous value. The [1] is an offset.

https://help.optuma.com/kb/faq.php?id=1070

Hi Matthew,
Thank you.
Cheers, Lester