English
中文
日本語
ID
Vietnam
한국어
Filipino
 
   学院导航

MQL4 震荡指标 EA

MQL4 Oscillator Indicator EA

另一种指标是震荡指标。 震荡指标在单独的窗口中绘制,它们在高价和低价极值之间震荡。 它们以中性轴(通常为 0)为中心,或者以上限或下限(例如 0 和 100)为界。


震荡指标的例子包括动量、随机指标和 RSI。 在这篇 MQL4 振荡器指标 EA 文章中了解如何对 Expert Advisor 进行编程以使用最流行的振荡器进行交易。


振荡器指示超买和超卖水平。 虽然它们可以用作趋势指标,但它们通常用于定位待逆转的区域。 这些用于产生反趋势信号。

 MACD(1)
笔记

//买入:MACD 上升到信号线上方

//卖出:MACD跌破信号线

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)