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

(やまだぃちぅ) #1
End
Else Begin
ProfitFactor = 0;
RiskFactor = 0;
End;
TestString = LeftStr(GetSymbolName, 5) + "," + TradeType + "," +
NumToStr(NoTrades, 0) + "," + NumToStr(PercentWinners, 2) + "," +
NumToStr(NetProfit, 2) + "," + NumToStr(AverageProfit, 2) + "," +
NumToStr(StDevProfit, 2) + "," + NumToStr(RiskRatio, 2) + "," +
NumToStr(ProfitFactor, 2) + "," + NumToStr(RiskFactor, 2) + "," +
NumToStr(MaxDrawDown, 2) + "," +
NumToStr(MaxDDPercent, 2) + "," +
NumToStr(PercentInTrade, 2) + "," +
NumToStr(AverageTrLen, 2) + NewLine;
{10} FileAppend(FileString, TestString);
End;
End;

Comments on the Code


Let’s go through the code step-by-step to see how it works:


  1. The variable ExportSwitch(True) must be placed on top of the code or even
    as an Input. The other variables only become active when ExportSwitch is set
    to True. To speed up the computing time, the program will not run through
    the rest of the code, when ExportSwitch is set to False.

  2. We need to create two arrays to contain the data for our calculations. We
    could have done without the arrays and instead run through all the calcula-
    tions for each bar, but to speed up the computing time, we will do most of
    the calculations only once, on the very last bar on the chart. The arrays are
    now set to hold 1,000 trades each. The larger the arrays, the slower the cal-
    culations, so you might want to change this number to what makes the most
    sense for the system you currently are working on.

  3. These calculations and exports only need to be done once, on the very first
    bar on the chart. By altering the state of the variables AllowLong and
    AllowShort at the very top of the code (see the code for any of the individ-
    ual systems), we can test all long and short trades, either separately or togeth-
    er. Then we create the file that we will import into Excel (variable
    FileString), and the column headers for the data we need to export later (vari-
    able TestString).


CHAPTER 7 TradeStation Coding 89

Free download pdf