MQL4 Trend Indicator EA

ほとんどの取引システムはインジケーターを使用して取引シグナルを決定します。 Metatrader には、移動平均、MACD、RSI、ストキャスティクスなど、一般的に使用される 20 以上の指標が含まれています。 MQL ストックインジケーター機能を内蔵。 エキスパートアドバイザーでカスタムインジケーターを使用することもできます。 この MQL4 トレンド インジケーター EA の記事で、最も人気のあるトレンド インジケーターを使って取引するエキスパート アドバイザーをプログラムする方法を学びましょう。

トレンドインジケーター

移動平均は最もよく知られたトレンド指標です。 指標期間中に価格が上昇したか下落したかを示します。 移動平均クロスオーバーの条件を構築する方法について見てきました。 戦略のエントリーとエグジットに関する他のトレンド指標の条件を調べてみましょう。


MT4 コンソールに移動し、[挿入/インジケーター/トレンド] をクリックすると、次のインジケーターのリストが表示されます。

< br/>

平均方向指数

ボリンジャーバンド

商品チャネル指数

移動平均

パラボリックSAR

標準偏差

使用注意事项

カスタム EA にコードを挿入したい場合は、外部変数をコピーして外部変数セクションに貼り付けることができます。 次に、私のテンプレートをガイドとして使用して、インジケーター呼び出し変数を start() 関数のどこかにコピーして貼り付けます。これらのテンプレートの下に、売買条件をコピーして貼り付けることができます。 あるいは、各インジケーターに基づいて構築した EA をダウンロードして使用することもできます。


 

ParamsAverage Directional Index
Intent

//買い: +DI ラインが -DI ラインより高く、ADX が特定の値より大きい

成長 (つまり、トレンドが強化)

//売り: -D ライン+DI ラインより高い、ADX が特定の値より大きい

増加 (つまり、トレンドが強化)

Externextern int adx=0; //Indicator period
extern int adu=14; //Period of averaging for index calculation
extern double minadx=20; //Minimal threshold value of ADX
Indicator
Calling
PosDLine =iADX(NULL,adx,adu,PRICE_CLOSE,MODE_PLUSDI,0);
NegDLine =iADX(NULL,adx,adu,PRICE_CLOSE,MODE_MINUSDI,0);
ADXCurrent =iADX(NULL,adx,adu,PRICE_CLOSE,MODE_MAIN,0);
ADXPrevious =iADX(NULL,adx,adu,PRICE_CLOSE,MODE_MAIN,1);
BuyCondif (PosDLine > NegDLine && ADXCurrent >= minadx
&& ADXCurrent > ADXPrevious)
SellCondif (NegDLine > PosDLine && ADXCurrent >= minadx
&& ADXCurrent > ADXPrevious)

ParamsBollinger Band
Intent//Buy: price crossed lower line upwards (returned to it from below)
//Sell: price crossed upper line downwards (returned to it from above)
Externextern int bandp=0; //Indicator period
extern int bandpx=20; //Period of averaging for indicator calculation
extern int banddev=2; //Deviation from the main line
Indicator
Calling
BBLowCurrent=iBands(NULL,bandp, bandpx, banddev,0,PRICE_CLOSE,MODE_LOWER,0);
BBLowPrevious=iBands(NULL,bandp, bandpx, banddev,0,PRICE_CLOSE,MODE_LOWER,1);
BBUpCurrent=iBands(NULL,bandp, bandpx, banddev,0,PRICE_CLOSE,MODE_UPPER,0);
BBUpPrevious=iBands(NULL,bandp, bandpx, banddev,0,PRICE_CLOSE,MODE_UPPER,1);
BBCurrentClose = iClose (NULL, 0,0);
BBPreviousClose = iClose (NULL, 0,1);
BuyCondif (BBLowPrevious<BBPreviousClose
&& BBLowCurrent>=BBCurrentClose)
SellCondif (BBUpPrevious>BBPreviousClose
&& BBUpCurrent<=BBCurrentClose)

 Commodity Chanel Index
Intent//Buy: 1. indicator crosses +100 from below upwards. 2. Crossing -100 from below upwards. 3.
//Sell: 1. indicator crosses -100 from above downwards. 2. Crossing +100 downwards. 3.
Externextern int CCp=0; //Indicator period
extern int CCpx=14; //Period of averaging for indicator calculation
extern int CCLine = 100;
Indicator
Calling
CCCurrent = iCCI(NULL,CCp,CCpx,PRICE_TYPICAL,0);
CCPrevious = iCCI(NULL,CCp,CCpx,PRICE_TYPICAL,1);
CCCrossLinePos = CCLine;
CCCrossLineNeg =-CCLine;
BuyCondif ((CCPrevious<CCCrossLinePos && CCCurrent >= CCCrossLinePos) || (CCPrevious <=CCCrossLineNeg&& CCCurrent>=CCCrossLineNeg) )
SellCondif ((CCPrevious>CCCrossLinePos && CCCurrent <= CCCrossLinePos)||
(CCPrevious >=CCCrossLineNeg&& CCCurrent<=CCCrossLineNeg) )

 Parabolic Sar
Note//Buy: Parabolic SAR crosses price downwards
//Sell: Parabolic SAR crosses price upwards
Externextern int sar=0; //Indicator period
extern double sarstep=0.02; //Stop level increment
extern double sarstop=0.2; //Maximal stop level
extern int sar2=0; //Price period
Indicator
Calling
sarcurrent = iSAR(NULL,sar,sarstep,sarstop,0);
sarprevious = iSAR(NULL,sar,sarstep,sarstop,1);
closecurrent = iClose(NULL,0,0);
closeprevious = iClose(NULL,0,1);
BuyCondif (sarprevious>closeprevious&&sarcurrent<=closecurrent)
SellCondif (sarprevious<closeprevious&&sarcurrent>=closecurrent)

 MA Rising or Falling
Intent//Buy: MA grows
//Sell: MA falls
Externextern int maperiod=14; //Period of averaging for indicator calculation
extern int mamode = 1; // Type of moving average, 1= Exponential
Indicator
Calling
macurrent = iMA(NULL,0,maperiod,0,mamode,0);
maprevious = iMA(NULL,0,maperiod,0,mamode,1);
maprevious2 =iMA(NULL,0,maperiod,0,mamode,2);
BuyCondif(maprevious2 > maprevious && maprevious > macurrent)
SellCondif (maprevious2 < maprevious && maprevious < macurrent)