Quote from frostengine:
I decided to convert this over to NinjaTrader. And I tested on 5 min ES data from 7/2003 to 10/21/2008. Here is the code I used. I tried to stick as closely as possible to ScottD's implementation
CashCow automated trading system
Architect: Jack Hershey
Version 0.3
12 Dec 2008
The only thing In my implementation I am unsure of is the stochastics. I may have used wrong parameters there.. Can someone verify this for me and I can rerun the tests. Let me know what is wrong in the conversions and I can make changes.
Here is the code:
bool timeOK=false;
bool volumeOK=false;
bool currentbarOK=false;
bool LongOK=false;
bool ShortOK=false;
//I am on Central time hence the time difference...
if(this.Time[0].Hour>=8&&Time[0].Minute>=45&&Time[0].Hour<15)
timeOK=true;
if(Volume[1]>20000)
volumeOK=true;
if(this.CurrentBar>2)
currentbarOK=true;
if(MACD(5,13,6).Diff[0]>0)
LongOK=true;
if(MACD(5,13,6).Diff[0]<0)
ShortOK=true;
//I may be using the wrong Stochastic parameters...
//Stochastics(D,K,Smooth)
double Stoch5FastK=Stochastics(2,5,3).K[0];
double Stoch5FastKLast=Stochastics(2,5,3).K[1];
double Stoch5FastD=Stochastics(2,5,3).D[0];
double Stoch5FastDLast=Stochastics(2,5,3).D[1];
double Stoch14SlowK=Stochastics(1,14,3).K[0];
double Stoch14SlowKLast=Stochastics(1,14,3).K[1];
double Stoch14SlowD=Stochastics(1,14,3).D[0];
double Stoch14SlowDLast=Stochastics(1,14,3).D[1];
if(currentbarOK==true&&timeOK==true)
{
if(volumeOK==true&&this.Position.MarketPosition==MarketPosition.Flat)
{
if(LongOK==true && Stoch5FastK>50&&Stoch5FastKLast<50&&Stoch5FastK>Stoch5FastD)
{
EnterLong(1,"");
}
if(ShortOK==true && Stoch5FastK<50&&Stoch5FastKLast>50&&Stoch5FastK<Stoch5FastD)
{
EnterShort(1,"");
}
}
if(volumeOK==true)
{
if(ShortOK==true && Stoch5FastK<50&&Stoch5FastKLast>50&&this.Position.MarketPosition==MarketPosition.Long)
{
EnterShort(1,"");
}
if(LongOK==true && Stoch5FastK>50&&Stoch5FastKLast<50&&this.Position.MarketPosition==MarketPosition.Short)
{
EnterLong(1,"");
}
}
if(Position.MarketPosition==MarketPosition.Long&&Math.Abs(MACD(5,13,6)[0])<1.4)
{
if(Stoch14SlowK<Stoch14SlowD&&Stoch14SlowK<80&&Stoch14SlowKLast>80)
{
ExitLong();
}
if(Stoch14SlowK<Stoch14SlowD&&Stoch14SlowKLast>Stoch14SlowDLast)
{
ExitLong();
}
if(Stoch5FastK<50&&Stoch5FastKLast>50)
{
ExitLong();
}
}
if(Position.MarketPosition==MarketPosition.Short&&Math.Abs(MACD(5,13,6)[0])<1.4)
{
if(Stoch14SlowK>Stoch14SlowD&&Stoch14SlowK>20&&Stoch14SlowKLast<20)
{
ExitShort();
}
if(Stoch14SlowK>Stoch14SlowD&&Stoch14SlowKLast<Stoch14SlowDLast)
{
ExitShort();
}
if(Stoch5FastK>50&&Stoch5FastKLast<50)
{
ExitShort();
}
}
}
if(this.Time[0].Hour>=15)
{
ExitLong();
ExitShort();
}