Intraday Volume Profile with Dynamic Start

B

billgt

New member
VIP
I am wondering if anyone has seen a volume profile study for TOS that plots intraday volume profiles but with a start based on something like a breakout of the previous range or X % price move. The built in volume profile can be used to do this on a fixed time basis but I think that is too rigid. I want something that will look to see if the price has moved out of the range of the current intraday volume profile and then start a new volume profile using the next X bars as the data. There is an indicator out there not available for TOS called TAS Boxes that looks like it will do something like this. I would be happy to pay for it but it isn't available on TOS. I have already searched UseThinkScript and didn't see anything. I am going to attempt to code this by modifying the built in volume profile but don't want to waste my time if anyone knows of something already done or that is close.

Thanks!

Bill
 
B

billgt

New member
VIP
Thanks. I started looking at the code and very quickly ran into a roadblock. Here is the section of the code I am struggling with if anyone can assist.

Code:
def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % multiplier else count[1], 0);
def cond = count < count[1] + period - period[1];
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
    height = PricePerRow.AUTOMATIC;
case TICKSIZE:
    height = PricePerRow.TICKSIZE;
case CUSTOM:
    height = customRowHeight;
}

profile vol = volumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = compoundValue(1, onExpansion, no);
def pc = if IsNaN(vol.getPointOfControl()) and con then pc[1] else vol.getPointOfControl();
def hVA = if IsNaN(vol.getHighestValueArea()) and con then hVA[1] else vol.getHighestValueArea();
def lVA = if IsNaN(vol.getLowestValueArea()) and con then lVA[1] else vol.getLowestValueArea();

The start of a new profile is based on the "cond" variable. The "cond" variable in the original code is based on a new period being found such as a new minute, hour, day, etc. But my condition needs to be based on the price being higher than the current volume profile hVA which of course doesn't exist yet because we don't create the profile until after the "cond" variable is created. In some other language I would do something like the following.

def cond;
def hVA = 0;
if hVA = 0 then
cond = true;
else
if close > hVA then
cond = true;
else
cond = false;

profile vol = volumeProfile("startNewProfile" = cond, ...... etc.
hVA = if IsNaN(vol.getHighestValueArea()) and con then hVA[1] else vol.getHighestValueArea();

But in TOS there is no concept that I know of to initialize a variable in one place and then assign it again in another lower in the code. It always throws a compiler error saying that "var X has already been assigend". You can do this in Tradingview but I just don't know a way around it in TOS. Any suggestions to get around this?

Thanks!

Bill
 

Similar threads

Top