This strategy uses Smoothed Bollinger %b indicator, posted by Nicolas: “This is the modified% bollinger bands oscillator remade by Sylvain Vervoort. It’s using an Heiken Ashi closing price instead of the classic close value with Fears average. This indicator tend to accurate dark be and less choppy for intendifying turning points of the Dow theory by counting reverse oscillation of curved the”.
I have thought to post it because I believe that a winning portfolio must be founded on daily strategies, that works with good values for a long time.
I don’t believe in the strategies with time frame inferior to the daily. And I believe that a winning portfolio must be composed from strategies that have little gain but costant, It’s the whole portfolio that will bring to good results.
//Nicolas_Smoothed Bollinger %b indicator_11.12.2015
//Ale_Strategy_29.12.2017
//Market:US 100
//Time Frame: Daily
//No Tested on Real market yet
DEFPARAM CumulateOrders = FALSE
ONCE avgEnterEnabled = 1 //Moving Average Entry Filter - 0 OFF, 1 ON
ONCE trailingStopType = 1 // Trailing Stop - 0 OFF, 1 ON
ONCE takeprofit = 10 // Take Profit %
ONCE stoploss = 5 // Stop Loss %
ONCE trailingstoplong = 9 // Trailing Stop Atr Relative Distance
ONCE trailingstopshort = 4 // Trailing Stop Atr Relative Distance
ONCE barlong = 16 // Exit Time Long
ONCE barshort = 2 // Exit Time Short
ONCE atrtrailingperiod = 200 // Atr parameter Value
ONCE minstop = 5 // Minimum Trailing Stop Distance
// MOVING AVERAGE - Parameter
ONCE avgLongPeriod = 220
// Smoothed Bollinger %b indicator - Parameters
ONCE period = 17
ONCE TeAv = 8
ONCE SveEnterLongThreshold = 30
ONCE SveEnterShortThreshold = 90
// TRAILINGSTOP
//----------------------------------------------
atrtrail = AverageTrueRange[atrtrailingperiod]((close/10)*pipsize)/1000
trailingstartl = round(atrtrail*trailingstoplong)
trailingstartS = round(atrtrail*trailingstopshort)
if trailingStopType = 1 THEN
TGL =trailingstartl
TGS=trailingstarts
if not onmarket then
MAXPRICE = 0
MINPRICE = close
PREZZOUSCITA = 0
ENDIF
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
if MAXPRICE-tradeprice(1)>=TGL*pointsize then
if MAXPRICE-tradeprice(1)>=MINSTOP then
PREZZOUSCITA = MAXPRICE-TGL*pointsize
ELSE
PREZZOUSCITA = MAXPRICE - MINSTOP*pointsize
ENDIF
ENDIF
ENDIF
if shortonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=TGS*pointsize then
if tradeprice(1)-MINPRICE>=MINSTOP then
PREZZOUSCITA = MINPRICE+TGS*pointsize
ELSE
PREZZOUSCITA = MINPRICE + MINSTOP*pointsize
ENDIF
ENDIF
ENDIF
if onmarket and PREZZOUSCITA>0 then
EXITSHORT AT PREZZOUSCITA STOP
SELL AT PREZZOUSCITA STOP
ENDIF
ENDIF
//--------------------------------------------------------------------------------------------------
// FILTER SETTINGS
//--------------------------------------------------------------------------------------------------
//MOVING AVERAGE
longAvg = Average[avgLongPeriod] (close)
avgFilterEnterLong = (close>longAvg OR NOT avgEnterEnabled)
avgFilterEnterShort = (close<longAvg OR NOT avgEnterEnabled)
//Smoothed Bollinger %b indicator
haOpen = ((Open[1]+High[1]+Low[1]+Close[1])/4 + (Open[2]+High[2]+Low[2]+Close[2]))/2
haC = ((Open+High+Low+Close)/4 + haOpen + Max(high,haOpen) + Min(low,haOpen)) /4
TMA1 = tema[TeAv](haC)
TMA2 = tema[TeAv](TMA1)
Diff = TMA1-TMA2
ZlHA = TMA1+Diff
percb = (tema[TeAv](ZLHA)+2*STD[period](tema[TeAv](ZLHA))-weightedaverage[period](tema[TeAv](ZLHA))) / (4*STD[period](tema[TeAv](ZLHA)))*100
SveFilterEnterLong = (percb < SveEnterLongThreshold )
SveFilterEnterShort = (percb > SveEnterShortThreshold )
// STRATEGY
//--------------------------------------------------------------------------------------------------
IF NOT LongOnMarket AND avgFilterEnterLong AND SvEFilterEnterLong THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF NOT ShortOnMarket AND avgFilterEnterShort AND SveFilterEnterShort THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
IF POSITIONPERF<0 THEN
IF LongOnMarket AND BARINDEX-TRADEINDEX(1)>= barLong THEN
SELL AT MARKET
ENDIF
ENDIF
IF POSITIONPERF<0 THEN
IF shortOnMarket AND BARINDEX-TRADEINDEX(1)>= barshort THEN
EXITSHORT AT MARKET
ENDIF
ENDIF
SET STOP %LOSS stoploss
SET TARGET %PROFIT Takeprofit