Bollinger reversal robot

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #31080 quote
    CN
    Participant
    Senior

    Hey guys,

    So I came across a screener for bollinger reversal.
    I like the idea and would try to make an automated system for it.

    1h and daily would be the timeframe.

    How do we make it automatic?

    Originalcode from https://www.youtube.com/watch?v=kSBxmx5KUPg

    Boll = 20
    flag = 0
    
    BolDown = BollingerDown[Boll](close)
    BolUp = BollingerUp[Boll](close)
    
    BearishEngulfing = CLOSE[1] > OPEN[1] AND OPEN > CLOSE[1] AND CLOSE < OPEN[1]
    BullishEngulfing = CLOSE[1] < OPEN[1] AND OPEN < CLOSE[1] AND CLOSE > OPEN[1]
    
    BearishHarami = CLOSE[1] > OPEN[1] and OPEN > CLOSE and OPEN <= CLOSE[1] and OPEN[1] <= CLOSE and OPEN - CLOSE < CLOSE[1] - OPEN[1]
    BullishHarami = OPEN[1] > CLOSE[1] and CLOSE > OPEN and CLOSE <= OPEN[1] and CLOSE[1] <= OPEN and CLOSE - OPEN < OPEN[1] - CLOSE[1]
    
    TweezerTop = ABS(HIGH -(HIGH[1]))<= HIGH * 0.0025
    TweezerBottom = ABS(LOW -(LOW[1]))<= LOW * 0.0025
    
    AboveUpperBand=close[1] > BolUp and open > BolUp
    BelowLowerBand=close[1] < BolDown and open < BolDown
    
    GoShort =((BearishEngulfing or BearishHarami or TweezerTop ) and AboveUpperBand)
    GoLong = ((BullishEngulfing or BullishHarami or TweezerBottom) and BelowLowerBand)
    
    if GoLong then
    flag = 1
    Endif
    if GoShort then
    flag =-1
    endif
    
    screener[GoLong or GoShort](flag as  "1 long / -1 short")
    
    #31084 quote
    StantonR
    Participant
    Senior

    Hi CN

    I believe that that is my code from youtube but that is why we do this to share knowledge.

    I started working on the robot for this. But we need to define a good exit strategy and money management.

    The current exit is when the price closes above or below the ema 20 which is basically the midlle bollinger line.

    This system works well in trending markets as it is a mean reversion strategy, so money management will be key.

     

    DEFPARAM CUMULATEORDERS = false
    
    Boll = 20
    n = 1
    
    BolDown = BollingerDown[Boll](close)
    BolUp = BollingerUp[Boll](close)
    ema20 = ExponentialAverage[20](close)
    
    BearishEngulfing = CLOSE[1] > OPEN[1] AND OPEN > CLOSE[1] AND CLOSE < OPEN[1]
    BullishEngulfing = CLOSE[1] < OPEN[1] AND OPEN < CLOSE[1] AND CLOSE > OPEN[1]
    
    BearishHarami = CLOSE[1] > OPEN[1] and OPEN > CLOSE and OPEN <= CLOSE[1] and OPEN[1] <= CLOSE and OPEN - CLOSE < CLOSE[1] - OPEN[1]
    BullishHarami = OPEN[1] > CLOSE[1] and CLOSE > OPEN and CLOSE <= OPEN[1] and CLOSE[1] <= OPEN and CLOSE - OPEN < OPEN[1] - CLOSE[1]
    
    
    TweezerTop = ABS(HIGH -(HIGH[1]))<= HIGH * 0.0025
    TweezerBottom = ABS(LOW -(LOW[1]))<= LOW * 0.0025
    
    AboveUpperBand=close[1] > BolUp and open > BolUp
    BelowLowerBand=close[1] < BolDown and open < BolDown
    
    GoShort =((BearishEngulfing or BearishHarami or TweezerTop ) and AboveUpperBand)
    GoLong = ((BullishEngulfing or BullishHarami or TweezerBottom) and BelowLowerBand)
    
    
    if not longonmarket and GoLong then
    Buy n Contract at Market
    Endif
    
    c1 = (close > ema20)
    IF c4 THEN
    SELL AT MARKET
    ENDIF
    
    if not shortonmarket and GoShort then
    Sell n Contract at Market
    Endif
    
    c2 = (close < ema20)
    
    IF c2 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    Set Stop Ploss 20
    
    #31086 quote
    StantonR
    Participant
    Senior

    Please note this is far from a complete system but this is the basic automation

    #31089 quote
    CN
    Participant
    Senior

    Yes Stanton, I am a follower to your channel and i’ve linked to your video.

    Hope you don’t mind.

    Would love working with this system, I realy love the mean rev idea.

    #31090 quote
    StantonR
    Participant
    Senior

    Sorry Error in code

    DEFPARAM CUMULATEORDERS = false
    
    Boll = 20
    n = 1
    
    BolDown = BollingerDown[Boll](close)
    BolUp = BollingerUp[Boll](close)
    ema20 = ExponentialAverage[20](close)
    
    BearishEngulfing = CLOSE[1] > OPEN[1] AND OPEN > CLOSE[1] AND CLOSE < OPEN[1]
    BullishEngulfing = CLOSE[1] < OPEN[1] AND OPEN < CLOSE[1] AND CLOSE > OPEN[1]
    
    BearishHarami = CLOSE[1] > OPEN[1] and OPEN > CLOSE and OPEN <= CLOSE[1] and OPEN[1] <= CLOSE and OPEN - CLOSE < CLOSE[1] - OPEN[1]
    BullishHarami = OPEN[1] > CLOSE[1] and CLOSE > OPEN and CLOSE <= OPEN[1] and CLOSE[1] <= OPEN and CLOSE - OPEN < OPEN[1] - CLOSE[1]
    
    
    TweezerTop = ABS(HIGH -(HIGH[1]))<= HIGH * 0.0025
    TweezerBottom = ABS(LOW -(LOW[1]))<= LOW * 0.0025
    
    AboveUpperBand=close[1] > BolUp and open > BolUp
    BelowLowerBand=close[1] < BolDown and open < BolDown
    
    GoShort =((BearishEngulfing or BearishHarami or TweezerTop ) and AboveUpperBand)
    GoLong = ((BullishEngulfing or BullishHarami or TweezerBottom) and BelowLowerBand)
    
    
    if not longonmarket and GoLong then
    Buy n Contract at Market
    Endif
    
    c1 = (close > ema20)
    IF c1 THEN
    SELL AT MARKET
    ENDIF
    
    if not shortonmarket and GoShort then
    Sell n Contract at Market
    Endif
    
    c2 = (close < ema20)
    
    IF c2 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    Set Stop Ploss 20
    #31092 quote
    StantonR
    Participant
    Senior

    Hi CN its all good like I said thats why we do it.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Bollinger reversal robot


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
CN @christian_niehqvist Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by StantonR
8 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/05/2017
Status: Active
Attachments: No files
Logo Logo
Loading...