PureBytes Links
Trading Reference Links
|
I've written a simple piece of code to just copy out to a disk file the
P&L of a trade whenever a trade is closed out. It appears there is a
bug somewhere--or perhaps I'm not doing something quite right. Executed
on the bar immediately following a position being closed out, It should
write out simply the symbolname and the P&L of that last
trade...Instead, I get many duplicate lines, though not apparently any
particular number of duplicates.
Here is the code, which I paste into the bottom my strategy--any
strategy, take one of the canned ones from TradeStation:
=====
vars: MP(0), plstring("");
MP = MarketPosition;
if MP = 0 and MP[1] <> 0 then begin
plstring = GetSymbolName + ", " + PositonProfit(1) + NewLine;
FileAppend("c:\mytrades.txt", plstring);
end;
=====
Here is what I tend to get in the output file:
IBM, -280.00
IBM, -280.00
IBM, -280.00
IBM, -280.00
IBM, -280.00
IBM, -280.00
IBM, -280.00
IBM, -224.00
IBM, -224.00
IBM, -224.00
IBM, 880.00
IBM, 880.00
IBM, 880.00
IBM, 880.00
IBM, 880.00
IBM, 880.00
IBM, 880.00
IBM, 880.00
IBM, 880.00
IBM, 880.00
IBM, 880.00
IBM, 880.00
IBM, 880.00
Anyone else had this problem? Am I doing something wrong?
THANKS!
|