| Feb 2008
|
July 2008
|
Oct 2008
|
Nov 2008
|
Dec 2008
|
| March 2009
|
||||
//
================================
// 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;
Back to top
July 2008
TradeStation code for “Pre-trend reversal system”
Inputs: StopLossAmt(500),Tim(1330);
If time >=Tim and Time<=Tim+59
and TradesToday(date)<1 then begin
If MarketPosition<>1 then Buy next bar at HighD(0) stop;
If MarketPosition<>-1 then Sell short next bar at LowD(0) stop;
end;
If StopLossAmt > 0 then
SetStopLoss( StopLossAmt );
SetStopShare;
SetExitOnClose ;
Back to top
October 2008
TradeStation code for “System filtering with %C”
%C indicator:
Inputs:lng(numericsimple);
Value1=TrueHigh;
Value2=TrueLow;
Value3=Value1-value2;
Value4=Summation(value3,lng);
Value5=Highest(Value1,lng);
Value6=Lowest(value2,lng);
If value5-value6>0 then Value7=value5-value6;
Value8=(value4/value7);
if Value8 <> 0 then Value9 = Log (value8);
Value10=value9/log(lng);
Value11=Value10*100;
@PercentC=Value11;
********
TradeStation system code
Filtered strategy #1
[LegacyColorValue = true];
Inputs: fac(.9),facs(.9);
Inputs: LChopEx(65),CDLF(14);
Inputs: SChopEx(65),CDSF(14);
If EntriesshortToday(Date)<1
and PercentC(CDSF)>SChopEx
Then Begin
Sell Short ( "DayTrader-SE" ) next bar at
OpenD(0) - ((HighD(1) - LowD(1)) * fac) stop ;
end;
If EntriesLongToday(date)<1
and PercentC(CDLF)>LChopEx
Then Begin
Buy ( "DayTrader-LE" ) next bar at
OpenD(0) + ((HighD(1) - LowD(1)) * facs) stop ;
End;
Filtered strategy #2
Inputs: fac(0.9),facs(.9);
Inputs: TrendExup(36),LChopEx(65),CDLF(14);
Inputs: TrendExdw(36),SChopEx(65),CDSF(14);
If EntriesshortToday(Date)<2
and (PercentC(CDSF)<TrendExdw and PercentC(CDSF)>15 )
or (PercentC(CDSF)>SChopEx )
Then Begin
Sell Short ( "TON%CPlus-SE" ) next bar at
OpenD(0) - ((HighD(1) - LowD(1)) * fac) stop ;
end;
If EntriesLongToday(date)<2
and ( PercentC(CDLF)<TrendExup and PercentC(CDLF)>15 )
or (PercentC(CDLF)>LChopEx )
Then Begin
Buy ( "TON%CPlus-LE" ) next bar at
OpenD(0) + ((HighD(1) - LowD(1)) * facs) stop ;
End;
Filtered strategy #3
Inputs: fac(0.9),facs(.9);
Inputs: TrendExup(36),LChopEx(65),CDLF(16);
Inputs: TrendExdw(36),SChopEx(65),CDSF(14);
If EntriesshortToday(Date)<2
and (PercentC(CDSF)<TrendExdw and PercentC(CDSF)>15 and
PercentC(CDSF)<XAverage(PercentC(CDSF), 6))
or (PercentC(CDSF)>SChopEx )
Then Begin
If (time>0930 and time <1000 or time>1200 and time <1530) then Sell Short ( "TON%CPlusA-SE" ) next bar at
OpenD(0) - ((HighD(1) - LowD(1)) * fac) stop ;
end;
If EntriesLongToday(date)<2
and ( PercentC(CDLF)<TrendExup and PercentC(CDLF)>15 )
or (PercentC(CDLF)>LChopEx )
Then Begin
If (time>0930 and time <1000 or time>1200 and time <1530) then Buy ( "TON%CPlusA-LE" ) next bar at
OpenD(0) + ((HighD(1) - LowD(1)) * facs) stop ;
End;
November 2008
CQG code for “Two systems are better than one”
Bollinger Band system:
Long Entry: Close(@)[-1] > BHI(@,Sim,20,2.00)[-1]
Short Entry: Close(@)[-1]< BLO(@,Sim,20,2.00)[-1]
Long & Short Exit (set price field to): BMA(@,Sim,20)[-1]
Counter-trend RSI system:
Long Entry: RSI(@,9)[-1] < 35 AND Close(@)[-1] > MA(@,Sim,200)[-1] AND Vol(@)[-2] > Vol(@)[-1]
Long Exit: RSI(@,9)[-1] > 65 OR OpenPositionAverageEntryPrice(@,ThisTradeOnly) - Dollar2Price(@,7500) / OpenPositionSize(@,ThisTradeOnly)
Short Entry: RSI(@,9)[-1] > 65 AND Close(@)[-1] < MA(@,Sim,200)[-1] AND Vol(@)[-2] > Vol(@)[-1]
Short Exit:
RSI(@,9)[-1] > 65 OR OpenPositionAverageEntryPrice(@,ThisTradeOnly) - Dollar2Price(@,7500) / OpenPositionSize(@,ThisTradeOnly)
December 2008
TradeStation code for “Trading the pit’s last trend”
The entry and exit strategies should be saved and verified in TradeStation as separate strategies, and then applied to the same @SP.P intraday 5-min chart.
{Entry Strategy: Last Trend In The Pit.
By: B.Stein
Use on 5-min @SP.P chart.}
var: BarsToOpen(0);
if t=calctime(sessionendtime(0,2), -barinterval) {1 bar before the last bar of the day}
then
begin
value1=(TimeToMinutes(SessionEndTime(0,2)) - TimeToMinutes(Sess1FirstBarTime))/barinterval;
BarsToOpen=Iff(FracPortion(value1)=0, value1, IntPortion(value1)+1);
value2 = MRO(h=highd(0),BarsToOpen,1); {bars to latest high of day}
value3 = MRO(l=lowd(0),BarsToOpen,1); {bars to latest low of day}
if value2>0 and value3>0 {both extremes found} and d=d[value2] and d=d[value3] {both for the same day} then
begin
if c > lowd(0) and value3 < value2 {low happened after high} then
buy("NTrendLE") next bar market;
if c < highd(0) and value2 < value3 {high after low} then
sellshort("NTrendSE") next bar market;
end;
end;
{Exit Strategy: Exit On Profitable Bar Close.
By: B.Stein}
input:BarsInTrade(1);
if positionprofit > 0 or barssinceentry>= BarsInTrade then
begin
Sell("PTExitLong") this bar on close;
Buytocover("PTExitShort") this bar on close;
end;
Back to top
March 2009
TradeStation code for "Using Probability as a guide"
// =================================
// Stoch Probability Strategy
// Coded by: Lee Leibfarth 2009
// =================================
inputs:
StopLoss(800),
ProfitTarget(800),
Line1(25),
Line2(75),
StochLength(14),
DoubleDSwitch(false),
DoubleDLimit(4);
variables:
oFastK(0),
oFastD(0),
oSlowK(0),
oSlowD(0),
count(0),
PrevLosTrades(0),
PrevWinTrades(0),
NumContracts(1);
value1 = Stochastic( h, l, c, StochLength, 3, 3, 1, oFastK, oFastD, oSlowK, oSlowD);
// ==== MONEY MANAGEMENT ====
if DoubleDSwitch then begin
if PrevLosTrades <> numlostrades then begin
if count <= DoubleDLimit or DoubleDLimit = 0 then NumContracts = NumContracts * 2;
if count > DoubleDLimit and DoubleDLimit <> 0 then NumContracts = 1;
count = count + 1;
end;
if PrevWinTrades <> numwintrades then begin
NumContracts = 1;
count = 1;
end;
PrevLosTrades = numlostrades;
PrevWinTrades = numwintrades;
end;
//==== TRADE RULES ====
if marketposition = 0 and time > 830 and time < 1500 then begin
if oFastK crosses under Line1 then sellshort ("ST_Sell") NumContracts contracts next bar at market ;
if oFastK crosses over Line2 then buy ("ST_Buy") NumContracts contracts next bar at market ;
end;
if time > 1600 then begin
sell ("EOD_LX") next bar at market;
buytocover ("EOD_SX") next bar at market;
end;
setstopcontract;
setexitonclose;
setstoploss(StopLoss);
setprofittarget(ProfitTarget);
Back to top