TIMESINCESIGNAL problem using Volume

Hi Optuma group,

I am having problem with incorrect results in varying degrees when using Volume() in TIMESINCESIGNAL(), I will try to explain it as simply as I can.

I am trying to achieve a “one or high output” when volume has been > say 15000000 within the last 2 days.

The code I am using is as below -

vol1=VOLUME();
tss5=TIMESINCESIGNAL(vol1 > 9000000) <= 2;
tss5

For AFI.au the above code shows correctly, if I change 9000000 to 15000000 the indicator displays incorrectly as per attached screen shots.

BKH.us shows incorrectly with both numbers ie - it shows a “one or high output” when it should be a “low”, even though the volume is mostly quite low - < 1000000.

What do I need to change to make this code work correctly?

Thanks for your help,

Cheers, Brad

Hi Brad,

I think you need to change the volume numbers as neither AFI or BKH have had volume above 15,000,000.

If you use this is will count how long it has been since > 500,000, ie 30 days for BKH. The Show Bar highlists within 2 days:

vol1=VOLUME();
tss5=TIMESINCESIGNAL(vol1 > 500000) ;
tss5

Capture

Hi Darren,

Thank you for your reply and I apologise for my late reply.

You wrote “I think you need to change the volume numbers as neither AFI or BKH have had volume above 15,000,000.”, this is precisely my point, with AFI.au for instance if I use vol1 > 500,000 my above supplied code shows correctly ie zero’s & one’s (blacks & greens), if I use vol1 > 997,000 the code shows mostly zero with a couple of one’s, and if I use vol1 > 15,000,000 the code shows all one or high (green) output when it should be all low or (black).
AFI.au doesn’t have volume of 15,000,000 on any day in its history, yet my above supplied code of -

vol1=VOLUME();
tss5=TIMESINCESIGNAL(vol1 > 15000000) <= 2;
tss5

  • shows an output indicating AFI.au has volume of greater than 15,000,000 every day when the maximum days volume is maximum days volume = 997,359 as per the attached screenshot.

What do I need to change to make this code show correctly?

Thanks for your help,

Brad

Hi Brad,

Your script is counting how many days volume has been above 15,000,000 and return a true result if it is <= 2. As AFL has had 0 days above 15,000,000 your formula returns a true result (0 <= 2).

Does this do what you need?

vol1=VOLUME();
tss5=TIMESINCESIGNAL(vol1 > 15000000);
tss5 > 0 and tss5 <=2

Hi Darren,

Thank you again for your helpful reply.

Your suggested code was very helpful, but the resulting true was delayed by 1 day, so I added [-1] to the end of tss5=TIMESINCESIGNAL(vol1 > 15000000)[-1]; which seemed to help with that.

But your suggested code with my mod doesn’t always produce a true result at the correct time, particularly it seems with much higher volume than 15,000,000.
WHC.au and TSLA are 2 recent examples of that.
WHC.au shows some > 15m volume days true result but not others, ie 3/3/2022.
TSLA’s daily volume is much higher than 15m but shows no recent true result at all.

Just to recap what I wanted the code to achieve was -
If daily volume has been greater than 15,000,000 within the last 2 days, show a true output.

Is there a better way to achieve this?

Brad

Ah OK now I understand… TIMESINCESIGNAL is a running count since a condition was last true, so if the condition is currently true (ie TSLA’s volume > 15,000,000) then you will get a value of 0.

As you are only looking for 2 bars this is perhaps an easier way to do it, with Vol1 being the current bar and Vol1[1] the previous:

Vol1=VOLUME();
(Vol1 > 15000000) or (Vol1[1] > 15000000)

Hi Darren,

I have only been “using within the last 2 bars” because it makes it easier to see of the code is working correctly.

Once I have a verified a correctly working script to achieve the above, I will use a longer time period, maybe 10-30 bars, which I will fine tune using visual checks and Backtesting.

I have used TIMESINCESIGNAL() many times, but haven’t experienced this amount of difficulty in making it work correctly.

Is there something unique about VOLUME() that has caused this?.

I am looking for this script to give a “true” output with likely a longer count than 2 bars from when a VOLUME() condition ie > 15M last occurred, probably 10-30 bars.

Thanks again for your help,

Brad

Hi Brad,

The TimeSinceSignal should work the same for all functions, so it’s a question of knowing what the function is doing and getting the logic right.

If you put TIMESINCESIGNAL(VOLUME()>15000000) in a Show View it will show the running total of the days since it last happened, as per this example for WHC:

The green bars show when it has been more than 20 days since a 15mill day (red arrows) ie a 20 day gap between red arrows:

Capture

As an aside, using a ‘higher than average volume’ signal rather then a discrete value would work better when comparing stocks, eg when volume is twice the 22 day average:

VOLUME()>(MA(VOLUME(), BARS=22)*2)

Thanks for your help again Darren, I will revisit it again next week, there must be a solution, just a matter of finding it.

Brad