Stochastic&Bands strategy

Moderator: admin

Stochastic&Bands strategy

Postby Alexander.Gettinger » Mon Dec 19, 2011 10:04 pm

BUY conditions: stochastic crossover appears in oversold area and the candlestick touches the lower band of the Bollinger Band.
SELL conditions: stochastic crossover appears in overbought area and the candlestick touches the upper band of the Bollinger Band.

Download:
Stochastic_BB_Strategy.lua
(15.92 KiB) Downloaded 1870 times


MT4 version.
https://fxcodebase.com/code/viewtopic.php?f=38&t=73055
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Stochastic&Bands strategy

Postby mfoste1 » Tue Dec 20, 2011 12:07 am

Excellent strategy! :D Thank you very much. I have a question, what does the parameter "max distance between stochastic cross and BB event" mean? does that mean pips or number of candles? And does this strategy operate on tick?

thanks Mfoste1 :)
mfoste1
 
Posts: 66
Joined: Thu Oct 21, 2010 6:55 pm

Re: Stochastic&Bands strategy

Postby Alexander.Gettinger » Thu Dec 22, 2011 10:38 am

"max. distance ..." is a maximum distance in candles between the intersection and touching.
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Stochastic&Bands strategy

Postby PascalFXCM » Mon Jan 02, 2012 10:17 am

Does it allow multiple position ? looking to the code at the moment but dont really understand whats going on in the haveTrades part of the extUpdate:

Code: Select all
    if (haveTrades) then
        local enum = trades:enumerator();
        while true do
            local row = enum:next();
            if row == nil then break end

            if row.AccountID == Account and row.OfferID == Offer then
                    -- Close position if we have corresponding closing conditions.
                if row.BS == 'B' then
                  if MustOpenS then
              if ShowAlert then
               if instance.parameters.AllowDirection=="Long" then
                            ExtSignal(source, period, "Close BUY", SoundFile, Email, RecurrentSound);
                         else
             ExtSignal(source, period, "Close BUY and SELL", SoundFile, Email, RecurrentSound);
          end   
             end

              if AllowTrade then
                            Close(row);
                            if instance.parameters.AllowDirection~="Long" then
                             Open("S")
                            end
             end
                  end
                elseif row.BS == 'S' then
                  if MustOpenB then
              if ShowAlert then
               if instance.parameters.AllowDirection=="Short" then
                            ExtSignal(source, period, "Close SELL", SoundFile, Email, RecurrentSound);
                         else
             ExtSignal(source, period, "Close SELL and BUY", SoundFile, Email, RecurrentSound);
          end   
             end

              if AllowTrade then
                            Close(row);
                            if instance.parameters.AllowDirection~="Short" then
                             Open("B")
                            end
             end
                  end
                end

            end
        end
  else
        if MustOpenB==true and instance.parameters.AllowDirection~="Short" then

            if ShowAlert then
                ExtSignal(source, period, "BUY", SoundFile, Email, RecurrentSound)
            end

            if AllowTrade then
                Open("B")
            end
        end

        if MustOpenS==true and instance.parameters.AllowDirection~="Long" then
            if ShowAlert then
               ExtSignal(source, period, "SELL", SoundFile, Email, RecurrentSound)
       end

            if AllowTrade then
                Open("S")
       end
        end
    end
end
PascalFXCM
 
Posts: 6
Joined: Sun Jan 01, 2012 5:34 pm

Re: Stochastic&Bands strategy

Postby mfoste1 » Mon Jan 02, 2012 7:17 pm

Hi there seems to be a problem with this strategy. It is not setting stops and limits, it just triggers the open position. Alex could you please figure out what is causing this :D

thanks, mfoste1
mfoste1
 
Posts: 66
Joined: Thu Oct 21, 2010 6:55 pm

Re: Stochastic&Bands strategy

Postby mfoste1 » Thu Jan 12, 2012 7:04 pm

could someone please try to fix this.

there are two issues
1. not setting stop or limit
2. "distance between events" there seems to be a problem here as the strategy is not opening positions that it should
mfoste1
 
Posts: 66
Joined: Thu Oct 21, 2010 6:55 pm

Re: Stochastic&Bands strategy

Postby Apprentice » Fri Jan 13, 2012 4:03 am

Your request is added to the developmental cue.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Stochastic&Bands strategy

Postby Alexander.Gettinger » Fri Jan 13, 2012 2:12 pm

mfoste1 wrote:Hi there seems to be a problem with this strategy. It is not setting stops and limits, it just triggers the open position. Alex could you please figure out what is causing this :D

thanks, mfoste1


In backtester strategy setting stops and limits.
Please, describe in detail your situation.
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Stochastic&Bands strategy

Postby dell123 » Tue Apr 10, 2012 10:09 pm

I back tested the strategy and it seems to work, however when I placed it on a demo account it would not place any stops or limits. Is this something you can fix? Also, would it be possible to make some additional modifications, such as:

1. Sell a selected number of lot's at a sma,ema,mva or opposite Bollinger band.

2. New stop. For example when the trade is opened the stop would be placed at the previous bars low or you could set by selecting previous bars low plus an amount in pips to keep you just under the previous bars low. Once the first target is hit the stop would be moved to brake even or brake even plus a set number of pips.You could set it up like you did in your Re: Stage trailing stop and just change the call for the parameters. For example level 1 in pips would be changed to touch of ___sma or___ ema and stop 1 in pips would be changed to previous bars low plus or minus pips. Level 2 touch of ___mva. Stop 2 Brake even plus or minus pips. Level 3 touch of opposite B band. Stop 3 previous bars low plus or minus pips. Level 4 the stop is moved to the previous bars low and should continue with a bar under bar stop until target is taken by bar or original strategy.

3. Hours for system to trade on/off two multiples.

4. Days of trading (ie: No Sundays)

Example for above. The strategy takes the order for 4 lots going long and places a stop under previous bars low. Price moves up to target 1 were it touches the SMA and sells 1 lot. The stop is now moved to brake even or plus 1. Price moves up to target 2 were it touches the MVA and sells 1 lot stop could be moved to previous bars low at this time or left at previous level. Price moves up to target 3 were it touches the B Band and sells 1 lot.The stop is now moved to the previous bars low and should continue with a bar under bar stop until target 4 is taken out by bar or the original strategy. Remember by placing a 0 at any of the levels would allow you to by pass that level so you could have sold all 4 lots at target 1,2,3 or 4 if you wanted to.

Thanks
dell123
 
Posts: 17
Joined: Thu Apr 05, 2012 12:20 pm

Re: Stochastic&Bands strategy

Postby Apprentice » Fri Apr 13, 2012 1:38 am

Your suggestions are added to the development list.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Next

Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 6 guests