So I recently got the idea of using Bollinger Bands in conjunction with the 200MA to identify a trend. I found that during choppy periods on when a market is consolidating the 200MA tends to stay within the Bollinger Bands. Once the Bollinger Bands clear the 200MA I enter a position on the first pullback to the 20MA.
Exits are triggered on the first pullback to the 20MA once a close beyond the 50MA is registered.
I also added a plain SL and TP, this can be optimized along with the Deviations variable
The included example is based on EURUSD 15min with a spread of 0.8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
Defparam cumulateorders = False Defparam preloadbars = 300 CurvePeriod = 250 Type = 0 Capital = 10000 Equity = Capital + StrategyProfit EquityCurve = Average[CurvePeriod,Type](Equity) possize = 1 MA20 = Average[20](close) MA50 = Average[50](close) MA200 = Average[200](close) Deviations = 2.4 PER = 42//Periods PRICE = LOG(customclose) alpha = 2/(PER+1) if barindex < PER then EWMA = AVERAGE[3](PRICE) else EWMA = alpha * PRICE + (1-alpha)*EWMA endif error = PRICE - EWMA dev = SQUARE(error) if barindex < PER+1 then var = dev else var = alpha * dev + (1-alpha) * var endif ESD = SQRT(var) BollU = EXP(EWMA + (DEVIATIONS*ESD)) BollL = EXP(EWMA - (DEVIATIONS*ESD)) once LT = 0 once ST = 0 If LT = 1 and BollL < MA200 Then LT = 0 ElsIf ST = 1 and BollU > MA200 Then ST = 0 EndIf If countofposition = 0 and (barindex < curveperiod or (barindex > curveperiod and equity >= equitycurve)) and LT = 0 and BollL > MA200 and close <= MA20 Then Buy possize contract at market LT = 1 LE = 0 ElsIf countofposition = 0 and (barindex < curveperiod or (barindex > curveperiod and equity >= equitycurve)) and ST = 0 and BollU < MA200 and close >= MA20 Then Sellshort possize contract at market ST = 1 SE = 0 EndIf If longonmarket and LE = 0 and close > MA20 Then LE = 1 ElsIf shortonmarket and SE = 0 and close < MA20 Then SE = 1 EndIf If longonmarket and LE = 2 and close > MA20 Then Sell at market ElsIf shortonmarket and SE = 2 and close < MA20 Then Exitshort at market ElsIf longonmarket and LE = 1 and close < MA50 Then LE = 2 ElsIf shortonmarket and SE = 1 and close > MA50 Then SE = 2 EndIf SET STOP $Loss 40*possize SET TARGET $PROFIT 130*possize |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
This gets me thinking about creating a strategy on the 5min timeframe that only takes trades in the direction of the trend when the 200MA is clear of the Bollinger on the 1 hour (or above) timeframe. This should drastically improve your odds of trading into the direction of a strong trend. Still eagerly waiting for multi timeframe support
I noted above does okay on DAX 10 min with even a reduction to 30 of the Stop Loss.
I’ve set it going, I’ll let you know how it goes.
Thank You
GraHal
Hi Grahal,
What about making the same great work you did with the snipet on google doc but with strategies performance on different asset?
Wouldn’t it be a great way to discard some strategies ?
Best,
Chris