Indicators Used
Miscellaneous
2
Views
1
Downloads
0
Favorites
Turn_Area_Alert
//+------------------------------------------------------------------+
//| Turn Area Alert.mq4 |
//| Yuriy Tokman (YTG) |
//| yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman (YTG)"
#property link "yuriytokman@gmail.com"
#property version "1.00"
#property strict
#property version "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 clrDarkViolet
#property indicator_width1 2
#property indicator_levelcolor clrSilver
#property indicator_levelstyle STYLE_SOLID
#property indicator_level1 0
#property indicator_level2 25
#property indicator_level3 -25
#property indicator_level4 20
#property indicator_level5 -20
#property indicator_level6 15
#property indicator_level7 -15
input int EMA_Period = 12;
input ENUM_MA_METHOD EMA_Method =0;
input ENUM_APPLIED_PRICE EMA_Price =0;
input int RSI_Period = 21;
input ENUM_APPLIED_PRICE PSI_Price =0;
input int level_up_alert = 20;
input int level_dn_alert = -20;
input bool Alerts = true;
input string Text_BUY = "BUY signal text";
input string Text_SELL = "SELL signals text";
input bool Send_Mail = false;
input string subject = "subject text";
input bool Send_Notification = false;
//---- buffers
double ExtMapBuffer1[];
string name="";
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
name = "Turn Area Alert";
IndicatorShortName(name);
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexLabel(0,name);
SetIndexDrawBegin(0,MathMax(RSI_Period,EMA_Period));
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
int limit=rates_total-prev_calculated;
if(prev_calculated==0)limit--;
else limit++;
double hi=0, lo=0, ce=0;
for( int i=0; i<limit && !IsStopped(); i++)
{
ExtMapBuffer1[i] =
((iMA(NULL,0,EMA_Period,0,EMA_Method,EMA_Price,i)
- (50 - iRSI(NULL, 0, RSI_Period, PSI_Price,i))*Point)
- iMA(NULL,0,EMA_Period,0,EMA_Method,EMA_Price,i) )
/Point ;
}
//---
if(ExtMapBuffer1[0]<level_dn_alert)
{
if(NewBar()){
if(Alerts)Alert(Text_BUY);
if(Send_Mail)SendMail(subject,Text_BUY);
if(Send_Notification)SendNotification(Text_BUY);}
}
if(ExtMapBuffer1[0]>level_up_alert)
{
if(NewBar()){
if(Alerts)Alert(Text_SELL);
if(Send_Mail)SendMail(subject,Text_SELL);
if(Send_Notification)SendNotification(Text_SELL);}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
bool NewBar(int TF = 0)
{
static datetime NewTime=0;
if(NewTime!=iTime(Symbol(),TF,0))
{
NewTime=iTime(Symbol(),TF,0);
return(true);
}
return(false);
}
//----
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---