PureBytes Links
Trading Reference Links
|
Here's a handy little indicator to "mark" your trades on a chart. It
draws a line from the trade entry to the trade exit, so you can
easily see whether it was a win or loss. (You can get fooled if you
look at the positions of the buy/sell arrows on the chart.) By
default it draws winning trades in green, losing trades in red, but
you can change that.
It would be easy to modify the indicator to e.g. show longs in green
and shorts in red, but I liked this style. I tried to change the
style of the lines to show losses with dotted/dashed lines, but
TL_SetStyle didn't seem to work. Any guesses why? I used
if PosProfit < 0 then TL_SetStyle(Line, <all values>);
Gary
{ Indicator: Trade Marker
Displays lines from trade-open to trade-close.
Move the indicator to the "Hidden" subgraph to save screen space.
Note: since TS doesn't provide much position information to
indicators, I had to calculate the exit price using
I_CurrentEquity. The increase in equity includes any costs
you've factored into your system, so the exit price will be off
by the "cost" amount. In most cases this will be a very small
offset. Also, since I had to use I_AvgEntryPrice for the entry
price, it will show the average entry price if you have multiple
entries.
}
inputs: Win(Tool_Green), Loss(Tool_Red);
vars: MP(0), EPrice(0), EDate(0), ETime(0), ICE(0), PosProfit(0), ExPrice(0), Line(0);
MP = I_MarketPosition;
if MP <> MP[1] then begin { Position has changed }
if MP[1] <> 0 then begin { Just exited a position }
ICE = I_ClosedEquity;
PosProfit = (ICE-ICE[1])/BigPointValue;
if MP[1] = 1 then ExPrice = EPrice + PosProfit
else ExPrice = EPrice - PosProfit;
Line = TL_New(Edate, Etime, Eprice, Date, Time, ExPrice);
TL_SetSize(Line, 1);
if PosProfit > 0 then TL_SetColor(Line, Win)
else TL_SetColor(Line, Loss);
end;
if MP <> 0 then begin { Just entered a position }
EPrice = I_AvgEntryPrice;
Edate = Date;
Etime = Time;
end;
end;
if false then plot1(0,"");
|