Quote from ScottD:
Here is the code for version 0.1 of the CashCow ATS. The name is nice and it's red rags for bull. In order for me to code stuff, I have to make the concepts very simple to match my lack of fluency in the programming language. As a side effect, it should be very easy to read.
I have started to bring some MACD language into the code so that later I can form some logical constructs with it, but for now it's commented out. Anything in between curly brackets { ... } is commented out for now.
Attached is a screen shot of the automated trade decisions. On the chart, you'll see labels for Long Entry (...LE), Short Entry (...SE), Long Exit (...LX), Short Exit (...SX) and, for today, End of Day Short Exit (EODSX). You will also see color coded vertical arrows showing the exact bar of entry and exit and horizontal arrows showing the exact price of entry and exit.
Technically, it made net profits today with a 4/6 win rate. Realistically the P&L is irrelevant at this stage because the engine is extremely rudimentary and not yet even close to what Jack is describing. Having a rudimentary engine to improve is a nice start though.
{
CashCow automated trading system
Architect: Jack Hershey
Version 0.1
11 Dec 2008
}
variables:
FastK5( 0 ), FastD5( 0 ), SlowK5( 0 ), SlowD5( 0 ),
FastK14( 0 ), FastD14( 0 ), SlowK14( 0 ), SlowD14( 0 ) ;
if Time > 945 and Time < 1600 then begin
Value1 = Stochastic( H, L, C, 5, 2, 3, 1, FastK5, FastD5, SlowK5, SlowD5 ) ;
Value2 = Stochastic( H, L, C, 14, 1, 3, 1, FastK14, FastD14, SlowK14, SlowD14 ) ;
condition1 = CurrentBar > 2 and FastK5 crosses over 50 ;
if condition1 and marketposition = 0 then
Buy ( "FastK5LE" ) 1 contract this bar at close ;
condition2 = CurrentBar > 2 and FastK5 crosses below 50 ;
if condition2 and marketposition = 0 then
Sellshort ( "FastK5SE" ) 1 contract this bar at close ;
condition3 = CurrentBar > 2 and (SlowK14 < SlowD14) and (SlowK14 crosses below 80) ;
if condition3 and marketposition > 0 then
Sell ( "SlowK5LX" ) 1 contract this bar at close ;
condition4 = CurrentBar > 2 and (SlowK14 > SlowD14) and (SlowK14 crosses above 20) ;
if condition4 and marketposition < 0 then
buytocover ( "SlowK5SX" ) 1 contract this bar at close ;
variables: MACDVal( 0 ), MACDMA( 0 ), MACDHist( 0 ) ;
MACDVal = MACD( Close, 5, 13 ) ;
MACDMA = XAverage( MACDVal, 6 ) ;
MACDHist = MACDVal - MACDMA ;
{
condition5 = CurrentBar > 2 and absvalue( MACDVal ) < 1.4 ;
if condition5 and marketposition > 0 then
Sell ( "MACDLX" ) this bar at close ;
if condition5 and marketposition < 0 then
Buytocover ( "MACDSX" ) this bar at close ;
}
end;
if Time > 1600 and marketposition > 0 then sell ( "EODLX" ) next bar at market;
if Time > 1600 and marketposition < 0 then buytocover ( "EODSX" ) next bar at market;
I see this is set up for a rocket entry (MACD hist .1.4) based on STOCH5 direction after a three bar time synch.
Conservative but useful for first pass.
I see the exit is STOCH 14 stuff.
You need to slip in a way to do a reversal if the new entry is BEFORE the old exit.
you said you had two losses. throw up the chart and I will focus on the coding here to eliminate losses as a starter. then we go to work on coding.