[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Same code prints prices in 32nds and decimals?



PureBytes Links

Trading Reference Links

Here is an ela file.  It contains a function called NumToDecFracStr.  The function will return a string of the number you input.  If the number is in decimals it will return the same number but for fractions it will return the string equivalent.  Example:

If Condition1 then Buy;
If Condition2 then Sell;

Commentary("The close for the bar is " + NumToFracStr(Close));
{Say this is for the bonds}
In the commentary window will appear  "The Close for this bar is 121-03"
{Say this is for the S&P}
In the commentary window will appear  "The Close for this bar is 1097.30"

Hope this is what you are looking for.  Oh there is a functiion that it calls that is called Decimals it is used to return the number of decimal places a number has. ie. 1097.30 will return 2 and so on.

Miles dunbar 

Function Name : NumToDecFracStr
________________________________
Inputs: Num(Numeric);

If FracPortion(PriceScale/10) <> 0 then begin
	Value1 = FracPortion(Num);
	
	NumToDecFracStr=NumToStr(IntPortion(Num),0)+"-"+NumToStr(Value1/(1/PriceScale),0);

end
Else NumToDecFracStr=NumToStr(Num,Decimals);

Function Name Decimals
________________________________
If PriceScale = 100 then Value1=2;
If PriceScale = 1000 then Value1=3;
If PriceScale = 10000 then Value1=4;
If PriceScale = 32 then Value1=4;
If PriceScale = 16 then Value1=4;
If PriceScale = 8 then Value1=3;

Decimals = Value1;

-----Original Message-----
From:	Mark Johnson [SMTP:janitor@xxxxxxxxxxxx]
Sent:	Wednesday, June 03, 1998 10:51 AM
To:	omega-list@xxxxxxxxxx
Subject:	Same code prints prices in 32nds and decimals?

I'd like to ask for help.  I want to run the same system
on several commodities, and print out prices occasionally.
For those commodities that trade in points and 32'nds of
a point (such as T-Bonds and 10-Year-Notes), I'd like
the printout to say

    PRICE: 100-21

which means 100 and 21/32nd's, i.e. 100.656250 in decimal


But for those commodities that trade in points and
100ths of a point (such as Cotton and Heating Oil), I'd
like the printout to say

    PRICE: 18.32

which means 18 and 32/100ths, i.e. 18.32000 in decimal.


I can see how to do this THE BRUTE FORCE UGLY UGLY WAY,
namely, look at the commodity ID number, and based on
that ID, branch to one of several individual print
statements, each laboriously written by me, with one
print statement for decimals, one for 32nds, one for
32nds and quarters of 32nds (like 2-Year-Notes), etc.

But, I ask, is there a better way?  An easier way?
Dare I say when talking about Easy Language, a more _elegant_
way?

Thank you very much,
  -Mark Johnson
--
   Mark Johnson     Silicon Valley, California     mark@xxxxxxxxxxxx

   "... The world will little note, nor long remember, what is said
    here today..."   -Abraham Lincoln, "The Gettysburg Address"

Attachment Converted: "c:\eudora\attach\FRAC.ELA"