Bollinger Strategy
Forums › ProRealTime English forum › ProOrder support › Bollinger Strategy
- This topic has 9 replies, 2 voices, and was last updated 8 years ago by Nicolas.
Tagged: Bollinger
-
-
03/06/2016 at 2:26 PM #3446
Hi, can somebody help me with my strategy. I need some modification to optimize it. The change that I need is to make it open a position only if it crosses the middle bollinger line before hand. Example: If I have an open long position and it hits target profit then it only opens a new long position if it crosses the middle bollinger line again, if the price still above the middle bollinger then it should stay inactive.
Sorry if my English is bad.
12345678910111213141516171819202122232425262728293031323334353637383940414243// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = ExponentialAverage[50](close)c1 = (close > indicator1)indicator2 = ExponentialAverage[50](close)+1.5*std[50](close)c2 = (high[7] >= indicator2)IF c1 AND c2 THENBUY 1 CONTRACT AT MARKETENDIF// Conditions to exit long positionsindicator3 = ExponentialAverage[50](close)-1.5*std[50](close)c3 = (low <= indicator3)IF c3 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator4 = ExponentialAverage[50](close)c4 = (close < indicator4)indicator5 = ExponentialAverage[50](close)-1.5*std[50](close)c5 = (low[7] <= indicator5)IF c4 AND c5 THENSELLSHORT 1 CONTRACT AT MARKETENDIF// Conditions to exit short positionsindicator6 = ExponentialAverage[50](close)+1.5*std[50](close)c6 = (high >= indicator6)IF c6 THENEXITSHORT AT MARKETENDIF// Stops and targetsset target %profit 0.403/06/2016 at 5:38 PM #345103/06/2016 at 7:37 PM #345403/07/2016 at 8:03 AM #3461Thanks for the reply, but that isn’t what I’m looking for. If I make those changes, then it will trigger an Entry only if it crosses the middle bollinger line and the second conditions kicks in. I need it to cross beforehand. So it will be like this:
Conditions:
- The price is over middle bollinger band
- Seven days before the high has to be over upper bollinger band
Enter Long.
- If previous position hits target/stop then enter only if the prise moves under the middle bollinger band, then up and condition 1 and 2 kicks in then go long again.
03/07/2016 at 10:18 AM #3479So your ‘c1’ condition need only to be tested once? At ProOrder strategy startup? If so, all you have to do is to “flag” your first trade with a variable and then make 2 different ‘c1’ conditions :
- first ‘c1’ : tradedbefore=0 so test only if “Close>EMA50”
- second ‘c1’ : tradedbefore=1 so test a crossover
03/12/2016 at 11:31 AM #360003/12/2016 at 12:27 PM #360103/14/2016 at 3:33 PM #3713Here is the final code, I have flagged the first trade with the “tradedbefore” variable set to 1 if a first trade has occurred. If then, the next trade would be taken only if the price crosses above or below the middle bollinger band (a moving average 50 periods in this case).
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedDEFPARAM preloadbars = 0once tradedbefore=0GRAPH tradedbefore as "tradedbefore"// Conditions to enter long positionsindicator1 = ExponentialAverage[50](close)if tradedbefore=0 thenc1 = (close > indicator1)elsif tradedbefore=1 thenc1 = close crosses over indicator1endifindicator2 = ExponentialAverage[50](close)+1.5*std[50](close)c2 = (high[7] >= indicator2)IF c1 AND c2 THENBUY 1 CONTRACT AT MARKETtradedbefore = 1ENDIF// Conditions to exit long positionsindicator3 = ExponentialAverage[50](close)-1.5*std[50](close)c3 = (low <= indicator3)IF c3 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator4 = ExponentialAverage[50](close)if tradedbefore=0 thenc4 = (close < indicator4)elsif tradedbefore = 1 thenc4 = close crosses under indicator4endifindicator5 = ExponentialAverage[50](close)-1.5*std[50](close)c5 = (low[7] <= indicator5)IF c4 AND c5 THENSELLSHORT 1 CONTRACT AT MARKETtradedbefore = 1ENDIF// Conditions to exit short positionsindicator6 = ExponentialAverage[50](close)+1.5*std[50](close)c6 = (high >= indicator6)IF c6 THENEXITSHORT AT MARKETENDIF// Stops and targetsset target %profit 0.403/15/2016 at 7:42 AM #372003/15/2016 at 12:38 PM #3766 -
AuthorPosts
Find exclusive trading pro-tools on