I was suggesting you calc the len of the fractional part of the price to determine the number of digits past the decimal point.
Announcement
Collapse
No announcement yet.
formatPriceNumber()
Collapse
This topic is closed.
X
X
-
e.g. price of 32
I thought of that too, however if you use the suggestion I made you will have to keep track of the max number returned, that way if the security trades at 32, then 32.1 then 32.34 then only trades with a max of 2 decimals, you would quickly realize the number of decimals was 2.
Comment
-
I think the thing to do is to wait till someone from esignal can chime in. These calculations are done at initialization so I only get 1 price. In the end formatPriceNumber should be working and consistently, perhaps there is something wrong with the install that isn't working. Wel''l see what they say.
Comment
-
Hello Bernie,
I've been testing the following code and haven't been able to reproduce a zero length string for fp.
PHP Code:
function preMain() {
setPriceStudy(true);
setStudyTitle("test");
}
function main() {
var nState = getBarState();
var sym = getSymbol();
if (nState == BARSTATE_ALLBARS) {
debugClear();
var p = close();
var fp = formatPriceNumber(p);
var intp = p.toFixed(0);
var dec = fp.length - intp.length; // calculates number of dec pts in sym
if (fp.indexOf(".") >= 0) dec -= 1;
debugPrintln("dec: " + dec);
debugPrintln("intp: " + intp + " fp: " + fp + " p: " + p);
}
return;
}
Try something like if (isNaN(p) || p <= 0 || p == null) return;Jason K.
Project Manager
eSignal - an Interactive Data company
EFS KnowledgeBase
JavaScript for EFS Video Series
EFS Beginner Tutorial Series
EFS Glossary
Custom EFS Development Policy
New User Orientation
Comment
-
Jason, I have an idea of what may be happening and it's a guess on how charting works. The other system (which doesn't work) is earl's who doesn't have interday stock but gets daily data for stocks (remember this works on my system ok). I suspect that formatPriceNumber uses a 'dictionary' that has data on how to format the symbol and that because he doesn't have intraday data, that dictionary is not loaded and therefore formatPriceNumber doesn't know how to format and then returns null. If that's the case then that dictionary should still be loaded
Bernie
Comment
-
Hello Bernie,
So Earl is running this on Daily intervals only? I think you're on to something. I'll find out if this is supposed to work with EOD subscriptions.Jason K.
Project Manager
eSignal - an Interactive Data company
EFS KnowledgeBase
JavaScript for EFS Video Series
EFS Beginner Tutorial Series
EFS Glossary
Custom EFS Development Policy
New User Orientation
Comment
-
Hello Bernie,
Your suspicion was pretty close. According to our development team, the formatPriceNumber() function does use some information sent with a quote record that may not be available in EOD versions. They are looking into it.Jason K.
Project Manager
eSignal - an Interactive Data company
EFS KnowledgeBase
JavaScript for EFS Video Series
EFS Beginner Tutorial Series
EFS Glossary
Custom EFS Development Policy
New User Orientation
Comment
Comment