//+---------------------------------------------------------------------------------+ //+ RSI_Signal.mq4 + //+ Индикатор сигналов при пересечении RSI уровня 50 + //+ + //+ Внешние параметры: + //+ ExtPeriodRSI - период RSI + //+ ExtPriceRSI - цена RSI + //+ Цены: 0 = Close, 1 = Open, 2 = High, 3 = Low, 4 = HL/2, 5 = HLC/3, 6 = HLCC/4 + //+---------------------------------------------------------------------------------+ #property copyright "Copyright 2009, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" //---- Определение индикаторов #property indicator_chart_window #property indicator_buffers 3 //---- Цвета #property indicator_color1 Magenta #property indicator_color2 Blue //---- Параметры extern int ExtPeriodRSI = 21; extern int ExtPriceRSI = 0; // 0 = Close, 1 = Open, 2 = High, 3 = Low, 4 = HL/2, 5 = HLC/3, 6 = HLCC/4 extern string ExtSoundFileName = ""; extern bool ActiveSignal=true; extern double NormalizeAccuracy = 0.0000; //---- Буферы double RSI[]; double CrossUp[]; double CrossDown[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- Установка параметров прорисовки // Сигналы SetIndexStyle( 2, DRAW_ARROW, EMPTY ); SetIndexArrow( 2, 233 ); SetIndexStyle( 3, DRAW_ARROW, EMPTY ); SetIndexArrow( 3, 234 ); //---- Задание буферов SetIndexBuffer( 1, RSI ); SetIndexBuffer( 2, CrossUp ); SetIndexBuffer( 3, CrossDown ); IndicatorDigits( MarketInfo( Symbol(), MODE_DIGITS ) ); //---- Название и метки IndicatorShortName ( "RSI"); SetIndexLabel ( 1, "Buy" ); SetIndexLabel ( 2, "Sell" ); return ( 0 ); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { static bool bBuy = False; static bool bSell = False; bool bConditionUp; bool bConditionDown; double Range; double AvgRange; int iLimit; int i; int counter; 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--; iLimit = Bars - counted_bars; for ( i = 0; i <= iLimit; i++ ) { RSI[i] = iRSI( NULL, ExtPeriodRSI, 0, ExtPriceRSI, i ); } for ( i = 1; i <= iLimit; i++ ) { AvgRange = 0; for ( counter = i; counter <= i + 9; counter++ ) { AvgRange += MathAbs( High[ counter ] - Low[ counter ] ); } Range = AvgRange/10; bConditionUp = ( RSI[i-1] <= 50 ) && ( RSI[i] >= 50 ) && ( RSI[i+1] >= RSI[i] )&& // пересечение вверх ( NormalizeDouble(RSI[i-1]- RSI[i+1],4)>=NormalizeAccuracy); bConditionDown = ( RSI[i-1] >= 50 ) && ( RSI[i] <= 50 ) && ( RSI[i+1] < RSI[i] )&& // пересечение вниз ( NormalizeDouble(RSI[i+1]- RSI[i-1],4)>=NormalizeAccuracy); if ( bConditionUp ) CrossUp[i] = Low[i] - Range * 0.5; else if ( bConditionDown ) CrossDown[i] = High[i] + Range * 0.5; if ( !bBuy && bConditionUp ) { // Флаги bBuy = True; // установка флага покупки bSell = False; // сброс флага продажи if ( i < 2 && ActiveSignal == True ) { Alert (Symbol()," ",Period(),"M RSI_Signal Achtung BUY "); // звуковой сигнал if ( ExtSoundFileName != "" ) PlaySound( ExtSoundFileName ); } } else if ( !bSell && bConditionDown ) { // Флаги bSell = True; // установка флага продажи bBuy = False; // сброс флага покупки if ( i < 2 && ActiveSignal == True) { CrossDown[i] = High[i] + Range * 0.5; Alert (Symbol()," ",Period(),"M RSI_Signal Achtung SELL "); // звуковой сигнал if ( ExtSoundFileName != "" ) PlaySound( ExtSoundFileName ); } } } return ( 0 ); }
так красивее!
кажись у тя цикл с алертом не запускается!
выведи в принте значение всего на что ты опираешься и те всё станет ясно!

Вы упускаете торговые возможности:
- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Регистрация
Вход
Вы принимаете политику сайта и условия использования
Если у вас нет учетной записи, зарегистрируйтесь
Добрый день.
Написал по аналогии с другим индикатором нужный мне.
Компилируется без ошибок, но Алерты не отображаются и не звучат.
Я не силен в MQL.
Если есть возможность и желание, помогите !!!
Алерт ( звук, окно и стрелка ) должен появляться с первым тиком нового бара.
Заранее, СПАСИБО.
Выкладываю Листинг программы. Что б не качали, не ставили и не компилировали.
ИМХО, так вам нагляднее.
//+---------------------------------------------------------------------------------+
//+ RSI_Signal.mq4 +
//+ Индикатор сигналов при пересечении RSI уровня 50 +
//+ +
//+ Внешние параметры: +
//+ ExtPeriodRSI - период RSI +
//+ ExtPriceRSI - цена RSI +
//+ Цены: 0 = Close, 1 = Open, 2 = High, 3 = Low, 4 = HL/2, 5 = HLC/3, 6 = HLCC/4 +
//+---------------------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//---- Определение индикаторов
#property indicator_chart_window
#property indicator_buffers 3
//---- Цвета
#property indicator_color1 Magenta
#property indicator_color2 Blue
//---- Параметры
extern int ExtPeriodRSI = 21;
extern int ExtPriceRSI = 0; // 0 = Close, 1 = Open, 2 = High, 3 = Low, 4 = HL/2, 5 = HLC/3, 6 = HLCC/4
extern string ExtSoundFileName = "";
extern bool ActiveSignal=true;
extern double NormalizeAccuracy = 0.0000;
//---- Буферы
double RSI[];
double CrossUp[];
double CrossDown[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- Установка параметров прорисовки
// Сигналы
SetIndexStyle( 2, DRAW_ARROW, EMPTY );
SetIndexArrow( 2, 233 );
SetIndexStyle( 3, DRAW_ARROW, EMPTY );
SetIndexArrow( 3, 234 );
//---- Задание буферов
SetIndexBuffer( 1, RSI );
SetIndexBuffer( 2, CrossUp );
SetIndexBuffer( 3, CrossDown );
IndicatorDigits( MarketInfo( Symbol(), MODE_DIGITS ) );
//---- Название и метки
IndicatorShortName ( "RSI");
SetIndexLabel ( 1, "Buy" );
SetIndexLabel ( 2, "Sell" );
return ( 0 );
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
static bool bBuy = False;
static bool bSell = False;
bool bConditionUp;
bool bConditionDown;
double Range;
double AvgRange;
int iLimit;
int i;
int counter;
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--;
iLimit = Bars - counted_bars;
for ( i = 0; i <= iLimit; i++ ) {
RSI[i] = iRSI( NULL, ExtPeriodRSI, 0, ExtPriceRSI, i );
}
for ( i = 1; i <= iLimit; i++ ) {
AvgRange = 0;
for ( counter = i; counter <= i + 9; counter++ ) {
AvgRange += MathAbs( High[ counter ] - Low[ counter ] );
}
Range = AvgRange/10;
bConditionUp = ( RSI[i-1] <= 50 ) &&
( RSI[i] >= 50 ) &&
( RSI[i+1] >= RSI[i] )&& // пересечение вверх
( NormalizeDouble(RSI[i-1]- RSI[i+1],4)>=NormalizeAccuracy);
bConditionDown = ( RSI[i-1] >= 50 ) &&
( RSI[i] <= 50 ) &&
( RSI[i+1] < RSI[i] )&& // пересечение вниз
( NormalizeDouble(RSI[i+1]- RSI[i-1],4)>=NormalizeAccuracy);
if ( bConditionUp )
CrossUp[i] = Low[i] - Range * 0.5;
else if ( bConditionDown )
CrossDown[i] = High[i] + Range * 0.5;
if ( !bBuy && bConditionUp ) {
// Флаги
bBuy = True; // установка флага покупки
bSell = False; // сброс флага продажи
if ( i < 2 && ActiveSignal == True ) {
Alert (Symbol()," ",Period(),"M RSI_Signal Achtung BUY "); // звуковой сигнал
if ( ExtSoundFileName != "" )
PlaySound( ExtSoundFileName );
}
}
else if ( !bSell && bConditionDown ) {
// Флаги
bSell = True; // установка флага продажи
bBuy = False; // сброс флага покупки
if ( i < 2 && ActiveSignal == True) {
CrossDown[i] = High[i] + Range * 0.5;
Alert (Symbol()," ",Period(),"M RSI_Signal Achtung SELL "); // звуковой сигнал
if ( ExtSoundFileName != "" )
PlaySound( ExtSoundFileName );
}
}
}
return ( 0 );
}