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

Re: real time upating of position P/L



PureBytes Links

Trading Reference Links

> Is there a slick way get TS4 to display position profit for trades
> that are not from a system? 

You could do something like this.  (Not tested, but should be close)

BTW, you don't need to pass in PtVal.  You can use BigPointValue, 
unless you don't want to use the pointval of the thing you're 
charting.

Gary


Inputs: EntryPr(0), NumContr(0), PtVal(250);
Vars: Profits(0);
Vars: TxtObj(0), Hi(0), Lo(0);

{ Create & initialize text object }

if CurrentBar = 1 then begin
  TxtObj = Text_New(Date,Time,Close,"XXX");
  Text_SetStyle(TxtObj,1,2);  {Left, Centered}
  Text_SetColor(TxtObj,Tool_Yellow);
  end;

{ When on last bar, plot the profit.  Try to find a location
  where the text won't overwrite the price chart. }

if LastBarOnChart then begin
  Profits = (Close - EntryPr)*NumContr*PtVal;
  Text_SetString(TxtObj, "Profit = " + NumToStr(Profits, 2));
  Hi = Highest(H,200);
  Lo = Lowest(L,200);
  if (C-Lo)/(Hi-Lo) > 0.5 
    then Text_SetLocation(TxtObj, Date, Time, Lowest(L,200))
    else Text_SetLocation(TxtObj, Date, Time, Highest(H,200));
  end;

if False then plot1(0,"");