Trading Systems and Money Management : A Guide to Trading and Profiting in Any Market

(やまだぃちぅ) #1
NameLength = StrLen(GetStrategyName) - 6;
FileString = "D:\BookFiles\InitTest-" +
RightStr(GetStrategyName, NameLength) + "-" +
RightStr(NumToStr(CurrentDate, 0), 4) + ".csv";
TestString = "Market" + "," + "Direction" + "," + "Trades" + "," +
"PercWin" + "," + "NetProfit" + "," + "AvgProfit" + "," +
"StDevProfit" + "," + "RiskRatio" + "," + "ProfitFactor" + "," +
"RiskFactor" + "," + "MaxDD" + "," + "PercDD" + "," +
"PercTime" + "," + "AvgLength" + NewLine;
FileAppend(FileString, TestString);
End;
{4} NoTrades = TotalTrades;
If NoTrades > NoTrades[1] Then Begin
TradeProfit[SetExportArray] = PositionProfit(1);
TradeLength[SetExportArray] = DateToJulian(ExitDate(1)) -
DateToJulian(EntryDate(1)) + 1;
SetExportArray = SetExportArray + 1;
End;
{5} If LastBarOnChart Then Begin
{Alt: If LastCalcDate = Date + 1 Then Begin}
EndPeriod = DateToJulian(Date);
PeriodLength = EndPeriod - StartPeriod;
For ExportArrayPos = 0 To (NoTrades - 1) Begin
SumProfit = SumProfit + TradeProfit[ExportArrayPos];
If SumProfit > MaxProfit Then
MaxProfit = SumProfit;
DrawDown = MaxProfit - SumProfit;
If MaxProfit > 0 Then
DDPercent = DrawDown * 100 / (100000 + MaxProfit)
Else
DDPercent = DrawDown * 100 / 100000;
If DrawDown > MaxDrawDown Then
MaxDrawDown = DrawDown;
If DDPercent > MaxDDPercent Then
MaxDDPercent = DDPercent;
If TradeProfit[ExportArrayPos] > 0 Then
WinningTrades = WinningTrades + 1;

CHAPTER 7 TradeStation Coding 87

Free download pdf