PureBytes Links
Trading Reference Links
|
Hi list,
I need a little help. The code below has been written in order to
compare the performance of a stock versus the index when a trading
system entry on the stock. This is the basic version,
based only on a simple moving average. Slave is the stock , master is
the Index, Length is the lookback of the moving average. This indicator
(is NOT a sistem, it SIMULATE a sistem)
runs on daily data and creates a file txt with the name specified with
the input "Report". I import the file in MS Excel for further study
(remember this is the basic version).
My problem is the calculos of the "performance". I use the ROC formula,
but the result are very BAD, I think it's for a code problem. The result
is very different compared to what I get in
Excel and in most of the cases the result is wrong. i.e.: Entry 2.23
Exit 3.48 Performance: - 6.48 !!!!!!!!!!
I use TS2000 and there aren't plot command line.
Any help would be appreciated.
{This is a simple test-code written by Nicola Prada to
in order to compare the performance of a stock versus
the performance of the index when the system entry}
Input: Slave(Close of data1),
Master(Close of data2),
Length(25),
Report("c:\TEST.txt");
Vars: Pox(0),
PrezzoEntryAz(0),
PrezzoEntryIn(0),
PerfAz(0),
PerfIn(0),
PosN(0);
Condition1=C>Average(C,Length);
Condition2=C<Average(C,Length);
if date of data1 > date[1] of data1 then begin
{Entry if price > average}
if Pox=0 AND Condition1 then begin
PosN=PosN+1;
FileAppend(Report,
"PositionN " +
NumToStr(PosN, 0)+ " "+
NumtoStr(Month(Date of Data1),0) + "/" + {Date - Month}
NumToStr(DayOfMonth(Date of Data1),0) + "/"+ {Date - Day}
NumtoStr(Year (Date of Data1),0) +" " + {Date - Year}
NumToStr(Open of Data1, 0)+"." + RightStr(NumtoStr(FracPortion(Open of
Data1),4),4) + " " +
NumToStr(Open of Data2, 0)+"." + RightStr(NumtoStr(FracPortion(Open of
Data2),4),4) + " " );
Pox=1;
PrezzoEntryAz=Open[0] of data1;
PrezzoEntryIn=Open[0] of data2;
End;
{Esce the position ic price < average}
if Pox=1 AND Condition2 then begin
PerfAz=(((Open[0] of data1/PrezzoEntryAz)-1)*100);
PerfIn=(((Open[0] of data2/PrezzoEntryIn)-1)*100);
FileAppend(Report,
"PositionClosed" + " " +
NumtoStr(Month(Date of Data1),0) + "/" + {Date - Month}
NumToStr(DayOfMonth(Date of Data1),0) + "/"+ {Date - Day}
NumtoStr(Year (Date of Data1),0) +" " + {Date - Year}
NumToStr(Open[0] of data1,0)+"." +
RightStr(NumtoStr(FracPortion(Open[0] of data1),4),4) + " " +
NumToStr(Open[0] of data2, 0)+"." +
RightStr(NumtoStr(FracPortion(Open[0] of data2),4),4)+ " "+
NumToStr(PerfAz, 0)+"." + RightStr(NumtoStr(FracPortion(PerfAz),4),4)
+ " "+
NumToStr(PerfIn, 0)+"." + RightStr(NumtoStr(FracPortion(PerfIn),4),4)
+ NewLine );
Pox=0;
PerfAz=0;
PerfIn=0;
PrezzoEntryAz=0;
PrezzoEntryIn=0;
End;
End;
|