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

Calculation Problem



PureBytes Links

Trading Reference Links

I use the following code to plot a continuously updated P&L on my S&P chart.
However, when I use the same code on Bonds it does not calculate properly
because of the fractions.  Any suggestions will be appreciated.  Thanks.

Inputs: EntryPr(Close), PtVal(31.25), NumContr(1), Comm(21.58);
Vars: Profits(0);

Profits = (Close - EntryPr)*NumContr*PtVal-NumContr*Comm;
Plot1(Profits, "Profit/Loss");
Plot2(0, "Breakeven");

If BarNumber = 1 then
 value1 = Text_New(date, time, Close,NumToStr(profits,0))
else begin
 value2 = Text_SetLocation(value1, Date, Time+22,Close);
 value2 = Text_SetString(value1,NumToStr(profits,0));
 If Profits > 0 then value2 = Text_SetColor(Value1,DarkGreen)
 else value2 = Text_SetColor(Value1,Red);

end;

Thanks.
Bill