{ Equity Curve Date Version 1.02 12/9/99 Gary Fritz This indicator plots bars of closed equity on a periodic basis on the last 200 bars of a chart. If your system test contains more than 200 trades or periods, it only plots the last 200. Winning periods plot green bars, losing periods plot red bars. The indicator also plots the date associated with each bar, in the format YYMM.DD (or YYYMM.DD for year>=2000). This allows you to see exactly when equity peaks, drawdowns, etc happened by looking at the "Date" value associated with a particular bar. The number of periods plotted is determined by the variable "Size," which may be changed. If you increase it, set the size of the array "EQ" and the "MaxBarsBack" value larger than or equal to the value of "Size". Also prints each period's ending equity, and change in equity, to the Print Log. Inputs: Period: Sampling period ("T"=per trade, "Y"=yearly, "Q"=quarterly, "M"=monthly, "W"=weekly, "D"=daily) (Thanks to Bob Fulks for the idea I "borrowed" :-) } Inputs: Period("W"); Vars: Equity(0), EndEq(0), LastEq(0); Vars: Mo(0), Countr(0), J(0), K(0), CE(0), Size(200), Last(0); Vars: Per(0), P1(0), P2(0); Array: EQ[200](0), EQDate[200](0); { Determine the desired period, print the proper header, and set Per to the appropriate value. Why use Per? Because if I compare Period to "T", "Y", etc on every bar, the indicator runs TWICE as slowly! String ops are sloooowww in EL... } if (BarNumber = 1) then begin if Period = "T" then begin print("Per-trade profit:"); Per = 0; end; if Period = "Y" then begin print("Yearly profit:"); Per = 1; end; if Period = "Q" then begin print("Quarterly profit:"); Per = 2; end; if Period = "M" then begin print("Monthly profit:"); Per = 3; end; if Period = "W" then begin print("Weekly profit:"); Per = 4; end; if Period = "D" then begin print("Daily profit:"); Per = 5; end; end; Mo = Month(Date); Equity = I_ClosedEquity; { If our chosen period has expired, record the end-of-period equity } if ((Per = 0) and (Equity <> Equity[1])) or ((Per = 1) and (Year(Date) <> Year(Date[1]))) or ((Per = 2) and (Mo <> Mo[1]) and (Mo=1 or Mo=4 or Mo=7 or Mo=10)) or ((Per = 3) and (Mo <> Mo[1])) or ((Per = 4) and (DayOfWeek(Date) < DayOfWeek(Date[1]))) or ((Per = 5) and (Date <> Date[1])) then begin if Per = 0 then begin EndEq = Equity; EQDate[Countr] = Date / 100; end else begin EndEq = Equity[1]; EQDate[Countr] = Date[1] / 100; end; if (LastBarOnChart = False) then print(Date[1]:6:0,",",EndEq:7:2,",",EndEq-LastEq:7:2); LastEq = EndEq; EQ[Countr] = EndEq; Countr = Mod(Countr + 1, Size); { Move pointer in buffer } end; { On last bar, plot the last Size periods of equity } if LastBarOnChart then for J = 0 to Size - 1 begin { Loop to plot bars } K = Mod(Countr + J, Size); { Calc pointer into buffer } P1 = 0; P2 = 0; if (J > 0) then begin { Set J=0 bar to 0 to "erase" it } if EQ[K] < Last then P1 = EQ[K]; { Plot losing periods in red } if EQ[K] > Last then P2 = EQ[K]; { Plot winning periods in green } end; Plot1[Size - 1 - J](P1,"ClosedEq"); Plot2[Size - 1 - J](P2,"ClosedEq"); Plot3[Size - 1 - J](EQ[K],"ClosedEq"); { Plot white line at top of histogram } Plot4[Size - 1 - J](EQDate[K], "Date"); { Plot date for this bar } Last = EQ[K]; end;