Twitter Charts 2

Following on from this thread here are details for charts posted on our Twitter account. Comment in the Tweet and we’ll post the details here.

For example, to calculate the average drawdown for the members of an index, as per this Tweet:

This was calculated using the Drawdown Percent function DDP() in the custom Market Breadth module, with the Breadth Action set to Average.

By default, the DDP() function will calculate distance from the 1 year high.


Once calculated, the data can be viewed in the Breadth Data tool below the price chart:


Hii Sir,

It seems ismember is not working on this any reason.


Hi Deepak,

The ISMEMBER() function only works with true/false conditions, not when calculating averages.

Breakout scan:

//Define pivots;
//Get pivot values;
//When did the pivots occur?;
//Close crosses previous pivot level with a new high/low since the pivot; 
(CLOSE() CrossesAbove H2 and CLOSE() > HIGHESTHIGH(BARS=$TL1)) or 
(CLOSE() CrossesBelow L2 and CLOSE() < LOWESTLOW(BARS=$TL1))

Can you post the script for the slope of the linear regression.

If you type ‘linear’ in the script editor window then all suggestions will pop up, including LRSLOPE():


VIX curve chart:

Save workbook attached (requires access to the CBOE Indices data).

VIX-Indices-Curve.owb (45.3 KB)

Day of the Week formulas:

The DAYOFWEEK() function assigns a value to each week day, with Sundays assigned a 1, Mondays = 2, etc. As such, to mark all Fridays on a chart use DAYOFWEEK()==6 in a Show Bar. This will show all Fridays with a fall greater than 3%:

DAYOFWEEK()==6 and

5 Consecutive Down Weeks:

The Days Down DD() function counts the consecutive bars a value (the close by default) has been lower (Days Up DU() does the opposite).

On a weekly timeframe DD()==5 will signal when there have been 5 consecutive weekly lower closes, which was used in the signal test.

For 5 consecutive lower highs use DD(HIGH())==5

The Days Down tool can be used on a chart (currently 6 weeks for the SPX):



To calculate how long ago the close was at the latest low (or high) - and the dates they occured:

Worst Change Since:

//Display as Date in Watchlist;
//Get the last 1D ROC change %;
//Get the BarDate when the 1D ROC was less than D1;

Lowest Close Since:

//Display as Date in Watchlist;
//Get the last close price;
//Get the BarDate when the Close was less than D1;

Weeks Since Low

//Get the last close price;
//Get the time since the Close was less than D1;

To find the high dates instead, change the < to >. Sample weekly watchlist attached that can be saved as a layout and applied to any other lists.

WorstBest-Dates.owb (94.8 KB)

Hi Optuma team,

can you publish the script for the Twitter chart “ATH Drawdown” (

As always many thanks for your excellent support.

Best wishes,

Hi Thomas - use the Drawdown tool set to 100 year lookback (the all-time high calculation is wrong and is being fixed).

Hi Darren,

The story goes on. Can you publish the scripts for your two interesting Twitter charts here?

Many thanks for your great inspirations and support.

Best wishes,

Hi Thomas,

The pre-Covid high values were defined using the HIGHESTHIGH function between January 1st and March 13th 2020, and getting the percent difference from the latest close:

V1=HIGHESTHIGH(RANGE=Range, RANGESTART=2020-01-01, RANGEEND=2020-03-13);

The custom bar colours use this:

V1=HIGHESTHIGH(RANGE=Range, RANGESTART=2020-01-01, RANGEEND=2020-03-13);

To count the days since any value was that high (eg closing price, RIC, RSI, Volume, etc) change the D1 function here, as required:


Hi Darren,

you published a real cool chart on Twitter (

Would you please be so kind again to explain how you created this chart?

Am I right that I need the “Column Chart” feature in the Professional and Enterprise edition of Optuma to create your chart?

But anyway, please just explain how you created the chart with all the necessary scripts.

I use the following script in a watchlist to calculate the maximum drawdown:

Line2 = Line1 / 100 ; 

With this script I get the maximum drawdown for the SPX of -24.52%, in your chart you have for the maximum drawdown a value of -23.69%.
What is the reason for this difference?

Best wishes,

Hi Darren,

I have figured out how you have calculated the maximum intra-year drawdowns. You calculate the percentage difference between the closing price of the previous year and the lowest low of the next year.

OK so far so good, but this is not the “real” maximum intra-year drawdown. A better naming would be helpful e.g. maximum drawdown between the closing price of the previous year and the lowest low of the next year.

Best wishes,

Hi Thomas,

It has been created using a Show View below a yearly price chart, and the price chart ‘view’ hidden in the Structure Panel.

The Show View formula set to display as a histogram is simply CHANGE() for the columns (as the chart is a yearly timeframe it will calculate yearly change).

Max intra-year low is a Show Plot for the blue line:

//Current low;
V1 = LOW();
//Prev close;
V2 = CLOSE()[1];
//Percent calc;

This is different from the DDP() function which uses the 52 week high whereas this calculates from the close of the previous year.

A workbook for the SPX attached, which includes Show Bar formulas for the labels.

IntraYear-Lows.owb (19.2 KB)

1 Like

Hi Darren,

The story goes on and on. You have again published on Twitter a great chart about the % SPX stocks 20EMA > 50EMA.


Would it be possible to publish here the scripts using this analysis?

I know of course I need the Optuma Breadth Module to calculate the % SPX stocks, but I have it.

Many thanks and best wishes,

Hi Thomas,

This is the breadth calculation, set to Percent:

MA(BARS=20, CALC=Close, STYLE=Exponential) > MA(BARS=50, CALC=Close, STYLE=Exponential)

The Signal Test formula for when the breadth crosses above 33 after crossing 20:

R1=V1 CrossesAbove 33;
R2=V1 CrossesAbove 20;

Hi Darren,

This time making it short: "Can you publish here in the forum the scripts for the chart and backtest of your Twitter analysis about “$SPX losing 2% on a Monday following a 1% loss on a Friday”?

Twitter link:

As always really many thanks for your exceptional good support and ideas.

Best wishes,