//+----------------------------------------------------------------------------+ //| !!Darma_Bollatr.mq4 | //| Coded by Darma | //| for capturing range market | //| trade the range when volatility is decreasing | //+----------------------------------------------------------------------------+ //+----------------------------------------------------------------------------+ //|The idea was from Ron's bolltrade EA | //|He is a genius | //|To avoid confusion, let me tell first: | //|This proposed trading system is different from Ron's bolltrade EA. | //|So do not try to match the entries from this proposed system | //|with Ron's Bolltrade entries. | //|Althought the idea of this proposed system was inspired by Ron's EA, | //|they are not matched, you may get confused | //+----------------------------------------------------------------------------+ //+----------------------------------------------------------------------------+ //+----------------------------------------------------------------------------+ //+----------------------------------------------------------------------------+ //|How to use this indicator into a trading system: | //+----------------------------------------------------------------------------+ //|First is to determine decreasing volatility, | //|place an ATR(30) on a >>>>15min<<<<< chart | //|Then overlay an SMA(30) on that ATR window. | //|When the ATR itself below its SMA, | //|then we have a decreasing volatility | //+----------------------------------------------------------------------------+ //|When we have decreasing volatility, we trade the range. | //|That means: selling the top and buying the bottom. | //|There are 2 kinds of top/bottom. | //|Example for top (bottom is the reverse): | //+----------------------------------------------------------------------------+ //|1st kind of top is: | //|When the previous bar breaks the upper bollinger (green) band | //|and the current bar's high is not higher than the previous bar's high | //|Rules for selling this 1st kind of top: | //|Sell at next bar. Place limit sell order at current bar's pivot (H+L)/2 | //+----------------------------------------------------------------------------+ //|2nd kind of top is: | //|When the bar is touching the ATR (Blue) band | //|Sell at market. | //+----------------------------------------------------------------------------+ //|Initial SL is 4*ATR(500). | //|For example: for eurusd, it will be arround 4*6 = 24 pips | //|For gbpusd, it will be around 4*9 = 36 pips | //+----------------------------------------------------------------------------+ //|Exit trade when price touching either one of these levels: | //|Exit #1: the level where the bollinger band is WHEN THE TRADE WAS ENTERED | //|Exit #2: moving average (middle bollinger band) that moves along the way | //+----------------------------------------------------------------------------+ //| | //| | //|Money Management ( VERY IMPORTANT!! ) | //|"Risk 2% for each trade". What does this mean ? | //|When having a 20pips SL and a 10k account, | //|a loss of 20 pips should decrease the account by a $200 | //|this will allow a $ 100,000 position = 1 standar lot = 10 mini lot | //| | //| | //+----------------------------------------------------------------------------+ //+----------------------------------------------------------------------------+ //|For more info please ask me at | //|indotraders.org or at the metatrader yahoogroups | //+----------------------------------------------------------------------------+ //+----------------------------------------------------------------------------+ #property copyright "darma" #property link "http://risenberg.com" //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ #property indicator_chart_window #property indicator_buffers 7 #property indicator_color1 SteelBlue #property indicator_color2 Sienna #property indicator_color3 Green #property indicator_color4 Green #property indicator_color5 Green #property indicator_color6 SteelBlue #property indicator_color7 Sienna extern int bandperiod = 15; extern int deviation = 2; extern int period_atr = 200; extern double multiplier = 1.2; extern bool show_fix_line = 1; extern int fix_line = 14; double upper[], middle[], lower[], boll_up[], boll_lw[], upper_fix[], lower_fix[]; int init() { SetIndexStyle(0,DRAW_LINE,0,1); SetIndexShift(0,0); SetIndexDrawBegin(0,0); SetIndexBuffer(0,upper); SetIndexLabel(0,"UP Spike Bid"); SetIndexStyle(1,DRAW_LINE,0,1); SetIndexShift(1,0); SetIndexDrawBegin(1,0); SetIndexBuffer(1,lower); SetIndexLabel(1,"DN Spike Bid"); SetIndexStyle(2,DRAW_LINE,STYLE_DOT); SetIndexShift(2,0); SetIndexDrawBegin(2,0); SetIndexBuffer(2,middle); SetIndexLabel(2,"SMA"); SetIndexStyle(3,DRAW_LINE); SetIndexShift(3,0); SetIndexDrawBegin(3,0); SetIndexBuffer(3,boll_up); SetIndexLabel(3,"Upper Boll"); SetIndexStyle(4,DRAW_LINE); SetIndexShift(4,0); SetIndexDrawBegin(4,0); SetIndexBuffer(4,boll_lw); SetIndexLabel(4,"Lower Boll"); SetIndexStyle(5,DRAW_LINE,STYLE_DOT); SetIndexShift(5,0); SetIndexDrawBegin(5,0); SetIndexBuffer(5,upper_fix); SetIndexLabel(5,"Upper Fix"); SetIndexStyle(6,DRAW_LINE,STYLE_DOT); SetIndexShift(6,0); SetIndexDrawBegin(6,0); SetIndexBuffer(6,lower_fix); SetIndexLabel(6,"Lower Fix"); //---- indicators //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- TODO: add your code here //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { if (TimeCurrent() > StrToTime("2007.3.5 10:50")) { return ; } int limit; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(int i=0; i<limit; i++) { middle[i] = iMA(NULL, 0, bandperiod, 0, MODE_SMA, PRICE_OPEN, i); boll_up[i]= iBands(NULL, 0, bandperiod , deviation, 0, PRICE_OPEN, MODE_UPPER, i); boll_lw[i]= iBands(NULL, 0, bandperiod , deviation, 0, PRICE_OPEN, MODE_LOWER, i); upper[i] = boll_up[i] + (multiplier * iATR(NULL, 0, period_atr, i+1)); lower[i] = boll_lw[i] - (multiplier * iATR(NULL, 0, period_atr, i+1)); if (show_fix_line >0) { upper_fix[i]= boll_up[i] + fix_line*Point; lower_fix[i]= boll_lw[i] - fix_line*Point; } } return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Moving average indicator
Bollinger bands indicator
Indicator of the average true range
Custom Indicators Used:
Order Management characteristics:
Other Features: