+1 888 340 6572

# Miscellaneous > Equity Curve Date

Article/Author: Origin: Gary Fritz`s site. Coded by Gary Fritz, 12/09/1999

File Includes:

Indicator - Equity Curve Date
Function - LastBarOnChart
Function - LastCalcDate
Function - LastCalcTime

Category: Miscellaneous > Eqcurve

Description:

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.

Usage:

Move indicator to subgraph 2

Inputs:

Sampling period ("T"=per trade, "Y"=yearly, "Q"=quarterly, "M"=monthly, "W"=weekly, "D"=daily)

EasyLanguage Code:
```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;```