Risk warning

All articles, strategies and indicators are just reflecting a single traders opinion and should be viewed as that.
I advice everybody to trade with a DEMO account!

Wednesday, December 22, 2010

Scalping strategy

First of all for those who don't know.
Scalping = http://en.wikipedia.org/wiki/Scalping_(trading)

How does this strategy work and how do you use it.

How does it work:

The strategy goes long when

1) the low of the current candle is lower than the lower bollingerband (deviation 1)
                         AND
2) the Fast Stochastics (line D) is lower than 19
                         AND
3) if you look back their is a candle with a close at least 5 pips lower than the current candle

The strategy goes short when

1) the high of the current candle is higher than the upper bollingerband (deviation 1)
                         AND
2) the Fast Stochastics (line D) is higher than 81
                         AND
3) if you look back their is a candle with a close at least 5 pips higher than the current candle

The strategy closes a long when

1)  the high of the candle is above the upper bollingerband (deviation 2!)
2)  the open P/L > 8000 X (distance between the upper band and lower band) X number of mini lots
3) the open P/L is bigger than  MaxLoss X number of mini lots

The strategy closes a short when

1)  the low of the candle is beneath the lower bollingerband (deviation 2!)
2)  the open P/L > 8000 X (distance between the upper band and lower band) X number of mini lots
3) the open P/L is bigger than  MaxLoss X number of mini lots





How do u use this strategy:

This strategy is written for mini lots (10.000) AND charts with 5 digits after the comma!!!!

Open EU timeframe 1 min. Attach the strategy to the timeframe. Then optimize the parameters:

h1=6   => The starting hour when the strategy is allowed to take a position
h2=23 => The latest hour when the strategy is allowed to take a position
So for above example strategy can take a position from 6 AM to 23 PM

MaxLoss=50 => The maximum allowed loss in case you use 1 mini lot
minilots=1 => The number of mini lots the strategy uses
So if you put 2 minilots, maxloss will be MaxLoss * 2

offset=1 => The level for the Fast Stochastics
offset =1 gives 81 and 19
offert =2 gives 82 and 18
......
or
offset=-1 gives 79 and 21

check=40 => the number of candles the strategy has to look back to find a lower or higher

Before using this strategy you must play with the paramters until you get a setting that gives you a positive backtest. This way the strategy is optimized for the current market conditions. Test shows that this strategy works pretty well under certain market conditions. Under no conditions i advice any live trading of course but you are free to test this strategy under a DEMO account.


The code:

strategy scalper;
/* written by ctlprogrammer for EUR/USD 1 min chart */
/*Warning for demonstration purpose only, no live trading please*/
/*you can freely copy the code but plz leave this header*/
/* http://ctltrading.blogspot.com*/
input h1=6,h2=23,MaxLoss=25, minilots = 1,offset=1,check=40;
vars currentbar = 1,stoch1min(series),t=0,t1=0,t2=0,longallowed(bool),shortallowed(bool),i(number);
begin
currentbar := back(close);
if currentbar < check then return;
 
Fast_Stochastics(close,5,3);
stoch1min:=Fast_Stochastics.line_d;
 
t:=hour(timestamp[currentbar])*60;
t1:=h1*60;
t2:=h2*60;
   
longallowed:=false;
shortallowed:=false;
Bollinger_Bands(close,20,1);
if t>=t1 and t<=t2 and stoch1min[currentbar]< (20-offset) and low[currentbar]<Bollinger_Bands.line_lower[currentbar] and not short() and not long() then
  begin
        for i:=1 to check do
        begin
        if close[currentbar-5-i]<(close[currentbar]-0.0005) then longallowed:=true;
        end;
        if longallowed=true then
        begin
        buy(minilots);
        end;
  end;
if t>=t1 and t<=t2 and stoch1min[currentbar]> (80+offset)  and high[currentbar]>Bollinger_Bands.line_upper[currentbar] and not short() and not long()then
 begin
        for i:=1 to check do
        begin
        if close[currentbar-5-i]>(close[currentbar]+0.0005) then shortallowed:=true;
        end;
        if shortallowed=true then
        begin
        sell(minilots);
        end;
 end;

Bollinger_Bands(close,20,2); 
if short() and low[currentbar]<Bollinger_Bands.line_lower[currentbar] then exitshort();
if long() and high[currentbar]>Bollinger_Bands.line_upper[currentbar] then exitlong();
 Bollinger_Bands(close,20,2);  
if fpl()<-8000*minilots*(Bollinger_Bands.line_upper[currentbar]-Bollinger_Bands.line_lower[currentbar]) then
 begin
 if long() then begin alert("text","fpl BBS"); exitlong(); end;
 if short() then begin alert("text","fpl BBS"); exitshort(); end;
 end;

if fpl()<-MaxLoss*minilots then
 begin
 if long() then begin alert("text","max loss"); exitlong(); end;
 if short() then begin alert("text","max loss"); exitshort(); end;
 end;
 
  end.

13 comments:

  1. Hi, it is a Good Strategy, can you convert it to the New DealBook.Best Regards jo

    ReplyDelete
  2. It works with the new version of dealbook too. There is no need to convert this. I noticed i sometimes have to close the chart and open a new one to get this strategy running. There must be some kind of bug that makes that the strategy doesn't always start when you first lance it. Most of time after closing the chart and deleting the history it starts fine. I still don't know why it does that. I like this strategy a lot.....

    ReplyDelete
  3. what does this condition mean P/L > 8000*(Bollinger.line_upper-Bollinger.line_lower)*minilots?
    why 8000?

    ReplyDelete
  4. P/L is the open profit or loss.

    8000 is a value that i found after optimizing and testing the strategy. You are free to play with this value. I like 8000. If you find better value. Please share

    Actually it checks how big the profit or loss is compared with the volatility. The width of the bollingerbands are an ideal way to check the volatility. I find it less laggy than the ATR

    ReplyDelete
  5. please tell me where i can get a compiled version ?

    ReplyDelete
  6. Hi,

    I guess you are asking for a MT4 compiled version. Sorry to say it hasn't been written yet.

    ReplyDelete
  7. Hy,

    I m also waiting for the version for the metatrader.At the beginnig i was trading with a GFT platform,but for automated trading,this platform really not good,too many disconnections,and for retarting the platform it last at least 3 min. Metatrader is really more stable and faster in the restarting of the metatrader.Backtesting is more precise wit metatrader.

    San

    ReplyDelete
  8. Well to be honest i never have serious problems with disconnections. Restarting is pretty slow. MT4 has better back testing. That always have been pretty bad with the GFT platform. Still since the introduction of global variables i had the impression that there was still a future for it.
    I wonder when WHselfinvest isn't going to inform its customers.

    ReplyDelete
  9. Hy,
    i will test your beautiful strategy,the only thing what is "negative" i see,is that you are making curvefitting,that means you optimize the strategy for the curret market conditions.But when the conditions change,the strategye will not work anymore for the new period,or not so good. How many times should we optimize the parameters? Can this strategy be applied also for other pairs only by optimizing the parameters?

    Thanks

    ReplyDelete
  10. Well i would optimize each time you start the strategy. I always had some automatic optimizing in mind but i never programmed it. And that would add a lot of coding. I never tried it on other pairs.

    I don't see curve fitting as a bad thing. Curve fitting is also like you said adapting to the current market conditions. Adapting isn't necessarily a bad thing. Of course curve fitting to make a bad strategy perform great = that's pretty bad. Curve fitting to increase profit = why not..... So much to explain about curve fitting. Maybe a post about this topic soon.

    Market conditions don't change every minute. I have seen this strategy make big series of winning trades but also series of losers.....When I use it and when it makes losers I check and try to judge if market conditions are ok or not. If not ok I close strategy for a few hours.

    Remember trade safe. Always use demo account first! These strategy are no holy grails. But they can be a great inspiration for making your own strategy.

    ReplyDelete
  11. Hy

    I think i will try perhaps your strategie in forward testing in a vps server . Some advices perhaps? The results looks good so far. Ps the last 3 posts are from me.

    Sandro

    ReplyDelete
  12. Well like with all strategies try to make some improvements. And please share them with the readers of this blog :-)

    ReplyDelete
  13. Hy,

    In the whs trading platform there is no way to change the parameters and then reevaluate the strategy ,like an optimization in metatrader. It s a lot of work and time to test each parameter.... to get a positive result. When do you think the metatrader version will come out? ;)

    ReplyDelete