Carsten’s post about a simple pivot-based trading system was intriguing to me mainly because I have never tried to code such a system. I guessed that coding a proof-of-concept of the system would be pretty easy, and it was.
Here is the code for Tradestation:
ATRLength( 10 ), // I used Average True Range as a substitute for Carsten’s “volatility.”
Length( 10 );
ATR( 0 ),
S1( 0 ),
R1( 0 ),
PP ( 0 );
ATR = AvgTrueRange( ATRLength ) ;
PP = close;
S1 = PP – ATR;
R1 = PP + ATR;
If close <= S1 then buy next bar at market;
If close >= R1 then sell short next bar at market;
If currentbar > 1 and marketposition = 1 and close = highest(close, 3) then sell (“LX”) next bar at market;
If currentbar > 1 and marketposition = -1 and close = lowest(close, 3) then buytocover (“SX”) next bar at market;
Here are the results and the equity curve. I assumed 10K starting equity, purchasing only one contract per trade, with no compounding of gains.
Not bad for a first pass. The equity curve is not nearly as nice as Carsten’s version, but again, this was more for practice than anything else.
Below are some recent trades:
I know very little about pivot points, how to calculate them, how to trade them, etc. I need to do much more reading on the subject.
I also know very little about trading S&P E-minis and need to complete more study on trading them as well.
This system can obviously be improved. Right now it suffered some large drawdowns and was underwater for well over 100 trades.
I’m hoping the collective wisdom of the community here can help produce an improved V1.1Comments »