MQL4 Oscillator Indicator EA

Một loại chỉ báo khác là bộ dao động. Các chỉ báo dao động được vẽ trong các cửa sổ riêng biệt và chúng dao động giữa mức giá cao nhất và mức giá thấp nhất. Chúng tập trung vào trục trung hòa (thường là 0) hoặc bị giới hạn bởi giới hạn trên hoặc dưới (chẳng hạn như 0 và 100).


Các ví dụ về bộ dao động bao gồm động lượng, ngẫu nhiên và RSI. Tìm hiểu cách lập trình Expert Advisor để giao dịch với các bộ dao động phổ biến nhất trong bài viết EA Chỉ báo dao động MQL4 này.


Chỉ báo dao động cho biết mức quá mua và quá bán. Mặc dù chúng có thể được sử dụng làm chỉ báo xu hướng nhưng chúng thường được sử dụng để xác định các khu vực sẽ bị đảo chiều. Chúng được sử dụng để tạo ra tín hiệu ngược xu hướng.

 MACD(1)
< strong>Ghi chú

//Mua: MACD tăng trên đường tín hiệu

//Bán: MACD giảm xuống dưới đường tín hiệu

Externint fastmacd=12; //Averaging period for calculation of a quick MA

extern int slowmacd=26; //Averaging period for calculation of a slow MA

extern int signalmacd=9; //Averaging period for calculation of a signal line

Indicator
Calling
macdmaincurr=iMACD(NULL,0,fastmacd,slowmacd,signalmacd,0,MODE_MAIN,0);
macdmainprev=iMACD(NULL,0,fastmacd,slowmacd,signalmacd,0,MODE_MAIN,1);
macdsigcurr=iMACD(NULL,0,fastmacd,slowmacd,signalmacd,0,MODE_SIGNAL,0);
macdsigprev=iMACD(NULL,0,fastmacd,slowmacd,signalmacd,0,MODE_SIGNAL,1);
BuyCondif (macdmainprev < <macdsignalprevious&&macdmaincurrent>macdsignalprev && macdmaincurr >= macdsignalcurr)
</macdsignalprevious&&macdmaincurrent>
SellCondif (macdmainprev > macdsignalprev && macdmaincurr <=macdsignalcurr)

 

 MACD(2)
Note//Buy: crossing 0 upwards

//Sell: crossing 0 downwards

Externint fastmacd=12; //Averaging period for calculation of a quick MA

extern int slowmacd=26; //Averaging period for calculation of a slow MA

extern int signalmacd=9; //Averaging period for calculation of a signal line

Indicator
Calling
macdmaincurr=iMACD(NULL,0,fastmacd,slowmacd,signalmacd,0,MODE_MAIN,0);
macdmainprev=iMACD(NULL,0,fastmacd,slowmacd,signalmacd,0,MODE_MAIN,1);
macdsigcurr=iMACD(NULL,0,fastmacd,slowmacd,signalmacd,0,MODE_SIGNAL,0);
macdsigprev=iMACD(NULL,0,fastmacd,slowmacd,signalmacd0,MODE_SIGNAL,1);
BuyCondif (macdmainprev < 0<macdsignalprevious&&macdmaincurrent> && macdmaincurr >= 0)
</macdsignalprevious&&macdmaincurrent>
SellCondif (macdmainprev > 0 && macdmaincurr <= 0)

 

 RSI
Note//Buy: crossing 30 upwards

//Sell: crossing 70 downwards

Externrsiu = 14; // averaging period
lowerband = 30;
upperband = 70;
Indicator
Calling
rsicurrent=iRSI(NULL,0,rsiu,PRICE_CLOSE,0);
rsiprevious=iRSI(NULL,0,rsiu,PRICE_CLOSE,1);
BuyCondif (rsiprevious<lowerband&&rsicurrent>=lowerband)
SellCondif (rsiprevious>upperband&&rsicurrent<=upperband)

 

 Stochastics Occilator(1)
Note//Buy: main line rises above 20 after it fell below this point

//Sell: main line falls lower than 80 after it rose above this point

Externstok = 5; // Period(amount of bars) for the calculation of %K line
stod = 3; //Averaging period for the calculation of %D line
stslow =3; // Value of slowdown
mamode = 1;
lowerband = 20;
upperband = 80;
Indicator
Calling
stocurrent=iStochastic(NULL,0,stok,stod,stslow,mamode,0,MODE_MAIN,0);
stoprevious=iStochastic(NULL,0,stok,stod,stslow,mamode,0,MODE_MAIN,1);
BuyCondif (stoprevious<lowerband&&stocurrent>=lowerband)
SellCondif (stoprevious>upperband&&stocurrent<=upperband)

 

 Stochastics Occilator(2)
Note//Buy: main line goes above the signal line
//Sell: signal line goes above the main line
Externstok = 5; // Period(amount of bars) for the calculation of %K line
stod = 3; //Averaging period for the calculation of %D line
stslow =3; // Value of slowdown
mamode = 1;
lowerband = 20;
upperband = 80;
Indicator
Calling
stomaincurr=iStochastic(NULL,0,stok,stod,stslow,mamode,0,MODE_MAIN,0);
stomainprev=iStochastic(NULL,0,stok,stod,stslow,mamode,0,MODE_MAIN,1);
stosignalcurr=iStochastic(NULL,0,stok,stod,stslow,mamode,0,MODE_SIGNAL,0);
stosignalprev=iStochastic(NULL,0,stok,stod,stslow,mamode,0,MODE_SIGNAL,1);
BuyCondif (stomainprev<stosignalprev&&stomaincurr>=stosignalcurr)
SellCondif (stomainprev>stosignalprev&&stomaincurr<=stosignalcurr)

 

 Williams % Range
Note//Buy: crossing -80 upwards

//Sell: crossing -20 downwards

Externwillperiod = 14; // averaging period
lowerband = -20;
upperband = -80;
Indicator
Calling
willcurrent=iWPR(NULL,0,willperiod,0);
willprevious=iWPR(NULL,0,willperiod,1);
BuyCondif (willprevious<upperband>willcurrent>= upperband)
SellCondif (willprevious>lowerband&&willcurrent<=lowerband)

 

 Force Index
Note/Flag 14 is 1, when FI recommends to buy (i.e. FI<0)

//Flag 14 is -1, when FI recommends to sell (i.e. FI>0)

Externforceu = 2; // averaging period
Indicator
Calling
forcecurrent=iForce(NULL,0,forceu,MODE_SMA,PRICE_CLOSE,0);
BuyCondif (forcecurrent<0)
SellCondif (forcecurrent>0)