System for Euro

Discussion in 'Strategy Development' started by sunnyskies, Oct 25, 2005.

  1. It's not great but I'm just getting started in wealth-lab. basically it shorts hammers in a bear market and buy them in a bull market. maybe some of you guys can play with it and improve it..

    Code:
    {#OptVar2 100;10;100;5}
    {#OptVar3 10;10;100;5}
    {#OptVar1 6;1;30;1}
    var Bar: integer;
    var stop: float;
    
    //InstallTimeBasedExit( #OptVar1 );
    SetAutoStopMode( #AsPoint );
    InstallProfitTarget( 0.0350 );
    InstallStopLoss( 0.0100 );
    //InstallTrailingStop( 0.0100, 30 );
    
    
    function LS( i: integer ): float;
    
    begin
    
      Result := PriceOpen(i) - PriceLow(i);
    
    end;
    
    
    function Hammer: boolean;
    
    begin
      var B, US: float;
      B :=  PriceClose (Bar) - PriceOpen (Bar);
      US := PriceHigh( Bar ) - PriceClose (Bar);
      Result := ( PriceClose (Bar) > PriceOpen (Bar)) and
      ( LS (Bar) > 2 * B) and ( LS (Bar) > US );
    
      {and
      { LS of Hammer longer than LSes of last 3 candles }
     // ( LS (Bar) > LS (Bar - 1)) and ( LS (Bar) > LS (Bar - 2)) and ( LS (Bar) > LS (Bar - 3)) and
      { Low of Hammer lower than Lows of last 3 candles }
     // ( PriceLow (Bar) < PriceLow (Bar - 1)) and ( PriceLow (Bar) < PriceLow (Bar - 2)) and
     // ( PriceLow (Bar) < PriceLow (Bar - 3));
    end;
    
    PlotSeries( EMASeries (#Close, 200), 0, #Blue, #Thick );
    
    for Bar := 20 to BarCount - 1 do
    begin
    
      ApplyAutoStops( Bar );
      if not LastPositionActive then begin
          if Hammer() {and ( PriceClose (Bar) < EMA( Bar, #Close, 1600 ))} and
          ( GetYear( Bar ) < 2002 )
           then
              if ShortAtLimit( Bar+1, ( PriceHigh (Bar) + 0.0001), '' )
              then stop := 2 * PriceHigh ( Bar ) - PriceLow ( Bar );
              
           if Hammer() {and ( PriceClose (Bar) < EMA( Bar, #Close, 1600 ))} and
          ( GetYear( Bar ) >= 2002 ) then BuyAtStop( Bar+1, ( PriceHigh (Bar) + 0.0001), '' );
      end;
              
              
              
      //else CoverAtStop( Bar+1, Highest( Bar, #High, 3 ), LastPosition, '');
      
    end;
    
    
     
  2. Your system uses the year 2002 as an additional filter for determining conditions under which to buy or sell. Your current knowledge of the trends in the past may help you indentify times where your trade setup would have been more successful in the past, but it doesn't mean you will be able to identify the right conditions in the future.
    Unless you can identify whether the 'current' market conditions reflect that of a bull market or of a bear market, your system will fail when the market turns around.
    I have a trend following system that uses moving average crossovers to indentify if trend of the target timeframe is in a bullish or bearish trend. As a warning, the problem I am having with that script is that it doesn't identify sideways markets, and is lags in catching the turnaround point. I'm still new to this as well, so I'm looking for ways to optomize it.
     
  3. Techguy

    Techguy

    I'm a little rusty at WL coding, but is that a 350 pip profit target and a 100 pip stop with a six bar time based stop?

    Seems a little tight on the time based stop, even though it is disabled.

    Check out Ryan Sheehy's Currency Secrets site. He did some work on candle patterns and posted some back tested results.