I'm trying to create an indicator that tracks the cumulative tick volume on the ask minus the cumulative tick volume on the bid (ie. a 100 share print on the ask or higher increases the indicator value by 100, a 100 share print on the bid or lower decreases the indicator value by 100). For some reason the following formula returns nothing. Could someone please help?
Thanks,
Rod
var bid = 0;
var ask = 0;
var tradeSize = 0;
var tradePrice = 0;
var upVol = 0;
var dnVol = 0;
var netVol = 0;
function preMain() {
setStudyTitle("Net Tick Volume");
setCursorLabelName("Net Tick Volume");
setDefaultBarFgColor(Color.blue, 0);
setShowCursorLabel(true);
setDefaultBarThickness( 2, 0 );
addBand( 0, PS_DOT, 3, Color.white);
}
function main() {
bid = getMostRecentBid();
ask = getMostRecentAsk();
tradePrice = getMostRecentTrade();
tradeSize = getMostRecentTradeSize();
time60 = getHour(0) * 60;
time60 += getMinute(0);
if((isTick() || isRawTick()) && time60>=570){
if(tradePrice<=bid)
dnVol += tradeSize;
else if(tradePrice>=ask)
upVol += tradeSize;
netVol = upVol - dnVol;
return netVol;
}
else return;
}
Thanks,
Rod
var bid = 0;
var ask = 0;
var tradeSize = 0;
var tradePrice = 0;
var upVol = 0;
var dnVol = 0;
var netVol = 0;
function preMain() {
setStudyTitle("Net Tick Volume");
setCursorLabelName("Net Tick Volume");
setDefaultBarFgColor(Color.blue, 0);
setShowCursorLabel(true);
setDefaultBarThickness( 2, 0 );
addBand( 0, PS_DOT, 3, Color.white);
}
function main() {
bid = getMostRecentBid();
ask = getMostRecentAsk();
tradePrice = getMostRecentTrade();
tradeSize = getMostRecentTradeSize();
time60 = getHour(0) * 60;
time60 += getMinute(0);
if((isTick() || isRawTick()) && time60>=570){
if(tradePrice<=bid)
dnVol += tradeSize;
else if(tradePrice>=ask)
upVol += tradeSize;
netVol = upVol - dnVol;
return netVol;
}
else return;
}
Comment