[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coding StdDev of Individual Trade Returns



PureBytes Links

Trading Reference Links

The Excel STDEV function is the standard deviation based on a sample, or
subset of a population.  The STDEVP function is analagous to your
Easylanguage code.  Do your answers agree if you use STDEVP?

Aaron




STDEV
See Also

Estimates standard deviation based on a sample. The standard deviation is a
measure of how widely values are dispersed from the average value (the
mean).

Syntax

STDEV(number1,number2,...)

Number1, number2, ...   are 1 to 30 number arguments corresponding to a
sample of a population. You can also use a single array or a reference to an
array instead of arguments separated by commas.

Remarks

  a.. STDEV assumes that its arguments are a sample of the population. If
your data represents the entire population, then compute the standard
deviation using STDEVP.
  b.. The standard deviation is calculated using the "nonbiased" or "n-1"
method.
  c.. STDEV uses the following formula:
  d..





----- Original Message -----
From: "Lance Fisher" <lance@xxxxxxxxxxxxxxx>
To: <omega-list@xxxxxxxxxx>
Sent: Saturday, March 09, 2002 12:57 PM
Subject: Coding StdDev of Individual Trade Returns


> Hello all,
>
> I seek the help of someone more smarter than I are.
>
> I am trying to calculate the Standard Deviation of the individual trade
> returns for a system. My humble snippet of code below is designed to be
> pasted at the bottom of a signal so the AvgTrade & StdDev of individual
> trade returns can be exported to a csv file.
>
> In order to double check the results produced by the code, I manually
> saved the trade returns to an Excel file straight from the "Trades"
> section of the TS performance summary. I then used Excel's Std Dev
> function (Both sample & population) to see if the results jived with
> those produced by my code below.
>
> Unfortunately, the results did not match, and I cannot figure out why.
>
> Is it perhaps because I'm using the built in Strategy Performance
> functions "TotalTrades" and "PositionProfit"? Has any one experienced
> unreliable results when using the built in Strategy Performance
> functions?
>
> Any ideas are apreciated.
>
> Lance Fisher
>
>
>
> {Code below}
>
>
> Vars: AvgTrd(00), SDEV(00), Summer(00), Cntr1(00), Cntr2(00),
> SumVar(00);
>
> If LastBarOnChart then begin
>
> AvgTrd = 00;
> SDEV = 00;
>
> If TotalTrades <> 00 then begin;
> Summer = 00;
>  For Cntr1 = 0 to TotalTrades - 1 begin {Calculate Average of all
> trades}
>   Summer = Summer + PositionProfit(Cntr1);
>  End;
>
>  AvgTrd = Summer / TotalTrades;
>  SumVar = 00;
>
>  For Cntr2 = 0 to TotalTrades - 1 begin {Calculate the variances (or
> rather, the sum of the variances)}
>   SumVar = SumVar + (PositionProfit(Cntr2) -
> AvgTrd)*(PositionProfit(Cntr2) - AvgTrd) / TotalTrades;
>  End;
>  SDEV = SquareRoot(SumVar); {StdDev = the SqRoot of the sum of the
> variances. Right?}
> End
> Else
> SDEV = 00;
>
>   FileAppend(FileName, Text(GetSymbolName, NetProfit/TotalTrades, SDEV)
> + NewLine) ; {Print AvgTrade & StdDev to a csv file for further
> analysis}
> End;
>
>

Attachment: Description: ""