Friday, July 6, 2018

BOLLINGER BANDS SIGNAL

Step 1.
create bollingerbandsignal file in expert folder and

Step 2. copy paste code given below on your bollingerbandsignal file :
//code start

void OnTick()
{
//create an empty string for the single
string signal="";
//symbol, period,20 candles, deviation 2, no shift, close price, candle
double LowerBB=iBands(_Symbol,_Period,20,2,0,PRICE_CLOSE,MODE_LOWER,1); 
double UpperBB=iBands(_Symbol,_Period,20,2,0,PRICE_CLOSE,MODE_UPPER,1);
// calculate the candle before
double PrevLowerBB=iBands(_Symbol,_Period,20,2,0,PRICE_CLOSE,MODE_LOWER,2);
double PrevUpperBB=iBands(_Symbol,_Period,20,2,0,PRICE_CLOSE,MODE_UPPER,2);
// if price is above the last close
if (Ask>Close[1])
//if close2 was below lower band
if (Close[2]<PrevLowerBB)
//if close1 was above lower band
if (Close[1]>LowerBB)
{
signal="BUY";
}
// if price is bellow the last close
if (Bid<Close[1])
// if close2 was above upper band
if (Close[2]>PrevUpperBB)
// if close is below upper band
if (Close[1]<UpperBB)
{
signal="SELL";
}
//Output the signal on the chart
Comment("Current Signaal is :",signal);
}

//+------------------------------------------------------------------+
//code end

Step 3.
Now open MT4 and go to :
Insert >> Indicator >> Trand >> Bollinger Bands 
Set parameter : Period : 20 , shift : 0 , Deviation 2 , Apply to : close , style : Yellow then OK

Step 4.
Now open MT4 and go to :
Charts >> Template >> save template >> save file as tester.tpl.

Step5.
Now open MT4 and go to :
View >> strategy test : 
set your symbol
Use date
Visual Mode
Start

Step6.
3 to 5 signal View on left side on top on your chart.in a day