Futures and Options Trader Magazine



February 2008

TradeStation code for "Fibonacci pivot points," p. 8:

// ================================
// FibPivot Strategy (Version 1.0)
// By: Lee Leibfarth
// 12-30-07
//
// TARGET: 5-Minute ES
// ================================

variables:
TradeSwitch(false),
Pivot(0),
R1(0),
R2(0),
S1(0),
S2(0),
PrevHigh(0),
PrevLow(0),
PrevClosed(0);
If date <> date[1] then begin
TradeSwitch = true;
PrevHigh = highd(1);
PrevLow = lowd(1);
PrevClosed = closed(1);
Pivot = (PrevHigh + PrevLow + PrevClosed )/3;
R1 = Pivot + (PrevHigh - PrevLow) * .382;
S1 = Pivot - (PrevHigh - PrevLow) * .382;
R2 = Pivot + (PrevHigh - PrevLow) * .618;
S2 = Pivot - (PrevHigh - PrevLow) * .618;
end;
if TradeSwitch and time > 930 and time < 1300 and marketposition = 0 then begin
if c < R1 then sellshort ("SellShort_R1") next bar at R1 limit;
if c > S1 then buy ("Buy_S1") next bar at S1 limit;
if c > R1 and c < R2 then buy ("Buy_R2") next bar at R2 stop;
if c < S1 and c > S2 then sellshort ("SellShort_S2") next bar at S2 stop;
end;
if marketposition = 1 then begin
sell from entry ("Buy_S1") next bar at Pivot limit;
sell from entry ("Buy_S1") next bar at S2 stop;
sell from entry ("Buy_R2") next bar at Pivot stop;
TradeSwitch = false;
end;
if marketposition = -1 then begin
buytocover from entry ("SellShort_R1") next bar at Pivot limit;
buytocover from entry ("SellShort_R1") next bar at R2 stop;
buytocover from entry ("SellShort_S2") next bar at Pivot stop;
TradeSwitch = false;
end;
if time >= 1600 then begin
sell next bar at market;
buytocover next bar at market;
end;
setexitonclose;



|
email this story
|
print this story