PureBytes Links
Trading Reference Links
|
> I wrote the following code, but it writes the values on the first
> day of the month, not the end of the previous month:
>
> If dayofmonth(Date) < dayofmonth(Date[1]) then begin
> Print(File("c:\aaa.eqy"), Date:6:0,",",(OpenPositionProfit+NetProfit):8:2);
> end;
You just need to refer to the previous bar's information in your
print statement. The previous bar is in the previous month, so that
will give you the correct info. Something like:
OPP = OpenPositionProfit;
NP = NetProfit;
if DayOfMonth(Date) < DayOfMonth(Date[1]) then begin
print(File("C:\aaa.eqy"), Date[1]:6:0,",", (OPP[1]+NP[1]):8:2);
end;
You can refer to the previous bar's value of Date, but not
OpenPositionProfit & NetProfit. You have to store them in variables
so you can refer to the previous value. If you don't need to access
them separately, you could add them together in a variable, called
OpenEq or something like that, and refer to OpenEq[1] in the print
statement.
Gary
|