Step 1.
create SimpleSMACrossover file in expert folder and
Step 2. copy paste code given below on your SimpleSMACrossover file :
//code start
void OnTick()
{
//current chart, current period, 20 candles, No shift, simple , close price
double SlowMovingAverage = iMA (NULL,0,20,0,MODE_SMA,PRICE_CLOSE,0);
//current chart, current period, 20 candles, No shift, simple , close price
double LastSlowMovingAverage = iMA (NULL,0,20,0,MODE_SMA,PRICE_CLOSE,1);
//current chart, current period, 10 candles, No shift, simple , close price
double FastMovingAverage = iMA (NULL,0,10,0,MODE_SMA,PRICE_CLOSE,0);
//current chart, current period, 10 candles, No shift, simple , close price
double LastFastMovingAverage = iMA (NULL,0,10,0,MODE_SMA,PRICE_CLOSE,1);
//if the fast SMA is now above
if ((LastFastMovingAverage < LastSlowMovingAverage) && (FastMovingAverage > SlowMovingAverage))
//chart output for BUY signal
Comment ("BUY");
//if the fast SMA is now above
if ((LastFastMovingAverage > LastSlowMovingAverage) && (FastMovingAverage < SlowMovingAverage))
//chart output for SELL signal
Comment ("SELL");
}
//+------------------------------------------------------------------+
//code end
Step 3.
Now open MT4 and go to :
Insert >> Indicator >> Moving Average
Set parameter : Period : 10 , shift : 0 , MA Method : Simple , Apply to : close , style : Yellow then OK
repeate again
Insert >> Indicator >> Moving Average
Set parameter : Period : 20 , shift : 0 , MA Method : Simple , Apply to : close , style : Red 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.
View signal on left side on top in your chart.
No comments:
Post a Comment