//+------------------------------------------------------------------+ //| SimpleRSI&MA.mq4 | //| Copyright(c) 2010 Masaru Sasaki | //| | //+------------------------------------------------------------------+ // // 「免責事項」 // *このプログラムに基づく行為の結果発生した障害、損失などについて // 著作者は一切の責任を負いません。 // // 「説明」 // *RSI値とRSI値を移動平均した値を表示します。 // 期間の標準設定は、14となっております。 // 二つの線のクロスが売買判断となっています。 // 又、移動平均線の種類はSMA、価格は終値です。 // プログラミングの練習用に作成した為、不備があると思いますので、 // 使用する場合は設定等ご注意下さい。 // // 参考書籍:FXメタトレーダー入門 PanRolling // #property copyright "Copyright(c) 2010 Masaru Sasaki" #property link "http://www.metaquotes.net" #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Red #property indicator_color2 Cyan #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_level1 30 #property indicator_level2 70 // 指標バッファ double RSI_Buf[]; double RSI_MA_Buf[]; // 期間 extern int RSI_period = 14; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { // 指標バッファの割り当て SetIndexBuffer(0, RSI_Buf); SetIndexBuffer(1, RSI_MA_Buf); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); int i; int limit = Bars - IndicatorCounted(); if( counted_bars == 0 ) limit = limit - RSI_period - 1; // RSI値の計算 for( i = limit-1; i >= 0; i-- ){ RSI_Buf[i] = iRSI(NULL, 0, RSI_period,PRICE_CLOSE, i); } if( counted_bars == 0 ) limit = limit - RSI_period - 1; // RSI移動平均値の計算 for( i = limit-1; i >= 0; i-- ){ RSI_MA_Buf[i] = iMAOnArray(RSI_Buf, 0, RSI_period, 0, MODE_SMA, i); } return(0); } //+------------------------------------------------------------------+