MetaTrader初心者専用スレat LIVEMARKET2
MetaTrader初心者専用スレ - 暇つぶし2ch300:Trader@Live!
07/12/25 21:29:53.50 WfduRII2
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence |
//+------------------------------------------------------------------+
int start()
{
int limit;

double OsMANow, OsMAPrevious;
static datetime prevtime = 0;

int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
for(int i=0; i<limit; i++)
ind_buffer1[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//---- signal line counted in the 2-nd buffer
for(i=0; i<limit; i++)
ind_buffer2[i]=iMAOnArray(ind_buffer1,Bars,SignalSMA,0,MODE_SMA,i);
for(i=0; i<limit; i++)
ind_buffer3[i]=iOsMA(NULL,0,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,i);
//---- done
// ======= Alert =========
if(AlertOn)
{
if(prevtime == Time[0])
{
return(0);
}
prevtime = Time[0];

OsMANow = iOsMA(NULL, 0, FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE, 0);
OsMAPrevious = iOsMA(NULL, 0, FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE, 1);

if((OsMANow < 0) && (OsMAPrevious > 0)) {
Alert(Symbol(), " M", Period(), " OsMA has crossed below zero");
}

if((OsMANow > 0) && (OsMAPrevious < 0)) {
Alert(Symbol(), " M", Period(), " OsMA has crossed above zero");
}
IndicatorShortName("MACD("+FastEMA+","+SlowEMA+","+SignalSMA+") (Alert on)");
}
// ======= Alert Ends =========
return(0);
}


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch