Hi Everyone,
I am trying to build an indicator that should plot the average volume per up tick in a given bar (5 min chart). Given that ticks and volunes are defined in the "volume based on", I have two datas:
Data1 - volume based on ticks
Data2 - volume based on trade volume
I can compile the code below without any error, but when I insert the indicator on the chart, I get an error message. Is there any point I am missing? Tks
variables: var1(0),var2(0),var3(0);
var1 = UpTicks of data1;
var2 = UpTicks of data2;
var3 = var2/var1;
plot1(var1,"1");
plot2(var2,"2");
plot3(var3,"3");
Indicator - Trade Volume / Ticks using DataN
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
what is your error message?
a screen shot would help.
a screen shot would help.
Last edited by TJ on 25 Aug 2008, edited 1 time in total.
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
-
- Posts: 407
- Joined: 01 Jan 2008
- Been thanked: 3 times
replace var3 with something like this:
if var1 <> 0 then var3 = var2/var1 else var3 = var2/var1[1];
it won't be 100% accurate when var1 = 0 but it might be close enough.
You could also use the prev value of val3 when var1 = 0;
Whenever doing a division, make sure the denominator can't be zero.
A tip from a programmer friend of mine- When working with multiple data streams, set the variable to zero of the data stream being referenced - example.
var2(0,data2);
if var1 <> 0 then var3 = var2/var1 else var3 = var2/var1[1];
it won't be 100% accurate when var1 = 0 but it might be close enough.
You could also use the prev value of val3 when var1 = 0;
Whenever doing a division, make sure the denominator can't be zero.
A tip from a programmer friend of mine- When working with multiple data streams, set the variable to zero of the data stream being referenced - example.
var2(0,data2);