working system, needs improvement

Discussion in 'Technical Analysis' started by traderkay, Feb 13, 2003.

  1. The instrument is ES 15min. Testing period is from contract start in 97 til Aug. 02. I will disclose the idea, the code, the performance stats and the equity curve picture.

    The idea: We look for sequences of 3 red candles (C<O) and 3 green candles (C>O). We enter short on the break of the low of the third candle, vica versa for longs. The stop is equal to the highest high - lowest low of the 3 candle combo. Target is 0.5 of that amount. There's only 2 exits: at stop and at profit target. There's also a 200EMA filter (it greatly cuts down on number of trades without hurting profits). We require that the third candle's close be above/below 200EMA. The WealthLab code is below.

    var bar, n, exitbar: integer;
    var StopPrice, target, bepoint: float;

    function RedSequence(bar: integer ): boolean;
    begin
    var z: integer;
    z := bar - 1;
    if (PriceClose(z)<PriceOpen(z)) and
    (PriceClose(z-1)<PriceOpen(z-1)) and
    (PriceClose(z-2)<PriceOpen(z-2)) then
    Result := true;
    end;

    function GreenSequence(bar: integer ): boolean;
    begin
    var z: integer;
    z := bar - 1;
    if (PriceClose(z)>PriceOpen(z)) and
    (PriceClose(z-1)>PriceOpen(z-1)) and
    (PriceClose(z-2)>PriceOpen(z-2)) then
    Result := true;
    end;

    for Bar := 4 to BarCount () - 1 do
    BEGIN
    if LastPositionActive () then // let's close position //
    begin
    // Closing short //
    if PositionShort(LastPosition) then begin
    // if PriceLow(bar)< bepoint then StopPrice := PositionBasisPrice(LastPosition)-0.25;
    if PriceHigh(bar)> StopPrice then begin
    CoverAtStop(bar, StopPrice, LastPosition, '');
    exitbar := bar; end;
    if PriceLow(bar)< target then begin
    CoverAtLimit(bar, target, LastPosition, '' );
    exitbar := bar; end;
    end;
    // Closing long //
    if PositionLong(LastPosition) then begin
    //if PriceHigh(bar)> bepoint then StopPrice := PositionBasisPrice(LastPosition);
    if PriceLow(bar)< StopPrice then begin
    SellAtStop(bar, StopPrice, LastPosition, '');
    exitbar := bar; end;
    if PriceHigh(bar)> target then begin
    SellAtLimit(bar, target, LastPosition, '' );
    exitbar := bar; end;
    end;
    end

    // No position open - let's open one!
    else begin

    // If red sequence and triggered on this bar then do following
    if RedSequence(bar) and (PriceLow(bar)<PriceLow(bar-1))
    and (PriceClose(bar-1)<EMA(bar-1, #Close, 200))

    then
    begin
    // Color chart background pink for three bars
    for n := 1 to 3 do SetBackgroundColor(bar-n, #RedBkg);
    ShortAtStop(bar, PriceLow(bar-1)-0.01, '');
    StopPrice := Max(Max(PriceHigh(bar-1), PriceHigh(bar-2)), PriceHigh(bar-3)) + 0.01;
    target := PositionBasisPrice(LastPosition) - 0.5*(StopPrice - Min(Min(PriceLow(bar-1), PriceLow(bar-2)), PriceLow(bar-3)));
    bepoint := PositionBasisPrice(LastPosition) - 2*(StopPrice - Min(Min(PriceLow(bar-1), PriceLow(bar-2)), PriceLow(bar-3)));
    end;

    // If green sequence and triggered on this bar then do following
    if GreenSequence(bar) and (PriceHigh(bar)>PriceHigh(bar-1))
    and (PriceClose(bar-1)>EMA(bar-1, #Close, 200))

    then
    begin
    // Color chart background lime for three bars
    for n := 1 to 3 do SetBackgroundColor(bar-n, #GreenBkg);
    BuyAtStop(bar, PriceHigh(bar-1)+0.01, '');
    StopPrice := Min(Min(PriceLow(bar-1), PriceLow(bar-2)), PriceLow(bar-3)) - 0.01;
    target := PositionBasisPrice(LastPosition) - 0.5*(StopPrice - Max(Max(PriceHigh(bar-1), PriceHigh(bar-2)), PriceHigh(bar-3)));
    bepoint := PositionBasisPrice(LastPosition) - (StopPrice - Max(Max(PriceHigh(bar-1), PriceHigh(bar-2)), PriceHigh(bar-3)));
    end;
    end;
    END;
     
  2. Commissions were set at $10/RT. Trading 1 contract.

    All Trades Long Trades Short Trades Buy && Hold
    Net Profit $40,589.08 $14,366.84 $26,222.15 $-580.00
    Profit per Bar $3.89 $2.46 $5.73 $-0.02
    All Trades 1,422 739 683 1
    Avg Profit/Loss $28.54 $19.44 $38.39 $-580.00
    Avg Profit/Loss % 0.05% 0.03% 0.06% -1.26%
    Avg Bars Held 7.33 7.91 6.70 33,783.00
    Winning Trades 1020 (71.73%) 525 (71.04%) 495 (72.47%) 0
    Gross Profit $231,796.27 $107,476.52 $124,319.76 $0.00
    Avg Profit $227.25 $204.72 $251.15 $0.00
    Avg Profit % 0.38% 0.34% 0.42% 0.00%
    Avg Bars Held 6.26 6.77 5.72 0.00
    Max Consecutive 18 11 14 0
    Losing Trades 402 (28.27%) 214 (28.96%) 188 (27.53%) 1
    Gross Loss $-191,207.06 $-93,109.55 $-98,097.54 $-580.00
    Avg Loss $-475.64 $-435.09 $-521.80 $-580.00
    Avg Loss % -0.80% -0.72% -0.89% -1.26%
    Avg Bars Held 10.04 10.71 9.28 33,783.00
    Max Consecutive 7 5 6 1
    Max DrawDown $-7,039.31 $-5,428.27 $-6,069.30 $-39,675.00
    Recovery Factor 5.77 2.65 4.32 0.01
    Profit Factor 1.21 1.15 1.27 N/A
    Payoff Ratio 0.48 0.47 0.48 N/A
    Standard Error $2,342.50 $2,305.53 $2,427.99 $8,493.53
    Risk Reward Ratio 0.13 0.06 0.07 0.00
    Sharpe Ratio of Trades 1.98 1.25 2.75 N/A
     
  3. check out equity curve here.
     
  4. OK, this system is profitable over the long-term. Mark Brown's Oddball system did good the least two or so years but bombed if you looked earlier; and it generated a ton of excitement; well as far as I'm concerned this system is better.

    Now let's look at the good points about the system. There's pretty much only 1 - robustness/absence of paramters (optimization).

    The minuses: To be honest this system doesn't have much of an edge. Meaning the Profit Factor is only 1.21. That is achieved solely thru the fact that when we reduced the profit target to 1/2 of risk (stop), we increased the wins to 70%, which is higher than the breakeven 66% we would expect in a random game. The drawdowns last way too long - that's the #1 reason I can't trade this system, I can't wait for half-year or a year to start making money. That's not acceptable. Plus the very first drawdown is kinda close to 50%, which kinda bites.

    Where we want to go: We want to add some filters, that improve winning % without sacrificing profits. Or maybe we can somehow let profits run in a big way. In any case we need to shorten the duration of drawdowns, and increase PF to 2+.
     
  5. onelot

    onelot

    this is a great idea traderkay! using this example as a model for system development i think is going to be very useful.

    i ran the script in Wealth-Lab but there were some problems with the code you posted. I took the liberty of trying to figure them out.

    Please let me know if this isn't the way you wanted it:

    Red sequence function should look like this:

    function RedSequence(bar: integer ): boolean;
    begin
    var z: integer;
    z := bar - 1;
    if (PriceClose(z) < PriceOpen(z)) and
    (PriceClose(z-1) < PriceClose(z-1)) and
    (PriceClose(z-2) < PriceClose(z-1)) then
    Result := true;
    end;

    and line 54 should be:

    if RedSequence(bar) and (PriceLow(bar) < PriceClose(bar-1))

    whew! :)
     
  6. onelot

    onelot

    nope... i messed up here :(

    ok, well take the above as proof that i'm not a great coder... :)

    i think i'm gonna need you on this one.

    to answer your third post... perhaps placing some sort of trailing stop or using some sort of trend indicator signal for your exit would allow those winners some room. just looking at the longs that i was able to get working :) most of them had a lot of room if they weren't cut short.

    onelot
     
  7. I think that 15 min is not a ideal time frame, 5 min should work better. I would add confirmation filter also.
    Walter
     
  8. ges

    ges

    Walter,

    Why do you 'think' that 5 min is better than 15 min? Making these kind of statements without anything to substantiate them is not very helpful.

    gs
     
  9. Try it and you will see that 5 min will have much better response time, especially when activating stops. Use 15 min to determine a trend .
    What would be your suggestion to improve this system ?
    Walter
     
  10. onelot, the copy/paste somehow messed up and of course it's if RedSequence(bar) and (PriceLow(bar) < PriceLow(bar-1)) in line 54. Regarding trailing stops, go ahead and implement some and tell us what happens, I'm not much of a coder either:)
     
    #10     Feb 14, 2003