Counting how long it takes for something to go up n-%?

What is the correct way to script in Optuma a Show View of how long it takes for something (say GBTC for the sake of discussion) to go up by n-%?

I believe I have seen Show View panels that depict a time series graph for this, but its not clear to me how to track each respective high that restarts the count.

For instance, GBTC has risen by 50% several times, and am trying to chart the length of time GBTC goes up 50% from the last time it went up 50% for each successive time.

Thanks as always,

Eric

Hi Eric,

We may be able to do something but how are you measuring the 50% moves? Is it from a 12 month low, or a 21 day rate of change? If you can provide a graphical example we’ll see what we can do.

Thank you Darren. Here would be a more specific example using the VIX. The general concept is the same where a 100% move or 150% move was used to track the bars between those points.

The trick is to track the low point {after the previous high mark) and then count from that point forward. I do hope this does help clarify.

Thank you kindly,

Eric

OK thanks. I can’t think of an easy way to do that (unless you know how they define the start / low - I can’t see the text in the image clearly). All I can think of is something like a 50% change in the VIX over X days, but that doesn’t reset as often. This is a 3 day change:

TIMESINCESIGNAL(ROC(BARS=3)>50)

Thanks Darren. I will follow-up with this, as well as the other project I am working on.

Darren,

Coming back to this (as my other project is quite complex and taking longer than I would like to draft). What if the VIX low was defined as a 7-bar swing low?

The TimeSince signal would then be a 50% rise from that point, and would reset every time a > than 50% rise in VIX occurred off a new swing low.

I tried scripting based off your example, but did not know how to isolate just the low point when using the GannSwing function.

Hopefully that is more clear.

Thank you sir.

Thanks Eric.

When dealing with swings it gets complicated because of the time it can take a swing turn to be confirmed. However, this will highlight the 1st 50% move after the swing low:

//Set Swing parameters;
S1=GANNSWING(SWINGCOUNT=7, USEINSIDE=True, METHOD=Use Next Bar);
V2=SWINGSTART(S1);
//Calc % from SwingStart;
V3=DIFFPCT(HIGH(), V2) CrossesAbove 50;
//Show 1st signal after new low;
SIGNALAFTER(S1 TurnsDown, V3)

Let me know what you think, and if it looks ok I can work on the time counts as part of a scripting consultation.

Darren,

If the VIX was greater than 30 how could I use the TimeSinceSignal function to determine how many days it takes to get to 20? I have tried various configurations and keep getting 0 or 1.0 values.

Hi Eric,

I think you need to use a SWITCH() function to turn on when crossing above 30 but only after crossing below 20 (and vice versa), as otherwise you would get every cross above 30.

This will count the trading days it takes for the VIX low to reach 20 after the high has hit 30:

d1 = GETDATA(CODE=VIX:CBOEI);
//use the intraday high / lows;
b1 = LOW(d1) CrossesBelow 20;
b2 = HIGH(d1) CrossesAbove 30;
//Set switch conditions;
V3 = switch(b1,b2) ChangeTo 0;
V4 = switch(b1,b2) ChangeTo 1;
//Get BarIndex values to calculate trading days;
V5 = VALUEWHEN(BARINDEX(),V4) - VALUEWHEN(BARINDEX(),V3);
If(V4, V5)

So it only took 5 trading days last week - the shortest time since December 2021. Workbook attached.

VIX - 30 20.owb (24.7 KB)

Thank you very much. These are not obvious to figure out without your support.

1 Like