CNParticipant
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")
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
Please note this is far from a complete system but this is the basic automation
CNParticipant
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.
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
Hi CN its all good like I said thats why we do it.