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

Re: TS calculation problem



PureBytes Links

Trading Reference Links

At 11:14 AM 3/2/2005, Scorpio  Massimiliano wrote:

>value1=118.27*118.23;
>
>Plot1(value1,"prova");
>
>Print(date," ",time," ",value1:0:5);


At 11:31 AM 3/2/2005, Bob Fulks wrote:

>At 11:14 AM 3/2/2005, Scorpio  Massimiliano wrote:
>
>>I wonder if someone else faced this problem or have a solution.
>
>Yes. You are correct. That is what happens.
>
>You can separate the integer and fractional parts and print them separately or combine them into a text string and print the text string.
>
>Bob Fulks


Correction. The printing problem does not exist in TradeStation 8 because it now has higher precision arithmetic. (Another reason to upgrade...)

I did test code to separately convert the integer and fractional parts of the number, This should allow you to print the value with higher precision on TS2000i. 

Bob Fulks

-----------------


Vars: Str("");
Value1 = 1118.274 * 2118.231;

Value2 = IntPortion(Value1);
Value3 = FracPortion(Value1);


Str = NumToStr(Value2, 0) + "." + RightStr(NumToStr(Value3, 10), 10);

if LastBarOnChart then 
   Print(date:7:0," ",time:5:0," ",value1:15:10, "  ", value2:15:10, 
      "  ", value3:15:10, "  ", Str);


This code printed as follows on TS8:

1050303   655 2368762.6532939998  2368762.0000000000     0.6532939998  2368762.6532939998